Welcome, Guest
Username: Password: Remember me
Components and Libraries for Documents Development, discussions, problems and suggestions
  • Page:
  • 1

TOPIC:

Auto size columns Fspreadsheet 9 years 3 months ago #7792

  • Randall G Garcia C
  • Randall G Garcia C's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
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

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

Last edit: by Randall G Garcia C.

Auto size columns Fspreadsheet 9 years 3 months ago #7793

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
Thanks Sir
we will test and report
PilotLogic Architect and Core Programmer

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

Auto size columns Fspreadsheet 9 years 3 months ago #7796

  • Randall G Garcia C
  • Randall G Garcia C's Avatar Topic Author
  • Offline
  • New Member
  • New Member
  • Posts: 2
  • Thank you received: 0
Thanks, do a great job, and I have applications in production and are excellent, thanks guys

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

Last edit: by Randall G Garcia C.

Auto size columns Fspreadsheet 9 years 3 months ago #7797

  • Sternas Stefanos
  • Sternas Stefanos's Avatar
  • Offline
  • Moderator
  • Moderator
  • Ex Pilot, M.Sc, Ph.D
  • Posts: 4535
  • Thank you received: 1114
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.

  • Page:
  • 1