PDA

View Full Version : [CLOSED] Undefined Error



ebeker
Mar 19, 2014, 5:29 PM
I am using here EPPLUS.dll to export some to excel , i am getting this undefined error
is my code behind, i am attaching a picture of error





<ext:Button runat="server" Text="Excel" Icon="PageExcel" ID="btnExcel" >

<DirectEvents>
<Click OnEvent="MyExcel">
<EventMask ShowMask="true"></EventMask>
</Click>
</DirectEvents>
</ext:Button>

Public Sub ToExcelFromDataTable(dtb As DataTable, POINIT As String)
Try

Dim pck As ExcelPackage = New ExcelPackage
Dim ws = pck.Workbook.Worksheets.Add(POINIT)

For i = 0 To dtb.Columns.Count - 1
ws.Cells(1, i + 1).Value = dtb.Columns(i).ColumnName.ToString
ws.Cells(1, i + 1).Style.Font.Bold = True
ws.Cells(1, i + 1).Style.Fill.PatternType = ExcelFillStyle.Solid

ws.Cells(1, i + 1).Style.Fill.BackgroundColor.SetColor(Color.Yello w)


ws.Column(i + 1).AutoFit()

Next

For R = 0 To dtb.Rows.Count - 1
For C = 0 To dtb.Columns.Count - 1
ws.Cells(R + 2, C + 1).Value = dtb.Rows(R).Item(C).ToString
ws.Column(C + 1).AutoFit()

Next

Next

pck.SaveAs(Response.OutputStream)
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader("content-disposition", "attachment; filename=ItemsExport.xlsx")
Catch ex As Exception

End Try

Daniil
Mar 20, 2014, 6:31 AM
Hi @ebeker,

Please try to set up this option for the DirectEvent:

IsUpload="true"


Does it help?

Here is a guide how to download a file using a DirectEvent.
http://forums.ext.net/showthread.php?27575

ebeker
Mar 20, 2014, 3:53 PM
Worked for me thanx....