AdvGridExcelIO.GridEndCol not working when exporting xls

Hi, I have a form with a TDBAdvGrid on it. The grid has 11 columns, but I want to export only the first 10.

So, I'm setting AdvGridExcelIO.GridEndCol = 9

However, the 11th column is shown in the excel file.

Any help is appreciated.

More information:

I'm using this code to export the data to xls

Call: ExportarExcel(Grid,0,9)

Procedure TDATOS.ExportarExcel(Grid: TDBAdvGrid;ColIni:Integer=0;ColFin:Integer=0);
Begin
  If SaveDialogXLS.Execute then
    Begin
      Grid.DataSource.DataSet.DisableControls;

      try

        AdvGridExcelIO.AdvStringGrid := Grid;

        AdvGridExcelIO.GridStartCol := ColIni;
        AdvGridExcelIO.GridStartRow := 0;

        AdvGridExcelIO.XlsStartCol := 1;
        AdvGridExcelIO.XlsStartRow := 1;

        if ColFin > 0 then
        begin
           AdvGridExcelIO.GridEndCol := ColFin;
           AdvGridExcelIO.GridEndRow := Grid.RowCount+1;

           AdvGridExcelIO.XlsEndCol := ColFin+1;
           AdvGridExcelIO.XlsEndRow := Grid.RowCount;
        end;


        try
          AdvGridExcelIO.XLSExport(SaveDialogXLS.FileName);
        except
         on E:Exception do
         begin
           MessageDlg('Error, no se pudo guardar el archivo: '+SaveDialogXLS.FileName+'. Compruebe que no esté en uso por otro usuario',mtWarning,[mbOk],0);
         end;
        end;

      finally
        Grid.DataSource.DataSet.EnableControls;
      end;

    End;
End;

Setting or not XlsStartCol, XlsEndCol has no effect

Grid.ColCount = 11 (Column 0... Column 10)
Grid.FixedCols = 0
Grid.FixedRows = 1

The last column (index 10) is hidden in FormShow (Grid.HideColumn...)

When loading the data, Column2.FieldName is set to blank.

I retested this here with:

procedure TForm1.Button1Click(Sender: TObject);
begin
  AdvGridExcelIO1.GridStartRow := 2;
  AdvGridExcelIO1.GridStartCol := 2;
  AdvGridExcelIO1.GridEndRow := 50;
  AdvGridExcelIO1.GridEndCol := 5;
  advgridexcelio1.XLSExport('e:\tms\temp\subset.xls')
end;

and this exports the desired subset of cells to the xls file.
So, it is unclear how this behaves different for you.
If the problem persists, can you isolate & send a sample source project with which we can reproduce this here?

Hi, thank you for your response. Apologies for not isolating the issue, as the source grid depends on external data and I was short on time. In the end, I used TAdvGridExcelExport along with the FlexCel API to achieve the desired output.

I’ll try to isolate the issue when I have more spare time and will get back here with a follow-up.

Ok, thanks