hi,
I have an issue when creating multiple excel files. The problem is that every single file who is opened, opens is the same instance of excel (i.e. opened 3 excel files, 1 excel.exe in task manager). its unhandy when working with multiple generated reports.
I tried to create diferent workbooks,that didnt helped, and also noticed that file size sums up, and last generated file size is the biggest, independently on the content of file. It seems that some information remains the same for all generated files(did i forgot something important to clean?).
So is there any way to create separate multiple excel files?
here is my example:
var wb = new XLWorkbook();
var wb2 = new XLWorkbook();
string select = "select * from table";
//firstfile
sheetName = "name1";
sheetName2 = "name2";
DataTable dataTable = DB.selectfromDBSA(select, sheetName);
wb.AddWorksheet(dataTable);
dataTable = DB.selectfromDBSA(select, sheetName2);
wb.AddWorksheet(dataTable);
wb.SaveAs("temp/test.xlsx");
dataTable.Clear();
wb.Worksheets.Delete(sheetName);
wb.Worksheets.Delete(sheetName2);
//for example this file weight is 175kb
//second file
sheetName = "name1";
sheetName2 = "name2";
DataTable dataTable = DB.selectfromDBSA(select, sheetName);
wb2.AddWorksheet(dataTable);
dataTable = DB.selectfromDBSA(select, sheetName2);
wb2.AddWorksheet(dataTable);
wb2.SaveAs("temp/test2.xlsx");
dataTable.Clear();
wb2.Worksheets.Delete(sheetName);
wb2.Worksheets.Delete(sheetName2);
//for example this file weight is 285kb, but information is the same, because its same query to database.
thanks,
Comments: I think its with ClosedXML generated files, because if i open few regular excel files, then everything it's ok (this problem occurs only with generated files). Also besides that there is a problem, that i mentioned in the comment below description. And file sizes - if my query return a lot of data, someting about 6k rows, and then stacks thiese file sizes, and the last one weights about 2 or 3 MB, even if its empty. So maybe my technique is wrong, maybe you can suggest something that i can try? thanks.
I have an issue when creating multiple excel files. The problem is that every single file who is opened, opens is the same instance of excel (i.e. opened 3 excel files, 1 excel.exe in task manager). its unhandy when working with multiple generated reports.
I tried to create diferent workbooks,that didnt helped, and also noticed that file size sums up, and last generated file size is the biggest, independently on the content of file. It seems that some information remains the same for all generated files(did i forgot something important to clean?).
So is there any way to create separate multiple excel files?
here is my example:
var wb = new XLWorkbook();
var wb2 = new XLWorkbook();
string select = "select * from table";
//firstfile
sheetName = "name1";
sheetName2 = "name2";
DataTable dataTable = DB.selectfromDBSA(select, sheetName);
wb.AddWorksheet(dataTable);
dataTable = DB.selectfromDBSA(select, sheetName2);
wb.AddWorksheet(dataTable);
wb.SaveAs("temp/test.xlsx");
dataTable.Clear();
wb.Worksheets.Delete(sheetName);
wb.Worksheets.Delete(sheetName2);
//for example this file weight is 175kb
//second file
sheetName = "name1";
sheetName2 = "name2";
DataTable dataTable = DB.selectfromDBSA(select, sheetName);
wb2.AddWorksheet(dataTable);
dataTable = DB.selectfromDBSA(select, sheetName2);
wb2.AddWorksheet(dataTable);
wb2.SaveAs("temp/test2.xlsx");
dataTable.Clear();
wb2.Worksheets.Delete(sheetName);
wb2.Worksheets.Delete(sheetName2);
//for example this file weight is 285kb, but information is the same, because its same query to database.
thanks,
Comments: I think its with ClosedXML generated files, because if i open few regular excel files, then everything it's ok (this problem occurs only with generated files). Also besides that there is a problem, that i mentioned in the comment below description. And file sizes - if my query return a lot of data, someting about 6k rows, and then stacks thiese file sizes, and the last one weights about 2 or 3 MB, even if its empty. So maybe my technique is wrong, maybe you can suggest something that i can try? thanks.