[]
        
(Showing Draft Content)

ITableRows

Interface ITableRows

All Superinterfaces:
Iterable<ITableRow>

public interface ITableRows extends Iterable<ITableRow>
Represents the collection of all ITableRow objects in a specified ITable.

Each ITableRow in this collection represents a data row in the table. Use this interface to access, count, add, and delete table rows.


 worksheet.getRange("A1:B3").setValue(new Object[][] {
     {"Name", "Value"},
     {"A", 100},
     {"B", 200}
 });
 ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
 ITableRows rows = table.getRows();
 int count = rows.getCount();
 
  • Method Summary

    Modifier and Type
    Method
    Description
    add()
    Adds a new row to the table and returns the created ITableRow.
    add(int position)
    Adds a new row to the table at the specified relative position.
    void
    add(int position, int count)
    Adds one or more rows to the table at the specified relative position.
    void
    delete(int position, int count)
    Deletes one or more rows from the table.
    get(int index)
    Gets the ITableRow at the specified index.
    int
    Gets the number of ITableRow objects in the collection.

    Methods inherited from interface java.lang.Iterable

    forEach, iterator, spliterator
  • Method Details

    • get

      ITableRow get(int index)
      Gets the ITableRow at the specified index.
      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Score"},
           {"Alice", 90},
           {"Bob", 85}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ITableRow row = table.getRows().get(0);
       
      Parameters:
      index - The zero-based index of the row to retrieve.
      Returns:
      The ITableRow object at the specified index.
    • getCount

      int getCount()
      Gets the number of ITableRow objects in the collection.

      Use this method to determine how many data rows are currently defined in a table.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       int count = table.getRows().getCount();
       
      Returns:
      The number of ITableRow objects in the collection; see ITableRow.
    • add

      ITableRow add()
      Adds a new row to the table and returns the created ITableRow.
      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ITableRow row = table.getRows().add();
       
      Returns:
      The newly added ITableRow object.
    • add

      ITableRow add(int position)
      Adds a new row to the table at the specified relative position.

      The position value is zero-based and specifies the relative position of the new row within the table rows collection. If position is less than 0 or greater than or equal to the current row count, the new row is added to the end of the table.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ITableRow row = table.getRows().add(1);
       
      Parameters:
      position - A zero-based integer that specifies the relative position of the new row.
      Returns:
      The newly added ITableRow object.
    • add

      void add(int position, int count)
      Adds one or more rows to the table at the specified relative position.

      The new rows are inserted at the specified zero-based relative position in the table data rows. If position is less than 0 or greater than or equal to the current row count, the new rows are added to the end of the table.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       table.getRows().add(1, 2);
       
      Parameters:
      position - A zero-based relative position that specifies where the new row(s) are added.
      count - The number of rows to add.
    • delete

      void delete(int position, int count)
      Deletes one or more rows from the table.

      The position value is zero-based and specifies the relative position within the table data rows. Remaining cells below the deleted rows are shifted up. If count exceeds the number of rows available from the specified position, only the remaining rows are deleted.

      
       worksheet.getRange("A1:B4").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200},
           {"C", 300}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B4"), true);
       table.getRows().delete(1, 2);
       
      Parameters:
      position - A zero-based relative position that specifies where the row deletion starts.
      count - The number of rows to delete.