forked from ggreen86/XLSX-Workbook-Class
-
Notifications
You must be signed in to change notification settings - Fork 1
/
testform.PRG
180 lines (164 loc) · 4.07 KB
/
testform.PRG
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
Public oform1
Set Procedure To vfpxworkbookxlsx Additive
oform1 = Newobject("form1")
oform1.Show()
Return
Define Class form1 As Form
DataSession = 2
Height = 250
Width = 761
DoCreate = .T.
AutoCenter = .T.
Caption = "Test"
MaxButton = .F.
MinButton = .F.
Name = "Form1"
Add Object clsvfpxworkbookxlsx As vfpxworkbookxlsx With ;
Height = 17, ;
Left = 617, ;
Top = 9, ;
Width = 129, ;
Name = "clsVFPxWorkbookXLSX"
Add Object command1 As CommandButton With ;
Top = 6, ;
Left = 7, ;
Height = 30, ;
Width = 183, ;
Caption = "Export Northwind Customers", ;
Name = "Command1"
Add Object command2 As CommandButton With ;
Top = 37, ;
Left = 7, ;
Height = 30, ;
Width = 183, ;
Caption = "Class Demo", ;
Name = "Command2"
Add Object grid1 As Grid With ;
DeleteMark = .F., ;
Height = 168, ;
Left = 7, ;
ReadOnly = .T., ;
Top = 75, ;
Width = 749, ;
Name = "Grid1"
Add Object command3 As CommandButton With ;
Top = 6, ;
Left = 193, ;
Height = 30, ;
Width = 183, ;
Caption = "Export Grid to Excel", ;
Name = "Command3"
Procedure Load
Set Safety Off
Procedure Resize
With This
.grid1.Width = .Width - 14
.grid1.Height = .Height - .grid1.Top - 7
Endwith
Procedure command1.Click
Local lcTable, lcExcel
lcExcel = Sys(5) + Addbs(Sys(2003)) + "Northwind Customers.xlsx"
lcTable = Addbs(Sys(2004)) + "Samples\Northwind\customers.dbf"
lcTable = Locfile(lcTable)
If !Isnull(lcTable) .And. File(lcTable)
Thisform.clsvfpxworkbookxlsx.SaveTabletoWorkbook(lcTable, lcExcel, .T., .T.)
Wait Window "Saved To Excel" Nowait
Endif
Procedure command2.Click
Thisform.clsvfpxworkbookxlsx.Demo()
Wait Window "Saved To Excel" Nowait
Procedure grid1.Init
Local lcTable, llFailed
lcTable = Addbs(Sys(2004)) + "Samples\Northwind\employees.dbf"
lcTable = Locfile(lcTable)
Try
Use (lcTable) In 0 Alias employees Shared
llFailed = .F.
Catch To loException
llFailed = .T.
Endtry
If llFailed
Return
Endif
With This
.ColumnCount = 7
.RecordSource = 'employees'
With .Column1
.Resizable = .T.
.Alignment = 0
.ControlSource = "employees.employeeid"
With .Header1
.Caption = "Employee Id"
.FontBold = .T.
.Alignment = 0
Endwith
Endwith
With .Column2
.Resizable = .T.
.Alignment = 0
.ControlSource = "ALLTRIM(employees.lastname) + ', ' + ALLTRIM(employees.firstname)"
With .Header1
.Caption = "Employee Name"
.FontBold = .T.
.Alignment = 0
Endwith
Endwith
With .Column3
.Resizable = .T.
.Alignment = 2
.ControlSource = "employees.hiredate"
With .Header1
.Caption = "Hire Date"
.FontBold = .T.
.Alignment = 0
Endwith
Endwith
With .Column4
.Resizable = .T.
.Alignment = 0
.ControlSource = "employees.address"
With .Header1
.Caption = "Address"
.FontBold = .T.
.Alignment = 0
Endwith
Endwith
With .Column5
.Resizable = .T.
.Alignment = 0
.ControlSource = "employees.city"
With .Header1
.Caption = "City"
.FontBold = .T.
.Alignment = 0
Endwith
.Text1.Alignment = 1
Endwith
With .Column6
.Resizable = .T.
.Alignment = 0
.ControlSource = "employees.region"
With .Header1
.Caption = "State"
.FontBold = .T.
.Alignment = 0
Endwith
.Text1.Alignment = 1
Endwith
With .Column7
.Resizable = .T.
.Alignment = 0
.ControlSource = "employees.postalcode"
With .Header1
.Caption = "Postal Code"
.FontBold = .T.
.Alignment = 0
Endwith
Endwith
Endwith
Procedure command3.Click
Local lcExcel
lcExcel = Sys(5) + Addbs(Sys(2003)) + "Northwind Employees.xlsx"
Thisform.clsvfpxworkbookxlsx.SaveGridToWorkbookEX(Thisform.grid1, lcExcel, .T., "Employees")
Wait Window "Saved To Excel" Nowait
Enddefine