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. Image for the cookie policy date
close icon

Fastest way to parse an Excel file?

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?

1 Reply

MK Manoj Kumar G M Syncfusion Team May 2, 2013 09:10 AM UTC

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


Loader.
Live Chat Icon For mobile
Up arrow icon