1

我正在尝试.xls使用 Google 代码“ExcelLibrary”在 c# 中编写 excel 文件。我想写行而不覆盖电子表格中已有的数据。关于如何做到这一点的任何想法?如果我应该使用更好的库,请告诉我!

我的代码如下所示:

        //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);
4

0 回答 0