ImportCSV MultiThread

Questions and answers on how to use XLSReadWriteII 5.
Post Reply
zhuhy87
Posts: 3
Joined: Wed Sep 09, 2020 7:56 am

ImportCSV MultiThread

Post by zhuhy87 »

Method importcsv of txlsreadwriteii5
Does the read support multithreading
larsa
Site Admin
Posts: 926
Joined: Mon Jun 27, 2005 9:30 pm

Re: ImportCSV MultiThread

Post by larsa »

Hello

Probably. Please do a test.
Lars Arvidsson, Axolot Data
zhuhy87
Posts: 3
Joined: Wed Sep 09, 2020 7:56 am

Re: ImportCSV MultiThread

Post by zhuhy87 »

larsa wrote:Hello

Probably. Please do a test.
Hello
In fact, I want to ask if the XLSReadWriteII5 control supports multithreading

Then I have done some tests on my project. The project mainly compares two different CVS files. There is only one answerfile and one examfile for each student
I have used multithreading for testing. I have opened 10 threads, and one thread has read 500 times. If something happens, there will be an address error. After searching the data, there is no discovery, so I want to ask

core code like:
//Open
AAnswerXLS := TXLSReadWriteII5.Create(nil);
AAnswerFile := AAnswerPath + ASheetName + '.csv';
ImportCSV(AAnswerXLS, 0, 0, 0, AAnswerFile, ',', True);
AAnswerSheet := AAnswerXLS.Sheets[0];

AExamXLS := TXLSReadWriteII5.Create(nil);
AExamFile := AExamPath + ASheetName + '.csv';
ImportCSV(AExamXLS, 0, 0, 0, AExamFile, ',', True);
AExamSheet := AExamXLS.Sheets[0];

//Read like this
function XLSPreciseReadCell(ASheet: TXLSWorksheet; Row, Col: Integer): string;
var
CellType: TXLSCellType;
begin
Result := string.Empty;
Col := Col - 1;
Row := Row - 1;
CellType := ASheet.CellType[Col,Row];
if CellType <> xctNone then
begin
Result := ASheet.AsString[Col,Row];
end;
end;
zhuhy87
Posts: 3
Joined: Wed Sep 09, 2020 7:56 am

Re: ImportCSV MultiThread

Post by zhuhy87 »

larsa wrote:Hello

Probably. Please do a test.
Yesterday, I had do a test again.The result as follow:
When there are dozens of threads, each new city will execute my program 500 times, and occasionally there will be errors. 20 threads will execute 2000 times, and 100 threads will execute 10 times. The problem stack is as shown in the figure
Error stack pointing : AExamXLS := TXLSReadWriteII5.Create(nil); or AExamXLS.Free;
Post Reply