i am printing invoices from c# windows forms fetching data from MySql. i want to use template that is designed in excel. i want to replace the values in the template with original values and print multiple bills or multiple copies of bills using that template.
I am successful in replacing the template values with my values but whats happening in my process is
this is what i have tried
xlWorkBook = xlApp.Workbooks.Open(@"C:\\Book1");
xlWorkSheet = xlWorkBook.Worksheets.get_Item(1);
ReplaceValuesInTemplate(xlWorkSheet);
xlWorkBook.SaveAs("C:\\Book2"); //saving as new excel WorkBook-Book2
xlWorkBook = xlApp.Workbooks.Open(@"C:\\Book2"); //Fetching Book2
xlWorkSheet = xlWorkBook.Worksheets[1];
xlWorkSheet.PrintOut(From:1,To:1, Copies:2,Preview: false); //printing
xlApp.Quit();
1) I open template from c# and replace the values with original values 2) its creating a new workbook and than i fetch that workbook and print it.
it's fine with single bill , but problem is,
if want to print multiple bills than it will create many workbooks and than i need to fetch them all and print. this creates lots of memory wastage also and seems like not a proper solution.
how can i print multiple bills from c# using template from excel?