We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Fastest way to parse an Excel file?

Thread ID:

Created:

Updated:

Platform:

Replies:

108510 Apr 24,2013 09:10 PM May 2,2013 05:10 AM Windows Forms 1
loading
Tags: PDF
Josh Santangelo
Asked On April 24, 2013 09:10 PM

I am using XlsIo to parse large (50k rows) Excel documents. This takes a while. I'm not expecting it to be instant, but I'm wondering if there's any simple tricks to improve performance. An example of my current code:

using (ExcelEngine ee = new ExcelEngine())
{
    IWorkbook workbook = await ee.Excel.Workbooks.OpenAsync(await schema.OpenStreamForReadAsync());
    IEnumerable<IRange> rows = workbook.Worksheets[0].Rows.Skip(1);

    foreach (IRange row in rows)
    {
        double latitude = row.Columns[0].Number;
        double longitude = row.Columns[1].Number;
        if (!double.IsNaN(latitude) && !double.IsNaN(longitude))
        {
            Location location = new Location(latitude, longitude);
        }
    }
}

For my test spreadsheet, this is taking about six seconds. The spreadsheet has nine columns, and if I remove all but the first two (which I'm actually interested in), I can get this down to under two seconds.

I notice that XlsIo tries to parse the values of each cell in a number of ways, which gives you nice Number and DateTime properties, but this probably has a performance cost. Is there any way to customize this behavior? I'd like to tell the parser: "the first two columns are numbers, don't do anything with the rest", or "columns zero and one are numbers, two is a DateTime, so don't try to parse dates into numbers or anything".

Or maybe there's some other trick I'm missing?

Manoj Kumar G M [Syncfusion]
Replied On May 2, 2013 05:10 AM

Hi Josh,

Thank you for choosing Syncfusion products.

We have already logged a feature report to improve performance while parsing large document and it will be implemented in any of our forth-coming releases. We will get back to you once the feature has been implemented

Please let us know if you require any further clarifications.

Regards,

Manojkumar


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;