I am working on a billing system. Everything was fine until I got a problem while printing the bills.
I have to do something like this:
for(int i=0; i<noOfHouse; i++)
-> read bill template (excel file that contains text and images)
-> change the bill amounts for ith house reading from DB
-> and then print the bill
Currently I am doing it like:
reading excel bill-template file and copying it cell-by-cell into another excel file except the cells that need to be changed.
Once the bill files are generated from the above for-loop, I've planned that the operator would select all the files and print them manually.
Can anyone give a better idea ??
July 3rd, 2011, 01:26 PM
Re: Bill Printing in C#
I would think you could automate the printing easy enough but if it were me I would not be using Excel. SQL Server or the like with the needed reports would in most if not all cases be a MUCH better choice.
for (int i = 0; i < lstHouseNo.Count; i++)
(range.Cells[12, 3] as Excel.Range).Value2 = lstOwnerName.ElementAt<String>(i); // Owner Name
(range.Cells[13, 3] as Excel.Range).Value2 = lstHouseNo.ElementAt<String>(i); // House Number
(range.Cells[14, 3] as Excel.Range).Value2 = textBoxBillingMonth.Text; // Billing Month
(range.Cells[15, 3] as Excel.Range).Value2 = textBoxDueDate.Text; // Due Date
(range.Cells[18, 6] as Excel.Range).Value2 = textBoxServiceCharges.Text; // Service Charges
(range.Cells[21, 6] as Excel.Range).Value2 = lstArrears.ElementAt<String>(i); // Arreaes
(range.Cells[24, 6] as Excel.Range).Value2 = lstMisc.ElementAt<String>(i); // Misc