program project1;
uses
FPSpreadsheet, FPSTypes, xlsxOOXML;
var
wb: TsWorkbook;
wsh: TsWorksheet;
r: Cardinal;
begin
wb := TsWorkBook.Create;
try
wsh := wb.AddWorksheet('Page 1');
// *** PREPARATION OF WORKSHEET ***
// A1
wsh.WriteNumber(0, 0, 1.234);
// B1
wsh.WriteNumber(0, 1, 1.48);
wsh.WriteFontStyle(0, 1, [fssItalic]);
// B2
wsh.WriteNumber(1, 1, 2.124);
wsh.WriteFontStyle(1, 1, [fssItalic]);
// B3
wsh.WriteNumber(2, 1, 3.8934);
wsh.WriteFontStyle(2, 1, [fssItalic]);
// B4
wsh.WriteFormula(3, 1, '=Sum(B1:B3)+$A$1');
wsh.WriteFontStyle(3, 1, [fssBold]);
wsh.WriteBackgroundColor(3, 1, scYellow);
// *** COPY COLUMN WITH FORMATS ***
// Step 1: Insert column before col1 --> col1 is col2 now!
wsh.InsertCol(1);
// Step 2: Copy formats, cell-by-cell, from source to destination columns
for r := wsh.GetFirstRowIndex to wsh.GetLastRowIndex do
wsh.CopyFormat(wsh.FindCell(r, 2), r, 1);
// Save to file for checking
wb.WriteToFile('test.xlsx', true);
finally
wb.Free;
end;
end.