TAdvGridExcelIO Column Widths

I"m using an a TAdvGridExcelIO component to export a nicely formatted TAdvStringGrid to Excel.  All is good with the exception of exporting the column widths. The export sets all columns to the same width. How to format custom column widths?

Did you set AdvGridExcelIO.Options.ExportCellSizes = true?

Yes, ExportCellSized is true.

I have retested this here with a default TAdvStringGrid and TAdvGridExcelIO on the form and the code:


procedure TForm1.Button1Click(Sender: TObject);
begin
  advgridexcelio1.XLSExport('e:\tms\temp\gridcolwidths.xls')
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i: integer;
begin
  advstringgrid1.ColCount := 15;
  for i := 0 to advstringgrid1.ColCount - 1 do
    begin
      if odd(i) then
        advstringgrid1.ColWidths := 192
      else
        advstringgrid1.ColWidths := 32;
    end;

  advstringgrid1.RandomFill(false,100);
end; 

and this is exporting the grid with its column sizes as expected.
What is different in your project?

I'm setting the first column width as: fAdvStringGrid.ColWidths[0] := 250;  The rest I set to 40.  The AdvStringGrid renders perfectly as expected...

Was retested once more with a default grid, default advgridexcelio on the form with the code:


procedure TForm1.Button1Click(Sender: TObject);
begin
  advgridexcelio1.GridStartRow := 0;
  advgridexcelio1.GridStartCol := 0;
  advgridexcelio1.XLSExport('e:\tms\temp\gridcolwidths.xls');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
   advstringgrid1.LinearFill(true);
   advstringgrid1.ColWidths[0] := 250;
end;

and this works as expected.

If a problem persists, please contact us by email with a sample source project that demonstrates this issue with the latest version of the components.