I have developed a windows form project that is export large date in excel. Sometimes worksheet.save() method takes 1 hour or infitine time. I think it stay locked, but I don't know why. Does anyone have any ideas to solve this?
...
FileInfo temp_excel_file = new FileInfo(Path.Combine(ConfigFile.ConfigsPaths["ExcelRaporFolder"], "temp", "Rakip.xlsm"));
rapor_file = new FileInfo(Path.Combine(ConfigFile.ConfigsPaths["ExcelRaporFolder"], "excel", FileName + ".xlsm"));
File.Copy(temp_excel_file.FullName, rapor_file.FullName);
Log.LogYaz(rapor_file.Name + "-Excell Açılıyor..");
SpreadsheetDocument myDoc = SpreadsheetDocument.Open(rapor_file.FullName, true);
IEnumerable<Sheet> sheets = myDoc.WorkbookPart.Workbook.Descendants<Sheet>();
WorksheetPart worksheetPart = (WorksheetPart)myDoc.WorkbookPart.GetPartById(sheets.Skip(1).First().Id);
SheetData sheetData = worksheetPart.Worksheet.Elements<SheetData>().First();
Log.LogYaz(rapor_file.Name + "-Rowlar Yaziliyor..");
uint row = 2;
Stopwatch swLoadTime = new Stopwatch();
swLoadTime.Start();
foreach (var row_index in filtered_data)
{
....
sheetData.AppendChild(Utils.CreateRow(row, 0, cell_data));
row++;
}
swLoadTime.Stop();
string loadRowTime = swLoadTime.Elapsed.ToString();
Log.LogYaz("RowsWasLoaded -" + FileName.ToString() + Environment.NewLine + " Load Row Time:" + loadRowTime);
swLoadTime.Reset();
swLoadTime.Start();
worksheetPart.Worksheet.Save();
myDoc.Close();
myDoc = null;
swLoadTime.Stop();
Log.LogYaz("RaporYazildi -" + FileName.ToString() + Environment.NewLine + " Load Row Time:" + loadRowTime + Environment.NewLine + " Save File Time:" + swLoadTime.Elapsed);