Method importcsv of txlsreadwriteii5
Does the read support multithreading
ImportCSV MultiThread
Re: ImportCSV MultiThread
Hellolarsa wrote:Hello
Probably. Please do a test.
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;
Re: ImportCSV MultiThread
Yesterday, I had do a test again.The result as follow:larsa wrote:Hello
Probably. Please do a test.
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;