× Components and Libraries for Documents Development, discussions, problems and suggestions

Question Auto size columns Fspreadsheet

  • Randall G Garcia C
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
5 years 1 week ago - 5 years 1 week ago #7792 by Randall G Garcia C
Auto size columns Fspreadsheet was created by Randall G Garcia C
this would be the correct procedure in the package pl_fpspreadsheet
procedure TsCustomWorksheetGrid.AutoAdjustColumn(ACol: Integer);
var
  gRow: Integer;  // row in grid coordinates
  r: Cardinal;
  lastRow: Cardinal;
  w, maxw: Integer;
  txt: String;
begin
  if Worksheet = nil then
    exit;

  lastRow := Worksheet.GetLastOccupiedRowIndex;
  maxw := -1;
  for r := 0 to lastRow do
  begin
    gRow := GetGridRow(r);
    txt := GetCellText(ACol, gRow);
    PrepareCanvas(ACol, gRow, []);
    w := Canvas.TextWidth(txt);
    if (txt <> '') and (w > maxw) then maxw := w;
  end;
  if maxw > -1 then
    maxw := maxw + 2*constCellPadding
  else
    maxw := DefaultColWidth;

 if Acol<Worksheet.GetLastOccupiedColIndex then  //LINE TO FIX THE PROBLEM

  ColWidths[ACol] := maxW;
  HeaderSized(true, ACol);
end;


the line marked in red serious which should be added
Last edit: 5 years 1 week ago by Randall G Garcia C.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
5 years 1 week ago #7793 by Sternas Stefanos
Replied by Sternas Stefanos on topic Auto size columns Fspreadsheet
Thanks Sir
we will test and report

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.

  • Randall G Garcia C
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
5 years 1 week ago - 5 years 1 week ago #7796 by Randall G Garcia C
Replied by Randall G Garcia C on topic Auto size columns Fspreadsheet
Thanks, do a great job, and I have applications in production and are excellent, thanks guys
Last edit: 5 years 1 week ago by Randall G Garcia C.

Please Log in or Create an account to join the conversation.

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Away
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
More
5 years 1 week ago #7797 by Sternas Stefanos
Replied by Sternas Stefanos on topic Auto size columns Fspreadsheet
Thanks Sir
we add your fix to lab CT 5.5 ver

PilotLogic Architect and Core Programmer

Please Log in or Create an account to join the conversation.