PivotTable
TsgcHTMLComponent_PivotTable — renderiza una tabla dinámica de Bootstrap que agrupa filas y columnas y agrega medidas con totales de fila, columna y gran total, en Delphi, C++ Builder y .NET.
TsgcHTMLComponent_PivotTable — renderiza una tabla dinámica de Bootstrap que agrupa filas y columnas y agrega medidas con totales de fila, columna y gran total, en Delphi, C++ Builder y .NET.
Declara los campos de agrupación y las medidas, aliméntalo con filas en bruto (o vincula un dataset), y luego lee la propiedad HTML.
TsgcHTMLComponent_PivotTable
Tabla agregada de Bootstrap 5 + totales
Delphi, C++ Builder, .NET
Añade RowFields / ColumnFields para agrupar, añade una entrada en Measures por cada valor agregado, indica las columnas de origen en DataFields, inserta filas con AddRow, y luego lee HTML.
uses
sgcHTML_Component_PivotTable;
var
oPivot: TsgcHTMLComponent_PivotTable;
oMeasure: TsgcHTMLPivotMeasure;
begin
oPivot := TsgcHTMLComponent_PivotTable.Create(nil);
try
oPivot.Caption := 'Revenue by Region and Quarter';
oPivot.RowFields.Add.FieldName := 'Region';
oPivot.ColumnFields.Add.FieldName := 'Quarter';
oMeasure := oPivot.Measures.Add;
oMeasure.SourceField := 'Amount';
oMeasure.Caption := 'Revenue';
oMeasure.Aggregation := paSum;
oMeasure.Format := '#,##0.00';
oPivot.DataFields.Add('Region');
oPivot.DataFields.Add('Quarter');
oPivot.DataFields.Add('Amount');
oPivot.AddRow(['EMEA', 'Q1', '12000']);
oPivot.AddRow(['EMEA', 'Q2', '15500']);
oPivot.AddRow(['APAC', 'Q1', '9800']);
WebModule.Response := oPivot.HTML; // aggregated table + row/column/grand totals
finally
oPivot.Free;
end;
end;
// Or bind it straight to a dataset (reads only RowFields/ColumnFields/Measures fields):
oPivot.LoadFromDataSet(qrySales);
// includes: sgcHTML_Component_PivotTable.hpp
TsgcHTMLComponent_PivotTable *oPivot = new TsgcHTMLComponent_PivotTable(NULL);
try
{
oPivot->Caption = "Revenue by Region and Quarter";
oPivot->RowFields->Add()->FieldName = "Region";
oPivot->ColumnFields->Add()->FieldName = "Quarter";
TsgcHTMLPivotMeasure *oMeasure = oPivot->Measures->Add();
oMeasure->SourceField = "Amount";
oMeasure->Caption = "Revenue";
oMeasure->Aggregation = paSum;
oMeasure->Format = "#,##0.00";
oPivot->DataFields->Add("Region");
oPivot->DataFields->Add("Quarter");
oPivot->DataFields->Add("Amount");
oPivot->AddRow(OPENARRAY(UnicodeString, ("EMEA", "Q1", "12000")));
oPivot->AddRow(OPENARRAY(UnicodeString, ("APAC", "Q1", "9800")));
String html = oPivot->HTML; // aggregated table + row/column/grand totals
}
__finally
{
delete oPivot;
}
using esegece.sgcWebSockets;
var pivot = new TsgcHTMLComponent_PivotTable();
pivot.Caption = "Revenue by Region and Quarter";
pivot.RowFields.Add().FieldName = "Region";
pivot.ColumnFields.Add().FieldName = "Quarter";
var measure = pivot.Measures.Add();
measure.SourceField = "Amount";
measure.Caption = "Revenue";
measure.Aggregation = TsgcHTMLPivotAggregation.paSum;
measure.Format = "#,##0.00";
pivot.DataFields.Add("Region");
pivot.DataFields.Add("Quarter");
pivot.DataFields.Add("Amount");
pivot.AddRow(new[] { "EMEA", "Q1", "12000" });
pivot.AddRow(new[] { "APAC", "Q1", "9800" });
string html = pivot.HTML; // aggregated table + row/column/grand totals
Los miembros que usarás con más frecuencia.
Cada entrada tiene un FieldName y un Caption; RowFields agrupa las filas hacia abajo por la izquierda, ColumnFields agrupa las columnas a lo largo de la parte superior.
Measures.Add devuelve un TsgcHTMLPivotMeasure con SourceField, Caption, una Aggregation (SUM/COUNT/AVERAGE/MIN/MAX) y un Format opcional.
DataFields lista las columnas de origen en bruto de forma posicional; AddRow(aValues) añade una fila que respeta ese orden.
LoadFromDataSet(aDataSet) lee únicamente los campos referenciados por RowFields, ColumnFields y Measures directamente desde un TDataSet.
ShowRowTotals, ShowColumnTotals y ShowGrandTotal activan cada uno una fila/columna de resumen; TotalText los etiqueta.
Striped, Bordered, Hover y Compact dan estilo a la tabla Bootstrap; EmptyCellText rellena los huecos vacíos; HTML devuelve la tabla terminada.
| Ayuda en líneaReferencia completa de la API y guía de uso para este componente. | Abrir | |
| Todos los componentes de sgcHTMLExplora la matriz completa de más de 80 componentes. | Abrir | |
| Descargar prueba gratuitaLa prueba de 30 días incluye los proyectos de demostración 60.HTML. | Abrir | |
| PreciosLicencias Single, Team y Site con código fuente completo. | Abrir |