Dim workbook As New HSSFWorkbook()

        Dim sheet As HSSFSheet = workbook.CreateSheet("Sheet111")
        Dim rowItem As HSSFRow
        rowItem = sheet.CreateRow(0)
        rowItem.CreateCell(0).SetCellValue("測試資料111")

        sheet = workbook.CreateSheet("Sheet222")
        rowItem = sheet.CreateRow(0)
        rowItem.CreateCell(0).SetCellValue("測試資料222")
        rowItem.CreateCell(1).SetCellValue("測試資料222")

        sheet = workbook.CreateSheet("Sheet333")
        rowItem = sheet.CreateRow(0)
        rowItem.CreateCell(0).SetCellValue("測試資料333")

        Dim ms As MemoryStream = New MemoryStream()
        workbook.Write(ms)
        Dim file As FileStream = New FileStream("test.xls", FileMode.Create)
        Response.AddHeader("Content-Disposition", String.Format("attachment; filename=test.xls"))
        HttpContext.Current.Response.BinaryWrite(ms.ToArray())

        workbook = Nothing
        ms.Close()
        ms.Dispose()

goodlucky 發表在 痞客邦 PIXNET 留言(0) 人氣()