Progress for ImportCSV
Progress for ImportCSV
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?
Hello
Yes. But you have to modify the source of the file ImportCSV2.pas
I have not tested this code, so there may be some error...
Lars Arvidsson
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);
Lars Arvidsson