Page 1 of 1

Progress for ImportCSV

Posted: Mon Mar 05, 2007 10:15 am
by kooths
The OnProgress event seems to be triggered only for reading/writing xls-files. Is there a way to use it while importing csv-files aswell?

Posted: Tue Mar 06, 2007 5:42 pm
by larsa
Hello

Yes. But you have to modify the source of the file ImportCSV2.pas

Code: Select all

// 1. Reset the progress.
    ProgressCount := 0;
    if Assigned(XLS.OnProgress) then
      FXLS.OnProgress(Self,0);

// 2. Insert this code after the for loop in the ImportCSVInt function.
// You shall also add two int variables, V and ProgressCount
        if Assigned(XLS.OnProgress) then begin
          V := Round((i / Lines.Count) * 100);
          // Don't update the progress for each line, as this can slow things down...
          if V > ProgressCount then begin
            ProgressCount := V;
            XLS.OnProgress(Self,ProgressCount);
          end;
        end;

// 3. At the end of the function, make sure that progress is at 100.
    if Assigned(XLS.OnProgress) then
      XLS.OnProgress(Self,100);
I have not tested this code, so there may be some error...


Lars Arvidsson