Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 81585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T21:28:59+00:00 2026-05-10T21:28:59+00:00

Basically I need to insert a bunch of data to an Excel file. Creating

  • 0

Basically I need to insert a bunch of data to an Excel file. Creating an OleDB connection appears to be the fastest way but I’ve seen to have run into memory issues. The memory used by the process seems to keep growing as I execute INSERT queries. I’ve narrowed them down to only happen when I output to the Excel file (the memory holds steady without the output to Excel). I close and reopen the connection in between each worksheet, but this doesn’t seem to have an effect on the memory usage (as so does Dispose()). The data is written successfully as I can verify with relatively small data sets. If anyone has insight, it would be appreciated.

initializeADOConn() is called in the constructor

initADOConnInsertComm() creates the insert parameterized insert query

writeRecord() is called whenever a new record is written. New worksheets are created as needed.

public bool initializeADOConn()         {             /* Set up the connection string and connect.*/             string connectionString = @'Provider=Microsoft.Jet.OLEDB.4.0;' +                 'Data Source=' + this.destination + ';Extended Properties=\'Excel 8.0;HDR=YES;\'';             //DbProviderFactory factory =                 //DbProviderFactories.GetFactory('System.Data.OleDb');             conn = new OleDbConnection(connectionString);             conn.ConnectionString = connectionString;             conn.Open();              /* Intialize the insert command. */             initADOConnInsertComm();             return true;         }     public override bool writeRecord(FileListerFileInfo file)             {                 /* If all available sheets are full, make a new one. */                 if (numWritten % EXCEL_MAX_ROWS == 0)                 {                     conn.Close();                     conn.Open();                     createNextSheet();                 }                 /* Count this record as written. */                 numWritten++;                 /* Get all of the properties of the FileListerFileInfo record and add                  * them to the parameters of the insert query. */                 PropertyInfo[] properties = typeof(FileListerFileInfo).GetProperties();                 for (int i = 0; i < insertComm.Parameters.Count; i++)                     insertComm.Parameters[i].Value = properties[i].GetValue(file, null);                 /* Add the record. */                 insertComm.ExecuteNonQuery();                  return true;             } 

EDIT:

No, I do not use Excel at all. I’m intentionally avoiding Interop.Excel due to its poor performance (at least from my dabbles with it).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T21:28:59+00:00Added an answer on May 10, 2026 at 9:28 pm

    The answer is Yes, the formula you describe does equal a bad time.

    If you have a database handy (SQL Server or Access are good for this), you can do all of your inserts into a database table, and then export the table all at once into an Excel spreadsheet.

    Generally speaking, databases are good at handling lots of inserts, while spreadsheets aren’t.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 77k
  • Answers 77k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Thanks for the responses, the problem was due to a… May 11, 2026 at 3:30 pm
  • added an answer Since he didn't answer (yet) and no one else referenced… May 11, 2026 at 3:30 pm
  • added an answer as will return an object of the type you requested,… May 11, 2026 at 3:30 pm

Related Questions

I'm trying to figure out the best way to insert a record into a
I am looking to parse INSERT and UPDATE MySQL SQL queries in PHP to
I need to create an SQL query to insert some data into a table
I have ASP.Net code similar to the following (this is inside a FIELDSET): <ol>

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.