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

Import huge datatable

I'm trying to import a huge datatable (408000 records, 18 fields per record) but I'm getting an "OutofMemory Exception" each time I try to do that.

This is the code I used

ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;

IWorkbook workbook = application.Workbooks.Create(1);
workbook.Version = ExcelVersion.Excel2010;
IWorksheet sheet = workbook.Worksheets[0];

sheet.ImportDataTable(datatable, false, 2, 1, true);

workbook.SaveAs(filename);
workbook.Close();
excelEngine.Dispose();

I also tried to manually import the datatable with a foreach statement, but then I get the OutOfMemory error around row 138000.


1 Reply

SR Sridhar Syncfusion Team May 9, 2011 12:33 PM UTC

Hi Ronan,

Thank you very much for using Syncfusion products.

In Essential XlsIO, we will be using the system memory for content preservation until it is save to the file .If we are dealing with large amount of data, the XlsIO component requires more system memory to preserve the details. In order to avoid such reported exceptions our existing object model requires more changes. We have already logged a feature report for the same and it will implemented in our forth coming releases. We highly regret for the inconvenience.

The ImportDataTable is best one to import the data then importing the data using foreach loop.


Please let us know if you need any clarifications.

Thanks,
Sridhar.S




Loader.
Live Chat Icon For mobile
Up arrow icon