Fork me on Github

EPPlus

using OfficeOpenXml;

// 写入到 Excel 文件
string filePath = "C:\\Users\\Administrator\\Desktop\\output.xlsx";
ExcelPackage.License.SetNonCommercialPersonal("Dang");
using (ExcelPackage excelPackage = new ExcelPackage())
{
    ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add("Data");

    int row = 1;
    int col = 1;
    for (int i = 0; i < positionLst.Count; i++)
    {
        
        worksheet.Cells[row, col++].Value = ""+(i+1);
        for (int j = 0; j < positionLst[i].Length; j++)
        {
            worksheet.Cells[row, col].Value = positionLst[i][j];
            worksheet.Cells[row, col+1].Value = microwaveLst[i][j];
            row++;
        }

        col += 3 ;
        row = 1;
    }

    FileInfo excelFile = new FileInfo(filePath);
    excelPackage.SaveAs(excelFile);
}

 

posted @ 2025-05-12 23:10  昂昂呀  阅读(39)  评论(0)    收藏  举报