I have a web application which needs to create a spreadsheet and save it to disk. Here's what I have so far:
Imports Telerik.Web.Spreadsheet
Dim wb As New Workbook
Dim ws As New Worksheet
Dim r As Row
wb.Sheets = New List(Of Worksheet) From {ws}
ws.Rows = New List(Of Row)
r = New Row With {.Cells = New List(Of Cell)}
r.Cells.Add(New Cell With {.Value = "Spreadsheet Title", .FontSize = Convert.ToInt16(Unit.Point(12).Value)})
ws.Rows.Add(r)
r = New Row With {.Cells = New List(Of Cell)}
r.Cells.Add(New Cell With {.Value = Today.ToShortDateString, .TextAlign = TextAlign.Left})
ws.Rows.Add(r)
r = New Row With {.Cells = New List(Of Cell)}
r.Cells.Add(New Cell With {.Value = "Column Header"})
<more column headers>
ws.Rows.Add(r)
For Each dr As DataRow In ds.Tables(0).Rows
r = New Row With {.Cells = New List(Of Cell)}
If Not IsDBNull(dr("Field1")) Then r.Cells.Add(New Cell With {.Value = dr("Field1")})
<more fields>
Next dr
ws.Rows.Add(r)
Dim strPath As String = My.Settings.DocPath & "ExcelReports\"
Dim strFileName As String = "Filename.xlsx"
wb.Save(New FileStream(strPath + strFileName, FileMode.Create), ".xlsx")
Problem: When the code gets to the Save statement, I get this error: "nullable object must have a value".
I don't know what this means. The strPath, strFileName and wb objects all have values, so I don't know what nullable object is being referenced.
Can anyone point out what I'm doing wrong? Or am I going about this whole thing the wrong way (entirely possible, since this is my first attempt at this)?