Basic usage and formatting
procedure TForm1.b1Click(Sender: TObject);
Var xls:TdxSpreadSheet;
sh: TdxSpreadSheetTableView;
begin
xls:=TdxSpreadSheet.Create(Self);
Try
xls.BeginUpdate;
xls.ClearAll;
sh:=TdxSpreadSheetTableView(xls.AddSheet('Bénéficiaires'));
// row,col
if Cells[1,1]=Nil then
CreateCell(1,1);
Cells[Row,Col].AsString:='test';
sh.cells[1,1].Style.Borders[bLeft].Style:=sscbsDouble;
sh.cells[1,1].Style.Borders[bRight].Color:=clred;
sh.Cells[1,1].Style.Brush.BackgroundColor:=clcxLightGray;
sh.Cells[1,1].Style.AlignHorz:=ssahCenter;
sh.Cells[1,1].Style.DataFormat.FormatCode:='dd/mm/yyyy';
sh.Cells[1,1].Style.DataFormat.FormatCode:='# ##0.00';
sh.Cells[1,1].Style.Font.Style:=[fsBold];
// Formula
CreateCell(2,1); // B3
sh.Cells[2,1].SetText('=SUM(B2:B2)',true);
xls.EndUpdate;
xls.SaveToFile('C:\Users\gosane\Desktop\text.xlsx');
Finally
xls.Free;
End;
end;
Helpers
function xlscolname(i:integer):string;
var a,b:integer;
begin
if i<0 then
result:='?'
else if i<26 then
result:=chr(65+i)
else begin
a:=i div 26;
b:=i mod 26;
result:=chr(64+a)+chr(65+b);
end;
end;