C# Excel 寫入 NPOI
下載 NPIO:http://npoi.codeplex.com/
參考資料:http://msdn.microsoft.com/zh-tw/ee818993.aspx
Dim Workbook As HSSFWorkbook = New HSSFWorkbook
Dim ms As MemoryStream = New MemoryStream
Dim sheet As HSSFSheet = Workbook.CreateSheet("My Sheet")
for(int i = 0; i < 5; i ++)
{
sheet.CreateRow(i)
sheet.GetRow(i).CreateCell(0).SetCellValue( i.ToString())
sheet.GetRow(i).CreateCell(1).SetCellValue("A" + i.ToString() )
}
Workbook.Write(ms)
Response.AddHeader("Content-Disposition", String.Format("attachment; filename=EmptyWorkbook.xls"))
Response.BinaryWrite(ms.ToArray())
Workbook = Nothing
ms.Close()
ms.Dispose()