Quantcast
Channel: ClosedXML - The easy way to OpenXML
Viewing all articles
Browse latest Browse all 1877

Commented Unassigned: creating multiple files at once [9328]

$
0
0
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 attached my generated files, there is same data to 1 and 3 file and 2 and 4 file, please can you compare thiese files and i think you might see the problem(file size, collumns, and they cannot be splited in the same window). the problem reproduction is simple, just use my code above, fill some data to datatable1 and datatable2, and save it to test1,test2, test3,test4 files. i suggest to save datatable1 data to 1 and 3 file, and datatable2 to 2 and 4 file, that could be easy to compare, how file size is summing up, and collums remain from the widest datatable. if there is a problem, i can share all the code, so you can replicate the same situation. thanks.

Viewing all articles
Browse latest Browse all 1877

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>