Recent

Author Topic: how can i change title of column from "A,B.C,.." to "1,2,3..." of FPSpreadsheet?  (Read 3989 times)

wylton

  • Jr. Member
  • **
  • Posts: 50
sometime i need "1,2,3.." for work..

Handoko

  • Hero Member
  • *****
  • Posts: 5130
  • My goal: build my own game engine using Lazarus
As far as I know we cannot change the title of column in Excel nor LibreOffice Calc so the same is in FPSpreadsheet. Maybe you can use TStringGrid.

wp

  • Hero Member
  • *****
  • Posts: 11854
In r6302 of fpspreadsheet you can write handlers for the WorksheetGrid events OnGetRowHeaderText and OnGetColHeaderText to override the row and column headers. Example:

Code: Pascal  [Select][+][-]
  1. procedure TForm1.sWorksheetGrid1GetColHeaderText(Sender: TObject;
  2.   AIndex: Integer; var AText: String);
  3. begin
  4.   AText := 'Col ' + IntToStr(AIndex);
  5. end;
  6.  
  7. procedure TForm1.sWorksheetGrid1GetRowHeaderText(Sender: TObject;
  8.   AIndex: Integer; var AText: String);
  9. begin
  10.   AText := 'Row ' + IntToStr(AIndex);
  11. end;

Finally one thing which fpspreadsheet can do, but Excel and Calc cannot!

fmolina

  • New Member
  • *
  • Posts: 40
Hi,

I cannot find these events in the last released version. Are they in trunk? Do they work reliably?

Regards

wp

  • Hero Member
  • *****
  • Posts: 11854
They are in trunk, not yet released.

Reliably? Whatever can go wrong will go wrong. So, if you want an exact answer: "no". But to the best of my knowledge: "yes".

fmolina

  • New Member
  • *
  • Posts: 40
OK, OK, I am aware or Murphy's law. "The best of my knowledge" is what I expected.
« Last Edit: May 28, 2018, 04:26:52 am by fmolina »

wp

  • Hero Member
  • *****
  • Posts: 11854
"Best of my knowledge" was not enough... Recent versions of Laz trunk did not display the column headers any more due to a change in the LCL grids which required an adaption of the TsWorksheetGrid. Should work again now.

 

TinyPortal © 2005-2018