FlexCel Studio for VCL/LCL
ContentsIndex
PreviousUpNext
TFlexCelImport.ColByIndex Property

Column position given an index on the array of used columns.

Pascal
property ColByIndex [Row, ColIndex: integer]: integer;
C++
__property int ColByIndex[int Row, ColIndex];

FlexCel allows you two way to access the cells in a sheet. You can do it by specifying row and column (with The Cell property) or by specifying the row and the cell position in the list of used cells for that row. Using the cell position is faster when you want to read all used cells in a sheet. (and only the used cells) 

 

This property returns the column position for an index on the array of columns. Use this together with ColIndex and ColIndexCount to loop all used cells of a Row.

Let's imagine that you have 3 used cells on row 2: B2, D2 and IV2 

You can use this loop to copy all the values and formats from Row 2 to row 3: 

 

for i:=0 to FImport.ColIndexCount[2]-1 do
  FImport.Cell[3, ColByIndex[2, i]] := FImport.Cell[2, ColByIndex[2, i]];

 

This will work much faster than using 

 

for i:=1 to FImport.MaxCol do //MaxCol is 255!
  FImport.Cell[3, i] := FImport.Cell[2, i];
Copyright (c) 2002-2008 TMS Software. All rights reserved.
What do you think about this topic? Send feedback!