Recent

Author Topic: Cell location in spreadsheet  (Read 278 times)

backprop

  • Jr. Member
  • **
  • Posts: 99
Cell location in spreadsheet
« on: September 08, 2024, 10:33:40 pm »
How to find location of the cell by given row and col?

For instance DF2 is (107,1), if I do not mistaking.

I have very large and dynamically created table which should at end have SUM formula. In formula need to be entered range of cells in spreadsheet, not fixed location known by application.

wp

  • Hero Member
  • *****
  • Posts: 12416
Re: Cell location in spreadsheet
« Reply #1 on: September 08, 2024, 11:38:20 pm »
Take a look at unit fpsutils. It contains a lot of Parse* functions, e.g.
Code: Pascal  [Select][+][-]
  1.  function ParseCellString(const AStr: string; out ACellRow, ACellCol: Cardinal): Boolean;
for conversion between string addresses (e.g. "A1") to row/col indices (row=0, col=0). Or the opposite direction, e.g.:
Code: Pascal  [Select][+][-]
  1. function GetCellString(ARow,ACol: Cardinal; AFlags: TsRelFlags = [rfRelRow, rfRelCol]): String;
The AFlags indicate whether the cell address is relative or absolute (i.e. includes a '$').

There are also conversion functions for the OpenDocument and the R1C1 syntax.

 

TinyPortal © 2005-2018