EPPlus 3.1 简单操作 Excel 2007/2010
using (ExcelPackage excelPackage = new ExcelPackage(new FileInfo(xlsxfullname))) { ExcelWorkbook wp = excelPackage.Workbook; ExcelWorksheet sh = wp.Worksheets[sheetname]; int col = 1; //1 为起始列 int rowindex = 1; //1为起始行 while (true) { //取某行的一个单元格 ExcelRange cell = sh.Cells[rowindex, col]; if (cell.Value == null || cell.Value.ToString() == "") { break; } //修改单元格 cell.Value= "123456"; //取某行的多个单元格 //ExcelRange cells= sh.Cells[rowIndex,1,rowIndex,13]; rowindex++; } //保存当前Excel文件 excelPackage.Save(); }