-
StackOverflow 文档
-
epplus 教程
-
将数据附加到现有文档
-
附加数据
//the path of the file
string filePath = "C:\\ExcelDemo.xlsx";
//or if you use asp.net, get the relative path
filePath = Server.MapPath("ExcelDemo.xlsx");
//create a fileinfo object of an excel file on the disk
FileInfo file = new FileInfo(filePath);
//create a new Excel package from the file
using (ExcelPackage excelPackage = new ExcelPackage(file))
{
//create an instance of the the first sheet in the loaded file
ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets[1];
//add some data
worksheet.Cells[4, 1].Value = "Added data in Cell A4";
worksheet.Cells[4, 2].Value = "Added data in Cell B4";
//save the changes
excelPackage.Save();
}