[]
        
(Showing Draft Content)

ITableColumn

Interface ITableColumn


public interface ITableColumn
Represents a column in a table.

An ITableColumn object is a member of the ITableColumns collection, which contains all columns in an ITable.


 worksheet.getRange("A1:B3").setValue(new Object[][] {
     {"Name", "Value"},
     {"A", 100},
     {"B", 200}
 });
 ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
 ITableColumn tableColumn = table.getColumns().get(0);
 String name = tableColumn.getName();
 
  • Method Details

    • getIndex

      int getIndex()
      Gets the zero-based index of this table column within the ITableColumns collection.

      The index reflects the current position of the column in its parent ITable.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Name", "Value"},
           {"A", 100},
           {"B", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       int index = table.getColumns().get(1).getIndex();
       
      Returns:
      The zero-based index of this table column within the collection.
    • getName

      String getName()
      Gets the name of the table column.

      This name is also used as the display name of the table column and must be unique within the table.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       String name = table.getColumns().get(1).getName();
       
      Returns:
      The name of the table column.
    • setName

      void setName(String value)
      Sets the name of the table column.

      This name is also used as the display name of the table column and must be unique within the table.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       table.getColumns().get(1).setName("Sample");
       
      Parameters:
      value - The name of the table column.
    • getTotalsCalculation

      TotalsCalculation getTotalsCalculation()
      Gets the calculation type used in the Totals row of this table column.

      The returned TotalsCalculation value determines how the totals cell for the column is calculated when the table shows a totals row.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       table.setShowTotals(true);
       table.getColumns().get(1).setTotalsCalculation(TotalsCalculation.Sum);
       TotalsCalculation calculation = table.getColumns().get(1).getTotalsCalculation();
       
      Returns:
      The TotalsCalculation value used in the Totals row of this table column; see TotalsCalculation.
    • setTotalsCalculation

      void setTotalsCalculation(TotalsCalculation value)
      Sets the calculation type used in the Totals row of this table column.

      Use this method to specify how the totals cell for the column is calculated when the table displays a totals row.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       table.setShowTotals(true);
       table.getColumns().get(1).setTotalsCalculation(TotalsCalculation.Sum);
       
      Parameters:
      value - The TotalsCalculation value that specifies the totals-row calculation for the table column.
    • getTotal

      IRange getTotal()
      Returns the Total row for the ITableColumn object.
      
       worksheet.getRange("A1:B3").setValue(new Object[][] {{"Product", "Amount"}, {"Apple", 100}, {"Pear", 200}});
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       table.setShowTotals(true);
       IRange totalCell = table.getColumns().get(1).getTotal();
       
      Returns:
      The Total row for the object.
    • delete

      void delete()
      Deletes this table column from its parent table.
      
       worksheet.getRange("A1:B3").setValue(new Object[][] {{"Product", "Amount"}, {"Apple", 100}, {"Pear", 200}});
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       table.getColumns().get(1).delete();
       
    • getDataBodyRange

      IRange getDataBodyRange()
      Gets the IRange that represents the data body cells of this table column.

      The returned range includes only the data rows in the column and excludes the header cell and totals cell.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ITableColumn tableColumn = table.getColumns().get(1);
       IRange dataBodyRange = tableColumn.getDataBodyRange();
       dataBodyRange.setValue(new Object[][] {{120}, {220}});
       
      Returns:
      The IRange that represents the data body cells of this table column.
    • getRange

      IRange getRange()
      Gets the IRange that represents this table column.

      The returned range covers the cells associated with the current ITableColumn within its parent table.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ITableColumn tableColumn = table.getColumns().get(1);
       IRange range = tableColumn.getRange();
       
      Returns:
      The IRange that represents this table column.
    • getDataField

      String getDataField()
      Gets the data field name of the current table column.

      This property returns the field name associated with the current table column.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ITableColumn tableColumn = table.getColumns().get(0);
       tableColumn.setDataField("Product");
       String dataField = tableColumn.getDataField();
       
      Returns:
      The data field name of the current table column.
    • setDataField

      void setDataField(String value)
      Sets the data field name for the current table column.

      This method sets the field name associated with the current table column.

      
       worksheet.getRange("A1:B3").setValue(new Object[][] {
           {"Product", "Amount"},
           {"Apple", 100},
           {"Pear", 200}
       });
       ITable table = worksheet.getTables().add(worksheet.getRange("A1:B3"), true);
       ITableColumn tableColumn = table.getColumns().get(0);
       tableColumn.setDataField("Product");
       
      Parameters:
      value - The data field name of the current table column.