0

I have problem with export dataset into xlsx. My code:

DataSet freeTable = new DataSet();
freeTable = FoxDal.Instance.freeTable;
XLWorkbook wb = new XLWorkbook();
wb.Worksheets.Add(freeTable.Tables[0], "sheet1");
wb.SaveAs(@"E:\test5.xlsx");

While running code VS give's me prompt ( asking me where is XLReentrantEnumerableSet.cs) if i dont choose it VS throw exception System.OutOfMemoryException. Im using ClosedXML. There are some attached libraries for this framework? With small tables my code working corectly.

P10trek
  • 167
  • 4
  • 15
  • Excel can only handle around 1million rows... – DavidG Mar 10 '17 at 11:22
  • Sorry i mean 500000. – P10trek Mar 10 '17 at 11:23
  • If you have fox pro tag to mean that the source is a foxpro table, then the fastest way to transfer data to Excel is to use Excel's QueryTables.Add. Second option is to transfer data using Excel's CopyFormRecordset. EPPLus would be slower but works. – Cetin Basoz Mar 13 '17 at 09:32

1 Answers1

0

I change framework to EPPlus and now i can convert large files. My new code:

        DataSet freeTable = new DataSet();
        freeTable = FoxDal.Instance.freeTable;
        FileInfo fileInfo = new FileInfo(@"E:\Test.xlsx");
        using (ExcelPackage pck = new ExcelPackage())
        {
            ExcelWorksheet ws = pck.Workbook.Worksheets.Add("table");
            ws.Cells["A1"].LoadFromDataTable(freeTable.Tables[0], true);
            pck.SaveAs(fileInfo);
        }
P10trek
  • 167
  • 4
  • 15