-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathXlsxFrm.pas
70 lines (54 loc) · 1.88 KB
/
XlsxFrm.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
unit XlsxFrm;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, XlsxLib;
type
TXlsxDlg = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
XlsxDlg: TXlsxDlg;
implementation
uses
CellFormat;
{$R *.dfm}
procedure TXlsxDlg.Button1Click(Sender: TObject);
var
xlsxFile: TXlsxFile;
begin
xlsxFile := TXlsxFile.Create;
xlsxFile.Workbook.Sheets[0].Cell[1, 1].Value := 'Hello';
xlsxFile.Workbook.Sheets[0].Cell[2, 1].Value := 'Text 1';
xlsxFile.Workbook.Sheets[0].Cell[2, 1].Format.Font.Size := 16;
xlsxFile.Workbook.Sheets[0].Cell[2, 1].Format.Font.Style := [xfsBold];
xlsxFile.Workbook.Sheets[0].Cell[1, 2].Value := 'Text 2';
xlsxFile.Workbook.Sheets[0].Cell[2, 2].Value := 'Text 3';
xlsxFile.Workbook.Sheets[0].Cell[2, 2].Format.Font.Size := 16;
xlsxFile.Workbook.Sheets[0].Cell[2, 2].Format.Font.Style := [xfsBold, xfsItalic, xfsUnderline];
xlsxFile.Workbook.Sheets[0].Cell[2, 2].Format.BottomBorder := xbsThick;
xlsxFile.Workbook.Sheets[0].Cell[2, 2].Format.DiagonalBorder := xbsDotted;
xlsxFile.Workbook.Sheets[0].Cell[1, 3].Value := 'TEXT';
xlsxFile.Workbook.Sheets[0].Cell[1, 3].Format.Fill.PatternType := xptSolid;
xlsxFile.Workbook.Sheets[0].Cell[1, 3].Format.Fill.Color := clBlue;
// xlsxFile.Workbook.Sheets[0].Cell[2, 1].Value := 2;
// xlsxFile.Workbook.Sheets[0].Cell[3, 1].Formula := 'A1+B1';
xlsxFile.SaveToFile('C:\temp\mappe\test.xlsx');
xlsxFile.Free;
end;
procedure TXlsxDlg.Button2Click(Sender: TObject);
var
xlsxFile: TXlsxFile;
begin
xlsxFile := TXlsxFile.Create;
xlsxFile.LoadFromFile('C:\temp\mappe\test.xlsx');
xlsxFile.Free;
end;
end.