Serious bug when deleting rows.
Posted: Mon Aug 05, 2019 1:13 pm
Hello all,
I'm testing out this simple chunk of code involving loading a big excel file, delete two rows and save it under another name. However, that would cause an 'Access violation at address ...' error.
Here is my current code, where XSS means TXLSSpreadSheet:
P/S: even without removing two rows in this big Excel file, it still produces a faulty Excel save file, requiring some repair work of Microsoft Excel 2010 in order to read it correctly.
My environment: Win 7, Excel 2010, Delphi 10.2, lastest XLSSpreadsheet demo package 6.00.55a...
My big Excel file:
https://drive.google.com/file/d/0B67b2Q ... Yc3g4/view
I'm testing out this simple chunk of code involving loading a big excel file, delete two rows and save it under another name. However, that would cause an 'Access violation at address ...' error.
Here is my current code, where XSS means TXLSSpreadSheet:
Code: Select all
procedure TfMain.btnOpenClick(Sender: TObject);
var
openDialog : TOpenDialog;
begin
openDialog := TOpenDialog.Create(self);
openDialog.InitialDir := GetCurrentDir;
openDialog.Options := [ofFileMustExist];
openDialog.Filter := 'Microsoft Excel(*.xlsx,*.xls)|*.xlsx;*.xls';
openDialog.FilterIndex := 1;
if openDialog.Execute then begin
XSS.Filename := openDialog.FileName;
XSS.Read;
end;
openDialog.Free;
end;
procedure TfMain.btnDeleteClick(Sender: TObject);
begin
XSS.XLS.DeleteRows(0,2,3);
end;
procedure TfMain.btnSaveClick(Sender: TObject);
var
saveDialog : TOpenDialog;
begin
saveDialog := TSaveDialog.Create(self);
saveDialog.InitialDir := GetCurrentDir;
saveDialog.Options := [ofFileMustExist];
saveDialog.Filter := 'Microsoft Excel(*.xls)|*.xls';
saveDialog.FilterIndex := 1;
if saveDialog.Execute then begin
XSS.Filename := saveDialog.FileName + '.xlsx';
XSS.Write;
end;
saveDialog.Free;
end;
My environment: Win 7, Excel 2010, Delphi 10.2, lastest XLSSpreadsheet demo package 6.00.55a...
My big Excel file:
https://drive.google.com/file/d/0B67b2Q ... Yc3g4/view