1

I am trying to write excel .xls files in c# by the use of the Google Code "ExcelLibrary". I want to write lines without writing over the data that is already in the spreadsheet. Any ideas on how I can do this? If there is a better library that I should use, please let me know!

My code is shown below:

        //gives us correct location to find excel file to edit
        string loco = "D://PayDay//PayDay_Files//Debtors//";
        loco = loco + debtorName;

        //declaration of XLS File
        string file = loco + "//debtor_template.xls";
        Workbook wb = new Workbook();
        Worksheet ws = new Worksheet("Worksheet 1");

        //header of XLS
        ws.Cells[0, 1] = new Cell("Debt Name");
        ws.Cells[0, 2] = new Cell("Amount");
        ws.Cells[0, 3] = new Cell("Date");
        ws.Cells[0, 4] = new Cell("Payment Due");
        ws.Cells[0, 5] = new Cell("Notes");


        //data collected from form to print on xls file
        ws.Cells[2, 1] = new Cell(debtName);
        ws.Cells[2, 2] = new Cell(amount);
        ws.Cells[2, 3] = new Cell(date);
        ws.Cells[2, 4] = new Cell(paymentDue);
        ws.Cells[2, 5] = new Cell(notes);
        wb.Worksheets.Add(ws);
        wb.Save(file);
Dale K
  • 25,246
  • 15
  • 42
  • 71

0 Answers0