John,
The code below uses automation which has a reference to [Microsoft Excel
10.0 Object Library] requiring no database. Consider it code to pick things
out of, nothing fancy.
Private Sub Demo()
Dim ExcelApp As New Excel.Application
Dim ExcelWorkbook As Excel.Workbook
Dim ExcelSheet As New Excel.Worksheet
Try
ExcelApp = DirectCast(CreateObject("Excel.Application"),
Excel.Application)
ExcelApp.Visible = True
ExcelWorkbook = ExcelApp.Workbooks.Add
ExcelSheet = DirectCast(ExcelWorkbook.ActiveSheet, Excel.Worksheet)
Catch ex As Exception
Console.WriteLine(ex.Message)
My.Application.ExceptionDialog("Failed to create needed COM/Excel
objects")
Exit Sub
End Try
With ExcelSheet.Range("A1")
.AddComment("Report Title goes here..whatever they want")
.Font.Bold = True
.Font.Size = 10
.Value = "Report Title for the report"
.ColumnWidth = 19.86
End With
With ExcelSheet.Range("A2")
.Font.Bold = True
.Font.Size = 10
.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft
.Value = Now.Month.ToString & "/" & Now.Day.ToString & "/" &
Now.Year.ToString
End With
With ExcelSheet.Range("A5")
.Font.Bold = True
.Font.Size = 10
.Value = "Equipment Data"
.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
End With
With ExcelSheet.Range("A6")
.Font.Bold = True
.Font.Size = 10
.Value = "Industry"
.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
End With
With ExcelSheet.Range("B6")
.Font.Size = 10
.Value = "Food"
End With
With ExcelSheet.Range("A7")
.Font.Bold = True
.Font.Size = 10
.Value = "Other Ind. (Lib Filing)"
.HorizontalAlignment = Excel.XlHAlign.xlHAlignRight
End With
With ExcelSheet.Range("B7")
.Font.Size = 10
.Value = "Data data ---- Equipment Type ---- data data data data
data"
End With
' More fields here
With ExcelSheet.Range("B16")
.Font.Bold = True
.Font.Size = 10
.Value = "Comments"
.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter
End With
With ExcelSheet.Range("B17")
.ColumnWidth = 50
.Font.Size = 10
.Value = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat
volutpat. "
.HorizontalAlignment = Excel.XlHAlign.xlHAlignLeft
.VerticalAlignment = Excel.XlVAlign.xlVAlignTop
.Orientation = 38
.WrapText = True
End With
Try
ExcelWorkbook.SaveAs("C:\test.xls")
ExcelApp.Quit()
Catch ex As Exception
End Try
End Sub
Other thoughts if you had your version of Office with the lastest patches
starting I believe with Office 2003 is to using file i/o and create your
Excel files using Office XML. I have some start up code if you like pop me
an email.