小编Rah*_*ord的帖子

在EPPlus中编写Excel文件

我已经坚持了几天,尽管有各种帮助,但这些解决方案都没有为我工作.我想要做的是使用EPPlus库创建一个excel文件,其中包含一些我从存储过程中提取的基本数据.这是我在ExportDocument.cs文件中的代码:

public static ExcelPackage CreateExcelDocument(int [] arr)
{
    String path = @"D:\temp\testsheet3.xlsx";
    //FileInfo newFile = null;
    /*if (!File.Exists(path + "\\testsheet2.xlsx"))
    newFile = new FileInfo(path + "\\testsheet2.xlsx");
    else
        return newFile;*/
    using (ExcelPackage package = new ExcelPackage())
    {
        ExcelWorksheet ws = package.Workbook.Worksheets.Add("testsheet");
        ws.Cells["B1"].Value = "Number of Used Agencies";
        ws.Cells["C1"].Value = "Active Agencies";
        ws.Cells["D1"].Value = "Inactive Agencies";
        ws.Cells["E1"].Value = "Total Hours Volunteered";
        ws.Cells["B1:E1"].Style.Font.Bold = true;

        int x = 2;
        char pos = 'B';
        foreach (object o in arr)
        {
            String str = pos …
Run Code Online (Sandbox Code Playgroud)

c# epplus

23
推荐指数
3
解决办法
12万
查看次数

标签 统计

c# ×1

epplus ×1