-1

I am creating a new Excel work in C# however the action of saving As is taking for too long time (couple of minutes) the excel size I am creating is about 4MB

is there a way to speed it up?

Microsoft.Office.Interop.Excel.Workbook  xlWorkBook = xlApp.Workbooks.Add("");

logic for creating the new WorkBook....

Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet = xlWorkBook.Worksheets.Add(); 
//xlWorkBook.Worksheets.get_Item(1);
xlWorkBook.SaveAs(_pathExcel,Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, System.Reflection.Missing.Value, System.Reflection.Missing.Value, false, false, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlShared, false, false, System.Reflection.Missing.Value, System.Reflection.Missing.Value, System.Reflection.Missing.Value);

xlWorkBook.Close(true);
xlApp.Quit();
meistermeier
  • 7,942
  • 2
  • 36
  • 45
BaBaBA fksld
  • 55
  • 1
  • 6
  • try to say ``xlWorkBook.Close(false);`` - you could also try to show the application `xlApp.Visible = true` and save as manually and see how that performs – Rand Random Nov 02 '17 at 13:23
  • It is what it is, it depends on your machine's power. – SᴇM Nov 02 '17 at 13:30

1 Answers1

0

Microsoft strongly advise against office automation, specially when it's done at server side.

I have not tested these, but there are a number of free c# libaries for this, check this post out.

I used OLEDB to write into excel, which was pretty fast and simple.

donCalculator
  • 318
  • 1
  • 11