Share via


ExcelScript.FilterDatetime interface

Representa cómo se filtra una fecha cuando se filtran valores.

Comentarios

Ejemplos

/**
 * This script applies a filter to a PivotTable that filters it
 * to only show rows from between June 20th, 2022 and July 10th, 2022.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the "Date Recorded" field to filter. 
  // The data in this field must be dates in order for the filter to work.
  const pivot = workbook.getPivotTables()[0];
  const rowHierarchy = pivot.getRowHierarchy("Date Recorded");
  const rowField = rowHierarchy.getFields()[0];

  // Create the filter's date boundaries.
  let earliestDate: ExcelScript.FilterDatetime = {
    date: "2022-06-20",
    specificity: ExcelScript.FilterDatetimeSpecificity.day
  };
  let latestDate: ExcelScript.FilterDatetime = {
    date: "2022-07-10",
    specificity: ExcelScript.FilterDatetimeSpecificity.day
  };

  // Apply the date filter.
  rowField.applyFilter({
    dateFilter: {
      condition: ExcelScript.DateFilterCondition.between,
      lowerBound: earliestDate,
      upperBound: latestDate
    }
  });
}

Propiedades

date

La fecha en formato ISO8601 usada para filtrar los datos.

specificity

El grado de especificidad de la fecha que se usará para mantener datos. Por ejemplo, si la fecha es 2005-04-02 y la especificidad se establece en "mes", la operación de filtro mantendrá todas las filas con una fecha en el mes de abril de 2005.

Detalles de las propiedades

date

La fecha en formato ISO8601 usada para filtrar los datos.

date: string;

Valor de propiedad

string

specificity

El grado de especificidad de la fecha que se usará para mantener datos. Por ejemplo, si la fecha es 2005-04-02 y la especificidad se establece en "mes", la operación de filtro mantendrá todas las filas con una fecha en el mes de abril de 2005.

specificity: FilterDatetimeSpecificity;

Valor de propiedad