Malcolm
Malcolm

Reputation: 11

Invalid Pointer and Access Violation with Native Excel 3 for Delphi

I'm using Delphi 10.2 and the Native Excel 3 library to create spreadsheets.

I have the following code:

var fWorkbook: IXLSWorkbook; fSheet1: IXLSWorksheet; begin fWorkbook:=TXLSWorkbook.Create; fSheet1:=fWorkBook.Sheets.Add;

    fSheet1.Range['A1','A1'].ColumnWidth:=20;
    fSheet1.Range['B1','B1'].ColumnWidth:=20;
    fSheet1.Range['C1','C1'].ColumnWidth:=32;
    fSheet1.Range['D1','D1'].ColumnWidth:=32;
    fSheet1.Range['E1','E1'].ColumnWidth:=14;
    fSheet1.Range['F1','F1'].ColumnWidth:=14;
    fSheet1.Range['G1','G1'].ColumnWidth:=14;
    fSheet1.Range['H1','H1'].ColumnWidth:=14;
    fSheet1.Range['I1','I1'].ColumnWidth:=14;

    fSheet1.Cells[1,1].Value:='Entry Type';
    fSheet1.Cells[1,2].Value:='Intacct Acct #';
    fSheet1.Cells[1,3].Value:='Intacct Acct # Description';
    fSheet1.Cells[1,4].Value:='Store Name';
    fSheet1.Cells[1,5].Value:='Department #';
    fSheet1.Cells[1,6].Value:='Location ID';
    fSheet1.Cells[1,7].Value:='Project ID';
    fSheet1.Cells[1,8].Value:='Grant ID';
    fSheet1.Cells[1,9].Value:='Net Amount';

    intRow:=fWorkBook.SaveAs(Outfile);

'there is additional code after this. end;

This code works every time on my development system. I've also used nExcel in other projects without a problem.

However, at the client's system, the fWorkbook.SaveAs generates an "Invalid Pointer" error or Access Violation. Since I cannot duplicate it, debugging is tough.

I have tried moving the SaveAs to various places (after the initial create, after the setting of column widths and where it is now).

Anyone seen this and/or have an explanation?

Thanks! Malcolm

Upvotes: 0

Views: 175

Answers (1)

Malcolm
Malcolm

Reputation: 11

This problem was resolved by saving the workbook as an xlsx.

Upvotes: 0

Related Questions