Posts
391
Comments
137
Trackbacks
0
Eine DataTable mit Aspose Cells exportieren

Hier ein Beispiel wie man eine DataTable mit Aspose.Cells exportieren kann:

Public Class CellsExport

 

    Public Sub New(ByVal dt As DataTable, ByVal name As String)

 

        'Excel-Workbook erzeugen

        Dim workbook As Workbook = New Workbook()

        workbook.Worksheets.Add()

        Dim worksheet As Worksheet = workbook.Worksheets(0)

        worksheet.Cells.ImportDataTable(dt, True, "A1")

 

        'Exceldatei ausgeben

        Dim ms As MemoryStream = workbook.SaveToStream()

        Dim bytes As Byte()

        bytes = ms.ToArray()

 

        HttpContext.Current.Response.Clear()

        HttpContext.Current.Response.ContentType = "application/vnd.ms-excel"

        HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename=ExcelExport_" & name & ".xls")

        HttpContext.Current.Response.BinaryWrite(bytes)

        HttpContext.Current.Response.End()

 

    End Sub

 

End class

 

posted on Saturday, May 30, 2009 10:43 AM Print
Comments
No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  
Please add 8 and 2 and type the answer here: