ExcelScript.TableColumn interface

Representa una columna en una tabla.

Comentarios

Ejemplos

/**
 * This script shows how to get the range of a table column.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first table in the workbook.
  const table = workbook.getTables()[0];

  // Get the range of the table column named "Type".
  const typeColumn : ExcelScript.TableColumn = table.getColumn("Type");
  const range = typeColumn.getRange();

  // Do something with the range...
}

Métodos

delete()

Elimina la columna de la tabla.

getFilter()

Recupera el filtro aplicado a la columna.

getHeaderRowRange()

Obtiene el objeto de rango asociado a la fila de encabezado de la columna.

getId()

Devuelve una clave única que identifica la columna de la tabla.

getIndex()

Devuelve el número de índice de la columna dentro de la colección de columnas de la tabla. Indizado con cero.

getName()

Especifica el nombre de la columna de tabla.

getRange()

Obtiene el objeto de rango asociado a toda la columna.

getRangeBetweenHeaderAndTotal()

Obtiene el objeto de rango asociado al cuerpo de datos de la columna.

getTotalRowRange()

Obtiene el objeto de rango asociado a la fila de totales de la columna.

setName(name)

Especifica el nombre de la columna de tabla.

Detalles del método

delete()

Elimina la columna de la tabla.

delete(): void;

Devoluciones

void

Ejemplos

/**
 * This script removes a specific column from a table.
 */
function main(workbook: ExcelScript.Workbook) {
    // Get the table named "Inventory".
    const table = workbook.getTable("Inventory");

    // If it exists, remove the column named "Category".
    let categoryColumn = table.getColumnByName("Category");
    if (categoryColumn) {
        categoryColumn.delete();
    }
}

getFilter()

Recupera el filtro aplicado a la columna.

getFilter(): Filter;

Devoluciones

Ejemplos

/**
 * This script adds a table filter to only show the top 10% of values 
 * belonging to a particular column.
 */
function main(workbook: ExcelScript.Workbook) {
    // Get the first table on the current worksheet.
    const table = workbook.getActiveWorksheet().getTables()[0];

    // Get the filter for the "PageViews" table column.
    const pageViewFilter = table.getColumnByName("PageViews").getFilter();

    // Apply a filter to only show the rows with the top 10% of values in this column.
    pageViewFilter.applyTopPercentFilter(10);
}

getHeaderRowRange()

Obtiene el objeto de rango asociado a la fila de encabezado de la columna.

getHeaderRowRange(): Range;

Devoluciones

getId()

Devuelve una clave única que identifica la columna de la tabla.

getId(): number;

Devoluciones

number

getIndex()

Devuelve el número de índice de la columna dentro de la colección de columnas de la tabla. Indizado con cero.

getIndex(): number;

Devoluciones

number

getName()

Especifica el nombre de la columna de tabla.

getName(): string;

Devoluciones

string

getRange()

Obtiene el objeto de rango asociado a toda la columna.

getRange(): Range;

Devoluciones

getRangeBetweenHeaderAndTotal()

Obtiene el objeto de rango asociado al cuerpo de datos de la columna.

getRangeBetweenHeaderAndTotal(): Range;

Devoluciones

Ejemplos

/**
 * This script adds a new column to a table.
 * It then sets the formulas in the new column to be the product
 * of the values in the two preceding columns.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the first table in the workbook.
  const table = workbook.getTables()[0];

  // Append an empty column to the table with the header "Total". 
  const totalColumn = table.addColumn(-1, null, "Total");

  // Get the names of the two preceding columns.
  const productColumnName1 = table.getColumns()[totalColumn.getIndex() - 1].getName();
  const productColumnName2 = table.getColumns()[totalColumn.getIndex() - 2].getName();
  
  // Set the formulas in the "Total" column to be the product of the two preceding columns.
  totalColumn.getRangeBetweenHeaderAndTotal().setFormula(
    `=[@[${productColumnName1}]]*[@[${productColumnName2}]]`
  );
}

getTotalRowRange()

Obtiene el objeto de rango asociado a la fila de totales de la columna.

getTotalRowRange(): Range;

Devoluciones

setName(name)

Especifica el nombre de la columna de tabla.

setName(name: string): void;

Parámetros

name

string

Devoluciones

void