DataTable Log = DbHelperSQL.Query(" select * from WorkSummaryLog ").Tables[0];

    //查出数据库的数据放入DataTable表内
            ExcelWorksheet ws = pck.Workbook.Worksheets.Add("he");

    //为页码添加一个名字
            ws.Cells["a1"].LoadFromDataTable(Log, true);

    //导出从a1开始
            var data = pck.GetAsByteArray();

    //保存和归来的Excel文件作为一个ByteArray
            context.Response.Clear();  

    //输出头文件  
            context.Response.AddHeader("content-disposition", "attachment;  filename=日志记录.xlsx");
            context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            context.Response.BinaryWrite(data);
            context.Response.Flush();
            context.Response.End();

相关文章:

  • 2022-12-23
  • 2021-12-09
  • 2021-06-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-27
  • 2021-10-15
相关资源
相似解决方案