【发布时间】:2017-08-08 06:18:10
【问题描述】:
我正在编写一个应用程序,我需要将数据单元格值存储到 Excel 工作表中。一切正常,但问题是每次我运行应用程序时,它都会覆盖现有数据。
到目前为止,我从 Github 获取的代码:
var workbook = new XLWorkbook();
var worksheet = workbook.Worksheets.Add("Sample Sheet");
worksheet.Cell("A1").Value = this.textBox1.Text;
worksheet.Cell("B1").Value = this.textBox2.Text;
worksheet.Cell("C1").Value = this.textBox3.Text;
worksheet.Cell("D1").Value = col1;
worksheet.Cell("E1").Value = col2;
worksheet.Cell("F1").Value = this.textBox6.Text;
workbook.SaveAs("HelloWorld.xlsx");
注意:我不想使用数据表或任何东西来保存数据。我只想从文本框中获取值并将它们附加到现有工作表中。我访问过许多stackoverflow post,但它们对我帮助不大。
提前致谢!
【问题讨论】:
标签: c# excel worksheet-function closedxml