Search Results for

    Show / Hide Table of Contents

    TExcelFile.ColCountInRow Method

    Overloads

    • TExcelFile.ColCountInRow(Integer)
    • TExcelFile.ColCountInRow(Integer, Integer)

    TExcelFile.ColCountInRow(Integer)

    This method returns the existing columns on ONE ROW. You can use this together with ColFromIndex(Integer, Integer) and ColToIndex(Integer, Integer) to iterate faster on a block.

    Syntax

    Unit: FlexCel.Core

    function TExcelFile.ColCountInRow(const row: Integer): Integer; overload; virtual; abstract;

    Parameters

    <-> Parameter Type Description
    const row Integer Row index. (1-based)

    Returns

    The number of existing columns on one row.

    Examples

    Instead of writing:

    var
      RowCount: Int32;
      ColCount: Int32;
      row: Int32;
      col: Int32;
    ...
      RowCount := xls.RowCount;
      ColCount := xls.ColCount;
      for row := 1 to RowCount do
      begin
        for col := 1 to ColCount do  //It would be faster to use ColCountInRow. See https://doc.tmssoftware.com/flexcel/vcl/guides/performance-guide.html#avoid-calling-colcount
        begin
          DoSomething(row, col);
        end;
      end;
    

    You can use:

    var
      RowCount: Int32;
      row: Int32;
      ColCountInRow: Int32;
      colIndex: Int32;
    ...
      RowCount := xls.RowCount;
      for row := 1 to RowCount do
      begin
        ColCountInRow := xls.ColCountInRow(row);
        for colIndex := 1 to ColCountInRow do
        begin
          DoSomething(row, xls.ColFromIndex(row, colIndex));
        end;
    
      end;
    

    See also

    • TExcelFile

    TExcelFile.ColCountInRow(Integer, Integer)

    This method returns the existing columns on ONE ROW, for a given sheet. You can use this together with ColFromIndex(Integer, Integer) and ColToIndex(Integer, Integer) to iterate faster on a block.

    Syntax

    Unit: FlexCel.Core

    function TExcelFile.ColCountInRow(const sheet: Integer; const row: Integer): Integer; overload; virtual; abstract;

    Parameters

    <-> Parameter Type Description
    const sheet Integer Sheet where we are working. It might be different from ActiveSheet.
    const row Integer Row index. (1-based)

    Returns

    The number of existing columns on one row.

    Examples

    Instead of writing:

    var
      RowCount: Int32;
      ColCount: Int32;
      row: Int32;
      col: Int32;
    ...
      RowCount := xls.RowCount;
      ColCount := xls.ColCount;
      for row := 1 to RowCount do
      begin
        for col := 1 to ColCount do  //It would be faster to use ColCountInRow. See https://doc.tmssoftware.com/flexcel/vcl/guides/performance-guide.html#avoid-calling-colcount
        begin
          DoSomething(row, col);
        end;
      end;
    

    You can use:

    var
      RowCount: Int32;
      row: Int32;
      ColCountInRow: Int32;
      colIndex: Int32;
    ...
      RowCount := xls.RowCount;
      for row := 1 to RowCount do
      begin
        ColCountInRow := xls.ColCountInRow(row);
        for colIndex := 1 to ColCountInRow do
        begin
          DoSomething(row, xls.ColFromIndex(row, colIndex));
        end;
    
      end;
    

    See also

    • TExcelFile
    In This Article
    Back to top FlexCel Studio for VCL and FireMonkey v7.8.0
    © 2002 - 2020 tmssoftware.com