INICIO RÁPIDO
Crea una hoja en pocas líneas
Escribe valores y fórmulas, desborda una matriz dinámica, inmoviliza la fila de encabezado, añade un gráfico y guarda el libro como XLSX.
sgcVCLSpreadsheet1 es un TsgcVCLSpreadsheet en el formulario. Los tipos de gráfico y las enumeraciones se declaran en sgcSpreadsheet_Charts.
uses
sgcSpreadsheet_Charts, sgcSpreadsheet_VCL;
procedure TForm1.BuildBudget;
var
oChart: TsgcSpreadsheetChart;
begin
// row and column are 0-based: (0, 0) is A1
sgcVCLSpreadsheet1.SetCellInput(0, 0, 'Month');
sgcVCLSpreadsheet1.SetCellInput(0, 1, 'Revenue');
sgcVCLSpreadsheet1.SetCellInput(1, 0, 'Jan');
sgcVCLSpreadsheet1.SetCellInput(1, 1, '42000');
sgcVCLSpreadsheet1.SetCellInput(2, 0, 'Feb');
sgcVCLSpreadsheet1.SetCellInput(2, 1, '45500');
sgcVCLSpreadsheet1.SetCellInput(3, 0, 'Total');
sgcVCLSpreadsheet1.SetCellInput(3, 1, '=SUM(B2:B3)');
// a dynamic array: the sorted revenues spill into D1:D2
sgcVCLSpreadsheet1.SetCellInput(0, 3, '=SORT(B2:B3,1,-1)');
// keep the header row visible while the sheet scrolls
sgcVCLSpreadsheet1.FreezePanes(1, 0);
// a column chart of the range, drawn by sgcCharts
oChart := sgcVCLSpreadsheet1.AddChart(sctColumn, 'A1:B3');
oChart.Title := 'Revenue';
oChart.Legend := sclRight;
sgcVCLSpreadsheet1.SaveToXLSX('budget.xlsx');
end;
Los controles de .NET usan los mismos nombres. sheet es un TsgcWinFormsSpreadsheet; los controles de WPF y Avalonia funcionan igual.
using esegece.sgcSpreadsheet;
// row and column are 0-based: (0, 0) is A1
sheet.SetCellInput(0, 0, "Month");
sheet.SetCellInput(0, 1, "Revenue");
sheet.SetCellInput(1, 0, "Jan");
sheet.SetCellInput(1, 1, "42000");
sheet.SetCellInput(2, 0, "Feb");
sheet.SetCellInput(2, 1, "45500");
sheet.SetCellInput(3, 0, "Total");
sheet.SetCellInput(3, 1, "=SUM(B2:B3)");
// a dynamic array: the sorted revenues spill into D1:D2
sheet.SetCellInput(0, 3, "=SORT(B2:B3,1,-1)");
// keep the header row visible while the sheet scrolls
sheet.FreezePanes(1, 0);
// a column chart of the range, drawn by sgcCharts
TsgcSpreadsheetChart chart = sheet.AddChart(TsgcSpreadsheetChartType.sctColumn, "A1:B3");
chart.Title = "Revenue";
chart.Legend = TsgcSpreadsheetChartLegend.sclRight;
sheet.SaveToXLSX("budget.xlsx");