wheatlas.blogg.se

Delphi read excel file
Delphi read excel file












delphi read excel file delphi read excel file

and the number of columns, we activate the last non-empty cell of it In order to know the dimension of the WorkSheet, i.e the number of rows XLApp := CreateOleObject('Excel.Application') Get each worksheets name and add it to the combo boxĬomboBox1.additem((Worksheets as _WorkSheet).Name,nil) ĬomboBox1.ItemIndex := 0 // set item indexīTW, the parameters (eg for )may vary between versions of Office - the ones I've used are for OfficeXP, but seem to work with the most recent edition.Function Xls_To_StringGrid(AGrid: TStringGrid AXLSFile: string): Boolean used this only to demonstrate getting the sheet names Procedure TForm1.FormActivate(Sender: TObject) ******* Display the results in the caption - this is the actual reading bit! ********

delphi read excel file

If (length(cCol) = 0) or not (cCol in ) thenĬCell := trim(E_Column.Text) + trim(E_Row.Text) // make the cell string Set the worksheet - must be its numeric value! WorkBooks.Open(fExcelFile,EmptyParam,EmptyParam,EmptyParam,EmptyParam,EmptyParam,ĮmptyParam, EmptyParam,EmptyParam,EmptyParam,EmptyParam,ĮmptyParam,EmptyParam,EmptyParam,EmptyParam,LCID) Converter, AddToMru, Local, CorruptLoad, LCID) IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, Visible := false // make Excel invisible when it worksīegin // Open the workbook to the existing file LCID := GetUserDefaultLCID // not sure what this is - me thinks its a handle Procedure TForm1.Button1Click(Sender: TObject) ĬCol, // string to check the column valueįExcelFile := 'c:\mypath\myfile.xls' // File to open Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,ĭialogs, StdCtrls, ExcelXP, OleServer, Mask














Delphi read excel file