Header missing in Export with TadvGridExcelExport

Hi,
I use your grid-excel-bridge to Export a TAdvStringGrid to a xlsx file.
The header of the grid is missing, I find the funcionallity in ExcelIO.GridStartRow setting to "0".
The origin TAdvGrid does have headers.
But in the TAdvGridExcelExport, I do not have a property "GridStartRow" and I just got a reference to "AdvStringGrid".

If I use ExcelIO Grid, I can export only XLS files, but I do need XLSX here.
How can I export the Grid with headers?

Or do I have to fill in the headers by editing an intermediate GRID before exporting?
Regards,
Christoph Weidmann

Hi,
The functionality from AdvGridExcelIO (and more) should be all there, but some is in different places.
In particular, GridStartRow is inside "LocationOptions". So you need to set AdvGridExcelExport.LocationOptions.GridStartRow

Thanks, Adrian.
Works like a charm.
Good hidden :wink: - never searched it there ...

Could I also fix the first line in Excel to stay the headline visible on scrolling?
Regards,
Christoph

Yes, you can fix the header even if not directly. And that is probably the best advantage of TAdvGridExcelExport over the older AdvGridExcelIO. You aren't limited by what the component does out of the box.

To further customize the file, you can always start with the code from here:

In your particular case, to freeze the top row you could use:

implementation
uses VCL.FlexCel.Core, FlexCel.XlsAdapter;
...

procedure TForm40.Button1Click(Sender: TObject);
var
  xls: TExcelFile;
begin
  xls := TXlsFile.Create(1, TExcelFileFormat.v2019, true);
  try
    AdvGridExcelExport1.LocationOptions.GridStartRow := 0;

    AdvGridExcelExport1.Export(xls, TInsertInSheet.InsertRows);

    xls.FreezePanes(TCellAddress.Create(2, 1));
    xls.Save('MyFile.xlsx');

  finally
    xls.Free;
  end;
end;
1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.