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