-
Notifications
You must be signed in to change notification settings - Fork 59
/
workbook.rb
346 lines (307 loc) · 10.7 KB
/
workbook.rb
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
module Libxlsxwriter
# = Fields:
# :constant_memory ::
# (Integer) Optimize the workbook to use constant memory for worksheets
# :tmpdir ::
# (String) Directory to use for the temporary files created by libxlsxwriter.
class WorkbookOptions < FFI::Struct
layout :constant_memory, :uchar,
:tmpdir, :string,
:use_zip64, :uchar
end
# = Fields:
# :file ::
# (FFI::Pointer(*FILE))
# :worksheets ::
# (Worksheets)
# :worksheet_names ::
# (WorksheetNames)
# :charts ::
# (Charts)
# :ordered_charts ::
# (Charts)
# :formats ::
# (Formats)
# :defined_names ::
# (DefinedNames)
# :sst ::
# (Sst)
# :properties ::
# (DocProperties)
# :custom_properties ::
# (CustomProperties)
# :filename ::
# (String)
# :options ::
# (WorkbookOptions)
# :num_sheets ::
# (Integer)
# :first_sheet ::
# (Integer)
# :active_sheet ::
# (Integer)
# :num_xf_formats ::
# (Integer)
# :num_format_count ::
# (Integer)
# :drawing_count ::
# (Integer)
# :font_count ::
# (Integer)
# :border_count ::
# (Integer)
# :fill_count ::
# (Integer)
# :optimize ::
# (Integer)
# :has_png ::
# (Integer)
# :has_jpeg ::
# (Integer)
# :has_bmp ::
# (Integer)
# :used_xf_formats ::
# (HashTable)
module WorkbookWrappers
# @param [String] sheetname
# @return [Worksheet]
def add_worksheet(sheetname)
Worksheet.new Libxlsxwriter.workbook_add_worksheet(self, sheetname)
end
# @return [Format]
def add_format()
Format.new Libxlsxwriter.workbook_add_format(self)
end
def default_format()
Format.new Libxlsxwriter.workbook_default_format(self)
end
# @param [Integer] chart_type
# @return [Chart]
def add_chart(chart_type)
Chart.new Libxlsxwriter.workbook_add_chart(self, chart_type)
end
# @return [Symbol from _enum_error_]
def close()
Libxlsxwriter.workbook_close(self)
end
# @param [DocProperties] properties
# @return [Symbol from _enum_error_]
def set_properties(properties)
Libxlsxwriter.workbook_set_properties(self, properties)
end
# @param [String] name
# @param [String] value
# @return [Symbol from _enum_error_]
def set_custom_property_string(name, value)
Libxlsxwriter.workbook_set_custom_property_string(self, name, value)
end
# @param [String] name
# @param [Float] value
# @return [Symbol from _enum_error_]
def set_custom_property_number(name, value)
Libxlsxwriter.workbook_set_custom_property_number(self, name, value)
end
# @param [String] name
# @param [Integer] value
# @return [Symbol from _enum_error_]
def set_custom_property_integer(name, value)
Libxlsxwriter.workbook_set_custom_property_integer(self, name, value)
end
# @param [String] name
# @param [Integer] value
# @return [Symbol from _enum_error_]
def set_custom_property_boolean(name, value)
Libxlsxwriter.workbook_set_custom_property_boolean(self, name, value)
end
# @param [String] name
# @param [Datetime] datetime
# @return [Symbol from _enum_error_]
def set_custom_property_datetime(name, datetime)
Libxlsxwriter.workbook_set_custom_property_datetime(self, name, datetime)
end
# @param [String] name
# @param [String] formula
# @return [Symbol from _enum_error_]
def define_name(name, formula)
Libxlsxwriter.workbook_define_name(self, name, formula)
end
# @param [String] name
# @return [Worksheet]
def get_worksheet_by_name(name)
Worksheet.new Libxlsxwriter.workbook_get_worksheet_by_name(self, name)
end
# @param [String] sheetname
# @return [Symbol from _enum_error_]
def validate_worksheet_name(sheetname)
Libxlsxwriter.workbook_validate_worksheet_name(self, sheetname)
end
# @return [nil]
def free()
Libxlsxwriter.workbook_free(self)
end
# @return [nil]
def assemble_xml_file()
Libxlsxwriter.workbook_assemble_xml_file(self)
end
# @return [nil]
def set_default_xf_indices()
Libxlsxwriter.workbook_set_default_xf_indices(self)
end
end
class Workbook < FFI::Struct
include WorkbookWrappers
layout :file, :pointer,
:sheets, Sheets.ptr,
:worksheets, Worksheets.ptr,
:chartsheets, :pointer,
:worksheet_names, WorksheetNames.ptr,
:chartsheet_names, :pointer,
:charts, Charts.ptr,
:ordered_charts, Charts.ptr,
:formats, Formats.ptr,
:defined_names, DefinedNames.ptr,
:sst, Sst.ptr,
:properties, DocProperties.ptr,
:custom_properties, CustomProperties.ptr,
:filename, :pointer,
:options, WorkbookOptions.by_value,
:num_sheets, :uint16,
:num_worksheets, :uint16,
:num_chartsheets, :uint16,
:first_sheet, :uint16,
:active_sheet, :uint16,
:num_xf_formats, :uint16,
:num_format_count, :uint16,
:drawing_count, :uint16,
:font_count, :uint16,
:border_count, :uint16,
:fill_count, :uint16,
:optimize, :uchar,
:has_png, :uchar,
:has_jpeg, :uchar,
:has_bmp, :uchar,
:used_xf_formats, HashTable.ptr,
:vba_project, :pointer,
:vba_codename, :pointer
end
attach_function :workbook_default_format, :workbook_default_format, [Workbook], Format
# @method workbook_new(filename)
# @param [String] filename
# @return [Workbook]
# @scope class
attach_function :workbook_new, :workbook_new, [:string], Workbook
# @method workbook_new_opt(filename, options)
# @param [String] filename
# @param [WorkbookOptions] options
# @return [Workbook]
# @scope class
attach_function :workbook_new_opt, :workbook_new_opt, [:string, WorkbookOptions], Workbook
# @method new_workbook(filename)
# @param [String] filename
# @return [Workbook]
# @scope class
attach_function :new_workbook, :new_workbook, [:string], Workbook
# @method new_workbook_opt(filename, options)
# @param [String] filename
# @param [WorkbookOptions] options
# @return [Workbook]
# @scope class
attach_function :new_workbook_opt, :new_workbook_opt, [:string, WorkbookOptions], Workbook
# @method workbook_add_worksheet(workbook, sheetname)
# @param [Workbook] workbook
# @param [String] sheetname
# @return [Worksheet]
# @scope class
attach_function :workbook_add_worksheet, :workbook_add_worksheet, [Workbook, :string], Worksheet
# @method workbook_add_format(workbook)
# @param [Workbook] workbook
# @return [Format]
# @scope class
attach_function :workbook_add_format, :workbook_add_format, [Workbook], Format
# @method workbook_add_chart(workbook, chart_type)
# @param [Workbook] workbook
# @param [Integer] chart_type
# @return [Chart]
# @scope class
attach_function :workbook_add_chart, :workbook_add_chart, [Workbook, :uchar], Chart
# @method workbook_close(workbook)
# @param [Workbook] workbook
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_close, :workbook_close, [Workbook], :error
# @method workbook_set_properties(workbook, properties)
# @param [Workbook] workbook
# @param [DocProperties] properties
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_set_properties, :workbook_set_properties, [Workbook, DocProperties], :error
# @method workbook_set_custom_property_string(workbook, name, value)
# @param [Workbook] workbook
# @param [String] name
# @param [String] value
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_set_custom_property_string, :workbook_set_custom_property_string, [Workbook, :string, :string], :error
# @method workbook_set_custom_property_number(workbook, name, value)
# @param [Workbook] workbook
# @param [String] name
# @param [Float] value
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_set_custom_property_number, :workbook_set_custom_property_number, [Workbook, :string, :double], :error
# @method workbook_set_custom_property_integer(workbook, name, value)
# @param [Workbook] workbook
# @param [String] name
# @param [Integer] value
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_set_custom_property_integer, :workbook_set_custom_property_integer, [Workbook, :string, :int], :error
# @method workbook_set_custom_property_boolean(workbook, name, value)
# @param [Workbook] workbook
# @param [String] name
# @param [Integer] value
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_set_custom_property_boolean, :workbook_set_custom_property_boolean, [Workbook, :string, :uchar], :error
# @method workbook_set_custom_property_datetime(workbook, name, datetime)
# @param [Workbook] workbook
# @param [String] name
# @param [Datetime] datetime
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_set_custom_property_datetime, :workbook_set_custom_property_datetime, [Workbook, :string, Datetime], :error
# @method workbook_define_name(workbook, name, formula)
# @param [Workbook] workbook
# @param [String] name
# @param [String] formula
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_define_name, :workbook_define_name, [Workbook, :string, :string], :error
# @method workbook_get_worksheet_by_name(workbook, name)
# @param [Workbook] workbook
# @param [String] name
# @return [Worksheet]
# @scope class
attach_function :workbook_get_worksheet_by_name, :workbook_get_worksheet_by_name, [Workbook, :string], Worksheet
# @method workbook_validate_worksheet_name(workbook, sheetname)
# @param [Workbook] workbook
# @param [String] sheetname
# @return [Symbol from _enum_error_]
# @scope class
attach_function :workbook_validate_worksheet_name, :workbook_validate_worksheet_name, [Workbook, :string], :error
# @method workbook_free(workbook)
# @param [Workbook] workbook
# @return [nil]
# @scope class
attach_function :workbook_free, :lxw_workbook_free, [Workbook], :void
# @method workbook_assemble_xml_file(workbook)
# @param [Workbook] workbook
# @return [nil]
# @scope class
attach_function :workbook_assemble_xml_file, :lxw_workbook_assemble_xml_file, [Workbook], :void
# @method workbook_set_default_xf_indices(workbook)
# @param [Workbook] workbook
# @return [nil]
# @scope class
attach_function :workbook_set_default_xf_indices, :lxw_workbook_set_default_xf_indices, [Workbook], :void
end