2

I am working on a winform with spreadsheetlight library.I want to create a excel file with specific name under a specific folder when user clicked on "Save to Excel" button. Ihave tried the below code so far.

string path = System.IO.Path.GetTempPath();

sl.SaveAs(path + "\\" + dosyaismi + ".xlsx");
FileInfo fi = new FileInfo(path + "\\" + dosyaismi + ".xlsx");
if (fi.Exists)
{
    System.Diagnostics.Process.Start(@path + "\\" + dosyaismi + ".xlsx");
}
else
{
    MessageBox.Show("Dosya bulunamadı!");
}

When program run and clicked that button first time it takes 2 minutes to create file.But without closing program I clicked that button again with different filename it creates file immediately.

I searched for 2 hours but ı didn't find any solution.Can anyone help what is the problem?

Harun Yılmaz
  • 96
  • 1
  • 11
  • Is Excel running the second time? `System.Diagnostics.Process.Start` starts Excel, which takes a while to load the first time you run it. The saving may not be the bottleneck it may be launching Excel. – Lithium Jun 09 '16 at 08:29
  • I debugged code , actually the "sl.saveAs..." line works slow.Other parts work with normal speed – Harun Yılmaz Jun 09 '16 at 08:30
  • i have the same problem, it seems that when i removed the hyperlinks from worksheet the sl.SaveAs works @8 times faster – Sas Gabriel Sep 09 '16 at 14:55

0 Answers0