I'm looking to create a simple windows service to export data from SQL tables, through a .NET datatable, directly to an Excel xlsx file.
Whilst testing ClosedXML, I found that when the 1st column is a uniqueidentifier the ClosedXML.dll errors
"An unhandled exception of type 'System.ArgumentException' occurred in ClosedXML.dll
Additional information: Unable to set cell value to [insert uniqueidentifier here]"
Is there any easy way around this?
Sample Code:
Private Sub ExportToxlsxUsingClosedXML
Dim appPath As String = Directory.GetCurrentDirectory()
Dim filename As String = appPath & "\mytest_" & Format(Now, "yyyyMMddHHmmss") & ".xlsx"
Dim SQL_Query As String = "select * FROM [mydb].[dbo].[mytable] where myDate >= '2017-01-01' "
Dim myTable As DataTable = CLS_SQL.SQL_Retrieve(SQL_Query)
Dim wb As XLWorkbook = New XLWorkbook
wb.Worksheets.Add(myTable, "MyData")
wb.SaveAs(filename)
End Sub