Page 1 of 1

Read sequentially an excel file

Posted: Mon Nov 27, 2017 4:54 pm
by advantage
Hi all.

I need to open a excel file with about 3000 lines and 5 columns , and for each cell do some calculation
and them write them in a database searching previously if cell one does not exist in my db file.

How can I do that ??

Mant thanks.

Regards

Re: Read sequentially an excel file

Posted: Tue Nov 28, 2017 1:06 pm
by larsa
Hello

Here is an example:

Code: Select all

  XLS[0].CalcDimensions;

  for r := XLS[0].FirstRow to XLS[0].LastRow do begin
    for c := XLS[0].FirstCol to XLS[0].LastCol do begin
      // Do something with the values.
      case XLS[0].CellType[c,r] of
        xctNone          : ;
        xctBlank         : ;
        xctBoolean       : B := XLS[0].AsBoolean[c,r];
        xctError         : ;
        xctString        : S := XLS[0].AsString[c,r];
        xctFloat         : V := XLS[0].AsFloat[c,r];
        xctFloatFormula  : ;
        xctStringFormula : ;
        xctBooleanFormula: ;
        xctErrorFormula  : ;
      end;
    end;
  end;

Re: Read sequentially an excel file

Posted: Tue Nov 28, 2017 5:59 pm
by advantage
Thank you so much.

Works perfectly..

Regards