var workbook = new HSSFWorkbook();
var sheetReportResult = workbook.CreateSheet("結果");
sheetReportResult.CreateRow(0).CreateCell(0).SetCellValue("開始時間");
//之後的用GetRow 取得在CreateCell
sheetReportResult.GetRow(0).CreateCell(1).SetCellValue("結束時間");
sheetReportResult.GetRow(0).CreateCell(2).SetCellValue("資料大小(KB)");
sheetReportResult.GetRow(0).CreateCell(3).SetCellValue("花費時間(s)");
sheetReportResult.GetRow(0).CreateCell(4).SetCellValue("速度(KB/s)");
int i = 1;
foreach (string str in sb.ToString().Split('|'))
{
if (str != "")
{
sheetReportResult.CreateRow(i).CreateCell(0).SetCellValue(str.Split(',')[0].Replace("Start Time: ", ""));
sheetReportResult.GetRow(i).CreateCell(1).SetCellValue(str.Split(',')[1].Replace(" End Time :", ""));
sheetReportResult.GetRow(i).CreateCell(2).SetCellValue(str.Split(',')[2].Replace(" Size:", ""));
sheetReportResult.GetRow(i).CreateCell(3).SetCellValue(str.Split(',')[3].Replace(" Total:", ""));
sheetReportResult.GetRow(i).CreateCell(4).SetCellValue(str.Split(',')[4].Replace(" Speed:", ""));
i++;
}
}
sheetReportResult.SetColumnWidth(0, 20 * 256);
sheetReportResult.SetColumnWidth(1, 40 * 256);
sheetReportResult.SetColumnWidth(2, 40 * 256);
var file = new FileStream("C:/ample.xls", FileMode.Create);
workbook.Write(file);
file.Close();
2014年7月6日 星期日
C# NPOI export xls
Third Part NPOI
Nuget搜尋NPOI
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言