DÉMARRAGE RAPIDE
Construis une feuille en quelques lignes
Écris des valeurs et des formules, fais déborder un tableau dynamique, fige la ligne d'en-tête, ajoute un graphique et enregistre le classeur en XLSX.
sgcVCLSpreadsheet1 est un TsgcVCLSpreadsheet sur la fiche. Les types de graphiques et les énumérations sont déclarés dans 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;
Les contrôles .NET utilisent les mêmes noms. sheet est un TsgcWinFormsSpreadsheet; les contrôles WPF et Avalonia fonctionnent de la même façon.
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");