Hello All,
I am trying to export a file following the code and examples provided here. Using VS 2015. It continually errors at the Response.AddHeader line, stating "Value does not fall within the expected range". This happens both when I append my variable to the filename or have it hardcoded. I am currently debugging the code, so the "server" is my localhost.
Any help is greatly appreciated!
Here is my sub:
Private Sub ExportToExcel(ByVal dtTemp As System.Data.DataTable, ByVal FName As String, ByVal colNum As Integer)
Dim dt As System.Data.DataTable = dtTemp
Dim ws As ExcelWorksheet
Using pck As New ExcelPackage()
ws = pck.Workbook.Worksheets.Add("Test")
ws.Cells("A1").LoadFromDataTable(dt, True)
Select Case colNum
Case 2
Using rng As ExcelRange = ws.Cells("A1:B1")
rng.Style.Font.Bold = True
End Using
Case 3
Using rng As ExcelRange = ws.Cells("A1:C1")
rng.Style.Font.Bold = True
End Using
Case 4
Using rng As ExcelRange = ws.Cells("A1:D1")
rng.Style.Font.Bold = True
End Using
Case 5
Using rng As ExcelRange = ws.Cells("A1:E1")
rng.Style.Font.Bold = True
End Using
End Select
Me.Context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Me.Context.Response.AddHeader("content-disposition", "attachment; filename=" & FName)
Me.Context.Response.BinaryWrite(pck.GetAsByteArray())
Me.Context.Response.End()
End Using
End Sub
I am trying to export a file following the code and examples provided here. Using VS 2015. It continually errors at the Response.AddHeader line, stating "Value does not fall within the expected range". This happens both when I append my variable to the filename or have it hardcoded. I am currently debugging the code, so the "server" is my localhost.
Any help is greatly appreciated!
Here is my sub:
Private Sub ExportToExcel(ByVal dtTemp As System.Data.DataTable, ByVal FName As String, ByVal colNum As Integer)
Dim dt As System.Data.DataTable = dtTemp
Dim ws As ExcelWorksheet
Using pck As New ExcelPackage()
ws = pck.Workbook.Worksheets.Add("Test")
ws.Cells("A1").LoadFromDataTable(dt, True)
Select Case colNum
Case 2
Using rng As ExcelRange = ws.Cells("A1:B1")
rng.Style.Font.Bold = True
End Using
Case 3
Using rng As ExcelRange = ws.Cells("A1:C1")
rng.Style.Font.Bold = True
End Using
Case 4
Using rng As ExcelRange = ws.Cells("A1:D1")
rng.Style.Font.Bold = True
End Using
Case 5
Using rng As ExcelRange = ws.Cells("A1:E1")
rng.Style.Font.Bold = True
End Using
End Select
Me.Context.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Me.Context.Response.AddHeader("content-disposition", "attachment; filename=" & FName)
Me.Context.Response.BinaryWrite(pck.GetAsByteArray())
Me.Context.Response.End()
End Using
End Sub