¤ I want to be able to create an Excel file with a VB.NET program on a server that does not have Microsoft Excel loaded on it. I am using the Jet OLE DB to read other data files. Can this be used to save an array in an Excel .XLS format?
You can use COM ADOX (Microsoft ADO Ext 2.x for DDL and Security) to create an Excel workbook:
Dim tbl As New ADOX.Table
Dim col As New ADOX.Column
Dim cat As New ADOX.Catalog
Dim cnn As New ADODB.Connection
cnn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=e:\My Documents\ExcelWB.xls;Extended Properties=Excel 8.0"
cnn.Open()
cat.ActiveConnection = cnn
tbl = New ADOX.Table
tbl.Name = "TestTable"
col = New ADOX.Column
With col
.Name = "Col1"
.Type = ADOX.DataTypeEnum.adDouble
End With
tbl.Columns.Append(col)
col = Nothing
col = New ADOX.Column
With col
.Name = "Col2"
.Type = ADOX.DataTypeEnum.adVarWChar
End With
tbl.Columns.Append(col)
cat.Tables.Append(tbl)
cat = Nothing
Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)