上传者: zyc15732116265
|
上传时间: 2021-09-24 10:16:34
|
文件大小: 2KB
|
文件类型: TXT
private void ToExcel(HttpContext context, string TempletFileName//模版文件, string ReportFileName//导出文件, DataTable dt2)
{
//模板文件
//string TempletFileName = context.Server.MapPath(TempletFileName);
//导出文件
//string ReportFileName = context.Server.MapPath("out.xls");
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
HSSFWorkbook hssfworkbook = new HSSFWorkbook(file);
//XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
//HSSFSheet ws = (HSSFSheet)hssfworkbook.GetSheetAt(0);//GetSheet("Sheet1");
HSSFSheet ws2 = null;
int rowsCount = dt2.Rows.Count;
int columnCount = dt2.Columns.Count;
int num = 60000;
int row = 0;
if (rowsCount > 0)
{
int sheetCount = rowsCount > num ? (int)Math.Ceiling((double)(rowsCount / num)) : 0;
for (int i = 0; i rowsCount - (num * i) ? rowsCount : (i + 1) * num;
NPOI.SS.UserModel.IRow row1 = null;
for (int j = strRows; j < endRows; j++)
{
row++;
int m = 0;
if (i == 0)
{
m = 4;
}
row1 = ws2.CreateRow(row + m);
row1.HeightInPoints = 25;//行高
for (int k = 0; k < columnCount; k++)
{