I am creating a Delphi program that needs to extract data from our database and create an Excel report. I would prefer to use the Delphi components TExcelApplication, TExcelWorkbook and TExcelWorksheet, but I haven't been able to get them to work. Most of the examples I have found are fairly old and I don't know if that's the problem or not.
Can anyone point me to a tutorial or example that uses these components in Delphi to create an Excel spreadsheet, populate that spreadsheet (I will be using data from the database), and then save that spreadsheet as a given filename?
I have been able to get fairly far using CreateOleObject('Excel.Application') to return me a variant, but then I'm running fairly blind not having any documentation and using just trial and error to make any progress.
Using the components, I have only gotten this far:
oXL.Connect;
ExcelApplication1.Visible[0] := True;
ExcelApplication1.Caption := 'Terry''s Special Excel Application';
ExcelWorkBook1.ConnectTo(ExcelApplication1.Workbooks[0]); <= This dies: Invalid Index
ExcelWorksheet1.ConnectTo(ExcelWorkBook1.ActiveSheet as _Worksheet);
ExcelApplication1.UserControl := True;