xlsxwriter 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,20 +8,22 @@ struct chart {
8
8
  lxw_chart *chart;
9
9
  };
10
10
 
11
+ struct chart_axis {
12
+ lxw_chart_axis *axis;
13
+ };
14
+
11
15
  struct chart_series {
12
16
  lxw_chart_series *series;
13
17
  };
14
18
 
15
- VALUE chart_alloc(VALUE klass);
16
- VALUE chart_init(VALUE self, VALUE worksheet, VALUE type);
17
- VALUE chart_series_alloc(VALUE klass);
18
- VALUE chart_series_init(int argc, VALUE *argv, VALUE self);
19
+ lxw_chart_fill val_to_lxw_chart_fill(VALUE opts);
20
+ lxw_chart_font val_to_lxw_chart_font(VALUE opts);
21
+ lxw_chart_line val_to_lxw_chart_line(VALUE opts);
19
22
 
20
- VALUE chart_add_series_(int argc, VALUE *argv, VALUE self);
23
+ void init_xlsxwriter_chart();
21
24
 
22
- VALUE chart_get_axis_id_1_(VALUE self);
23
- VALUE chart_set_axis_id_1_(VALUE self, VALUE val);
24
- VALUE chart_get_axis_id_2_(VALUE self);
25
- VALUE chart_set_axis_id_2_(VALUE self, VALUE val);
25
+ extern VALUE cChart;
26
+ extern VALUE cChartSeries;
27
+ extern VALUE cChartAxis;
26
28
 
27
29
  #endif // __CHART__
@@ -1,4 +1,7 @@
1
1
  #include "format.h"
2
+ #include "workbook.h"
3
+
4
+ VALUE mXlsxFormat;
2
5
 
3
6
  #define STR2SYM(x) ID2SYM(rb_intern(x))
4
7
 
@@ -14,7 +17,8 @@
14
17
  format_set_##fmt_name(format); \
15
18
  }
16
19
 
17
- void format_apply_opts(lxw_format *format, VALUE opts) {
20
+ void
21
+ format_apply_opts(lxw_format *format, VALUE opts) {
18
22
  VALUE value;
19
23
 
20
24
  MAP_FORMAT(font_name, StringValueCStr(value));
@@ -65,3 +69,87 @@ void format_apply_opts(lxw_format *format, VALUE opts) {
65
69
  MAP_FORMAT(reading_order, NUM2INT(value));
66
70
  MAP_FORMAT(theme, NUM2INT(value));
67
71
  }
72
+
73
+ void
74
+ init_xlsxwriter_format() {
75
+ /* :nodoc: */
76
+ mXlsxFormat = rb_define_module_under(mXlsxWriter, "Format");
77
+
78
+ #define MAP_LXW_FMT_CONST(name) rb_define_const(mXlsxFormat, #name, INT2NUM(LXW_##name))
79
+ MAP_LXW_FMT_CONST(COLOR_BLACK);
80
+ MAP_LXW_FMT_CONST(COLOR_BLUE);
81
+ MAP_LXW_FMT_CONST(COLOR_BROWN);
82
+ MAP_LXW_FMT_CONST(COLOR_CYAN);
83
+ MAP_LXW_FMT_CONST(COLOR_GRAY);
84
+ MAP_LXW_FMT_CONST(COLOR_GREEN);
85
+ MAP_LXW_FMT_CONST(COLOR_LIME);
86
+ MAP_LXW_FMT_CONST(COLOR_MAGENTA);
87
+ MAP_LXW_FMT_CONST(COLOR_NAVY);
88
+ MAP_LXW_FMT_CONST(COLOR_ORANGE);
89
+ MAP_LXW_FMT_CONST(COLOR_PINK);
90
+ MAP_LXW_FMT_CONST(COLOR_PURPLE);
91
+ MAP_LXW_FMT_CONST(COLOR_RED);
92
+ MAP_LXW_FMT_CONST(COLOR_SILVER);
93
+ MAP_LXW_FMT_CONST(COLOR_WHITE);
94
+ MAP_LXW_FMT_CONST(COLOR_YELLOW);
95
+
96
+ MAP_LXW_FMT_CONST(UNDERLINE_SINGLE);
97
+ MAP_LXW_FMT_CONST(UNDERLINE_DOUBLE);
98
+ MAP_LXW_FMT_CONST(UNDERLINE_SINGLE_ACCOUNTING);
99
+ MAP_LXW_FMT_CONST(UNDERLINE_DOUBLE_ACCOUNTING);
100
+
101
+ MAP_LXW_FMT_CONST(FONT_SUPERSCRIPT);
102
+ MAP_LXW_FMT_CONST(FONT_SUBSCRIPT);
103
+
104
+ MAP_LXW_FMT_CONST(ALIGN_LEFT);
105
+ MAP_LXW_FMT_CONST(ALIGN_CENTER);
106
+ MAP_LXW_FMT_CONST(ALIGN_RIGHT);
107
+ MAP_LXW_FMT_CONST(ALIGN_FILL);
108
+ MAP_LXW_FMT_CONST(ALIGN_JUSTIFY);
109
+ MAP_LXW_FMT_CONST(ALIGN_CENTER_ACROSS);
110
+ MAP_LXW_FMT_CONST(ALIGN_DISTRIBUTED);
111
+
112
+ MAP_LXW_FMT_CONST(ALIGN_VERTICAL_TOP);
113
+ MAP_LXW_FMT_CONST(ALIGN_VERTICAL_BOTTOM);
114
+ MAP_LXW_FMT_CONST(ALIGN_VERTICAL_CENTER);
115
+ MAP_LXW_FMT_CONST(ALIGN_VERTICAL_JUSTIFY);
116
+ MAP_LXW_FMT_CONST(ALIGN_VERTICAL_DISTRIBUTED);
117
+
118
+ MAP_LXW_FMT_CONST(PATTERN_SOLID);
119
+ MAP_LXW_FMT_CONST(PATTERN_MEDIUM_GRAY);
120
+ MAP_LXW_FMT_CONST(PATTERN_DARK_GRAY);
121
+ MAP_LXW_FMT_CONST(PATTERN_LIGHT_GRAY);
122
+ MAP_LXW_FMT_CONST(PATTERN_DARK_HORIZONTAL);
123
+ MAP_LXW_FMT_CONST(PATTERN_DARK_VERTICAL);
124
+ MAP_LXW_FMT_CONST(PATTERN_DARK_DOWN);
125
+ MAP_LXW_FMT_CONST(PATTERN_DARK_UP);
126
+ MAP_LXW_FMT_CONST(PATTERN_DARK_GRID);
127
+ MAP_LXW_FMT_CONST(PATTERN_DARK_TRELLIS);
128
+ MAP_LXW_FMT_CONST(PATTERN_LIGHT_HORIZONTAL);
129
+ MAP_LXW_FMT_CONST(PATTERN_LIGHT_VERTICAL);
130
+ MAP_LXW_FMT_CONST(PATTERN_LIGHT_DOWN);
131
+ MAP_LXW_FMT_CONST(PATTERN_LIGHT_UP);
132
+ MAP_LXW_FMT_CONST(PATTERN_LIGHT_GRID);
133
+ MAP_LXW_FMT_CONST(PATTERN_LIGHT_TRELLIS);
134
+ MAP_LXW_FMT_CONST(PATTERN_GRAY_125);
135
+ MAP_LXW_FMT_CONST(PATTERN_GRAY_0625);
136
+
137
+ MAP_LXW_FMT_CONST(BORDER_THIN);
138
+ MAP_LXW_FMT_CONST(BORDER_MEDIUM);
139
+ MAP_LXW_FMT_CONST(BORDER_DASHED);
140
+ MAP_LXW_FMT_CONST(BORDER_DOTTED);
141
+ MAP_LXW_FMT_CONST(BORDER_THICK);
142
+ MAP_LXW_FMT_CONST(BORDER_DOUBLE);
143
+ MAP_LXW_FMT_CONST(BORDER_HAIR);
144
+ MAP_LXW_FMT_CONST(BORDER_MEDIUM_DASHED);
145
+ MAP_LXW_FMT_CONST(BORDER_DASH_DOT);
146
+ MAP_LXW_FMT_CONST(BORDER_MEDIUM_DASH_DOT);
147
+ MAP_LXW_FMT_CONST(BORDER_DASH_DOT_DOT);
148
+ MAP_LXW_FMT_CONST(BORDER_MEDIUM_DASH_DOT_DOT);
149
+ MAP_LXW_FMT_CONST(BORDER_SLANT_DASH_DOT);
150
+
151
+ MAP_LXW_FMT_CONST(DIAGONAL_BORDER_UP);
152
+ MAP_LXW_FMT_CONST(DIAGONAL_BORDER_DOWN);
153
+ MAP_LXW_FMT_CONST(DIAGONAL_BORDER_UP_DOWN);
154
+ #undef MAP_LXW_FMT_CONST
155
+ }
@@ -6,4 +6,8 @@
6
6
 
7
7
  void format_apply_opts(lxw_format *format, VALUE opts);
8
8
 
9
+ void init_xlsxwriter_format();
10
+
11
+ extern VALUE mXlsxFormat;
12
+
9
13
  #endif // __FORMAT__
@@ -1,7 +1,16 @@
1
1
  #include <string.h>
2
2
  #include "xlsxwriter.h"
3
+ #include "chart.h"
3
4
  #include "format.h"
4
5
  #include "workbook.h"
6
+ #include "workbook_properties.h"
7
+ #include "worksheet.h"
8
+
9
+ VALUE cWorkbook;
10
+
11
+ void workbook_free(void *p);
12
+ VALUE workbook_release(VALUE self);
13
+
5
14
 
6
15
  VALUE
7
16
  workbook_alloc(VALUE klass)
@@ -19,6 +28,20 @@ workbook_alloc(VALUE klass)
19
28
  return obj;
20
29
  }
21
30
 
31
+ /* call-seq:
32
+ * XlsxWriter::Workbook.new(path, constant_memory: false, tmpdir: nil) -> workbook
33
+ * XlsxWriter::Workbook.new(path, constant_memory: false, tmpdir: nil) { |wb| block } -> nil
34
+ * XlsxWriter::Workbook.open(path, constant_memory: false, tmpdir: nil) { |wb| block } -> nil
35
+ *
36
+ * Creates a new Xlsx workbook in file +path+ and returns a new Workbook object.
37
+ *
38
+ * If +constant_memory+ is set to true workbook data is stored in temporary files
39
+ * in +tmpdir+, considerably reducing memory consumption for large documents.
40
+ *
41
+ * XlsxWriter::Workbook.open('/tmp/test.xlsx', constant_memory: true) do |wb|
42
+ * # ... populate the workbook with data ...
43
+ * end
44
+ */
22
45
  VALUE
23
46
  workbook_new_(int argc, VALUE *argv, VALUE self) {
24
47
  VALUE workbook = rb_call_super(argc, argv);
@@ -30,6 +53,7 @@ workbook_new_(int argc, VALUE *argv, VALUE self) {
30
53
  return workbook;
31
54
  }
32
55
 
56
+ /* :nodoc: */
33
57
  VALUE
34
58
  workbook_init(int argc, VALUE *argv, VALUE self) {
35
59
  struct workbook *ptr;
@@ -67,6 +91,18 @@ workbook_init(int argc, VALUE *argv, VALUE self) {
67
91
  return self;
68
92
  }
69
93
 
94
+ /* call-seq:
95
+ * wb.close -> nil
96
+ *
97
+ * Dumps the workbook content to the file and closes the worksheet.
98
+ * To be used only for workbooks opened with <code>XlsxWriter::Workbook.new</code>
99
+ * without block.
100
+ *
101
+ * No methods should be called on the worksheet after it is colsed.
102
+ *
103
+ * wb = XlsxWriter::Workbook.new('/tmp/test.xlsx')
104
+ * wb.close
105
+ */
70
106
  VALUE
71
107
  workbook_release(VALUE self) {
72
108
  struct workbook *ptr;
@@ -119,20 +155,27 @@ workbook_free(void *p) {
119
155
  }
120
156
  }
121
157
 
158
+ /* call-seq:
159
+ * wb.add_worksheet([name]) -> ws
160
+ * wb.add_worksheet([name]) { |ws| block } -> obj
161
+ *
162
+ * Adds a worksheet named +name+ to the workbook.
163
+ *
164
+ * If a block is passed, the last statement is returned.
165
+ *
166
+ * wb.add_worksheet('Sheet1') do |ws|
167
+ * ws.add_row(['test'])
168
+ * end
169
+ */
122
170
  VALUE
123
171
  workbook_add_worksheet_(int argc, VALUE *argv, VALUE self) {
124
172
  VALUE worksheet = Qnil;
125
173
 
126
- if (argc > 1) {
127
- rb_raise(rb_eArgError, "wrong number of arguments");
128
- return Qnil;
129
- }
174
+ rb_check_arity(argc, 0, 1);
130
175
 
131
176
  struct workbook *ptr;
132
177
  Data_Get_Struct(self, struct workbook, ptr);
133
178
  if (ptr->workbook) {
134
- VALUE mXlsxWriter = rb_const_get(rb_cObject, rb_intern("XlsxWriter"));
135
- VALUE cWorksheet = rb_const_get(mXlsxWriter, rb_intern("Worksheet"));
136
179
  worksheet = rb_funcall(cWorksheet, rb_intern("new"), argc + 1, self, argv[0]);
137
180
  }
138
181
 
@@ -144,6 +187,37 @@ workbook_add_worksheet_(int argc, VALUE *argv, VALUE self) {
144
187
  return worksheet;
145
188
  }
146
189
 
190
+ /* call-seq:
191
+ * wb.add_format(key, definition) -> wb
192
+ *
193
+ * Adds a format identified as +key+ with parameters set from +definition+ to the
194
+ * workbook.
195
+ *
196
+ * +definition+ should be an object and may contain the following options:
197
+ *
198
+ * :font_name:: Font family to be used to display the cell content (like Arial, Dejavu or Helvetica).
199
+ * :font_size:: Font size.
200
+ * :font_color:: Text color.
201
+ * :bold, :italic, underline :: Bold, italic, underlined text.
202
+ * :font_strikeout:: Striked out text.
203
+ * :font_script:: Superscript (XlsxWrtiter::Format::FONT_SUPERSCRIPT) or subscript (XlsxWriter::Format::FONT_SUBSCRIPT).
204
+ * :num_format:: Defines numerical format with mask, like <code>'d mmm yyyy'</code>
205
+ * or <code>'#,##0.00'</code>.
206
+ * :num_format_index:: Defines numerical format from special {pre-defined set}[https://libxlsxwriter.github.io/format_8h.html#a688aa42bcc703d17e125d9a34c721872].
207
+ * :unlocked:: Allows modifications of protected cells.
208
+ * :hidden::
209
+ * :align, :vertical_align::
210
+ * :text_wrap::
211
+ * :rotation::
212
+ * :indent::
213
+ * :shrink::
214
+ * :pattern::
215
+ * :bg_color::
216
+ * :fg_color::
217
+ * :border::
218
+ * :bottom, :top, :left, :right::
219
+ * :border_color, :bottom_color, :top_color, :left_color, :right_color::
220
+ */
147
221
  VALUE
148
222
  workbook_add_format_(VALUE self, VALUE key, VALUE opts) {
149
223
  struct workbook *ptr;
@@ -171,6 +245,23 @@ workbook_add_format_(VALUE self, VALUE key, VALUE opts) {
171
245
  return self;
172
246
  }
173
247
 
248
+ /* call-seq:
249
+ * wb.add_chart(type) { |chart| block } -> obj
250
+ * wb.add_chert(type) -> chart
251
+ *
252
+ * Adds a chart of type +type+ to the workbook.
253
+ *
254
+ * +type+ is expected to be one of <code>XlsxWriter::Workbook::Chart::{NONE, AREA,
255
+ * AREA_STACKED, AREA_STACKED_PERCENT, BAR, BAR_STACKED, BAR_STACKED_PERCENT,
256
+ * COLUMN, COLUMN_STACKED, COLUMN_STACKED_PERCENT, DOUGHNUT, LINE, PIE, SCATTER,
257
+ * SCATTER_STRAIGHT, SCATTER_STRAIGHT_WOTH_MARKERS, SCATTER_SMOOTH,
258
+ * SCATTER_SMOOTH_WITH_MARKERS, RADAR, RADAR_WITH_MARKERS, RADAR_FILLED}</code>.
259
+ *
260
+ * wb.add_chart(XlsxWriter::Workbook::Chart::PIE) do |chart|
261
+ * chart.add_series 'A1:A10', 'B1:B10'
262
+ * ws.insert_chart('D2', chart)
263
+ * end
264
+ */
174
265
  VALUE
175
266
  workbook_add_chart_(VALUE self, VALUE type) {
176
267
  VALUE chart = rb_funcall(cChart, rb_intern("new"), 2, self, type);
@@ -181,6 +272,7 @@ workbook_add_chart_(VALUE self, VALUE type) {
181
272
  return chart;
182
273
  }
183
274
 
275
+ /* :nodoc: */
184
276
  VALUE
185
277
  workbook_set_default_xf_indices_(VALUE self) {
186
278
  struct workbook *ptr;
@@ -189,6 +281,12 @@ workbook_set_default_xf_indices_(VALUE self) {
189
281
  return self;
190
282
  }
191
283
 
284
+ /* call-seq: wb.properties -> wb_properties
285
+ *
286
+ * Returns worbook properties accessor object.
287
+ *
288
+ * wb.properties.title = 'My awesome sheet'
289
+ */
192
290
  VALUE
193
291
  workbook_properties_(VALUE self) {
194
292
  VALUE props = rb_obj_alloc(cWorkbookProperties);
@@ -196,6 +294,12 @@ workbook_properties_(VALUE self) {
196
294
  return props;
197
295
  }
198
296
 
297
+ /* call-seq: wb.define_name(name, formula) -> wb
298
+ *
299
+ * Create a defined +name+ in the workbook to use as a variable defined in +formula+.
300
+ *
301
+ * wb.define_name 'Sales', '=Sheet1!$G$1:$H$10'
302
+ */
199
303
  VALUE
200
304
  workbook_define_name_(VALUE self, VALUE name, VALUE formula) {
201
305
  struct workbook *ptr;
@@ -204,6 +308,11 @@ workbook_define_name_(VALUE self, VALUE name, VALUE formula) {
204
308
  return self;
205
309
  }
206
310
 
311
+ /* call-seq: wb.validate_worksheet_name(name) -> true
312
+ *
313
+ * Validates a worksheet +name+. Returns +true+ or raises an exception (not
314
+ * implemented yet).
315
+ */
207
316
  VALUE
208
317
  workbook_validate_worksheet_name_(VALUE self, VALUE name) {
209
318
  struct workbook *ptr;
@@ -255,3 +364,33 @@ void
255
364
  handle_lxw_error(lxw_error err) {
256
365
  return;
257
366
  }
367
+
368
+
369
+ /* Document-class: XlsxWriter::Workbook
370
+ *
371
+ * +Workbook+ is the main class exposed by +XlsxWriter+. It represents the
372
+ * workbook (.xlsx) file.
373
+ */
374
+ void
375
+ init_xlsxwriter_workbook() {
376
+ cWorkbook = rb_define_class_under(mXlsxWriter, "Workbook", rb_cObject);
377
+
378
+ rb_define_alloc_func(cWorkbook, workbook_alloc);
379
+ rb_define_singleton_method(cWorkbook, "new", workbook_new_, -1);
380
+ rb_define_alias(rb_singleton_class(cWorkbook), "open", "new");
381
+ rb_define_method(cWorkbook, "initialize", workbook_init, -1);
382
+ rb_define_method(cWorkbook, "close", workbook_release, 0);
383
+ rb_define_method(cWorkbook, "add_worksheet", workbook_add_worksheet_, -1);
384
+ rb_define_method(cWorkbook, "add_format", workbook_add_format_, 2);
385
+ rb_define_method(cWorkbook, "add_chart", workbook_add_chart_, 1);
386
+ rb_define_method(cWorkbook, "set_default_xf_indices", workbook_set_default_xf_indices_, 0);
387
+ rb_define_method(cWorkbook, "properties", workbook_properties_, 0);
388
+ rb_define_method(cWorkbook, "define_name", workbook_define_name_, 2);
389
+ rb_define_method(cWorkbook, "validate_worksheet_name", workbook_validate_worksheet_name_, 1);
390
+
391
+ /*
392
+ * This attribute contains effective font widths used for automatic column
393
+ * widths of workbook columns.
394
+ */
395
+ rb_define_attr(cWorkbook, "font_sizes", 1, 0);
396
+ }
@@ -10,33 +10,13 @@ struct workbook {
10
10
  st_table *formats;
11
11
  };
12
12
 
13
-
14
- VALUE workbook_alloc(VALUE klass);
15
- VALUE workbook_new_(int argc, VALUE *argv, VALUE self);
16
- VALUE workbook_init(int argc, VALUE *argv, VALUE self);
17
- VALUE workbook_release(VALUE self);
18
- void workbook_free(void *);
19
-
20
- VALUE workbook_add_worksheet_(int argc, VALUE *argv, VALUE self);
21
- VALUE workbook_add_format_(VALUE self, VALUE key, VALUE opts);
22
- VALUE workbook_add_chart_(VALUE self, VALUE type);
23
- VALUE workbook_set_default_xf_indices_(VALUE self);
24
- VALUE workbook_properties_(VALUE self);
25
- VALUE workbook_define_name_(VALUE self, VALUE name, VALUE formula);
26
- VALUE workbook_validate_worksheet_name_(VALUE self, VALUE name);
27
-
28
-
29
13
  lxw_format *workbook_get_format(VALUE self, VALUE key);
30
14
  lxw_datetime value_to_lxw_datetime(VALUE val);
31
15
  void handle_lxw_error(lxw_error err);
32
16
 
17
+ void init_xlsxwriter_workbook();
18
+
33
19
  extern VALUE mXlsxWriter;
34
20
  extern VALUE cWorkbook;
35
- extern VALUE cWorksheet;
36
- extern VALUE mXlsxFormat;
37
- extern VALUE cWorkbookProperties;
38
- extern VALUE cChart;
39
- extern VALUE cChartSeries;
40
- extern VALUE cChartAxis;
41
21
 
42
22
  #endif // __WORKBOOK__
@@ -4,6 +4,9 @@
4
4
  #include "workbook.h"
5
5
  #include "workbook_properties.h"
6
6
 
7
+ VALUE cWorkbookProperties;
8
+
9
+ /* :nodoc: */
7
10
  VALUE
8
11
  workbook_properties_init_(VALUE self, VALUE workbook) {
9
12
  struct workbook *wb_ptr;
@@ -18,20 +21,11 @@ workbook_properties_init_(VALUE self, VALUE workbook) {
18
21
  return self;
19
22
  }
20
23
 
21
- VALUE
22
- workbook_properties_set_dir_(VALUE self, VALUE value) {
23
- VALUE key = rb_id2str(rb_frame_callee());
24
- char *key_str = ruby_strdup(RSTRING_PTR(key));
25
- size_t last_pos = RSTRING_LEN(key) - 1;
26
- if (last_pos > 0 && key_str[last_pos] == '=') {
27
- key_str[last_pos] = '\0';
28
- }
29
- key = rb_str_new_cstr(key_str);
30
- workbook_properties_set_(self, key, value);
31
- xfree(key_str);
32
- return value;
33
- }
34
-
24
+ /* call-seq: wb_properies[property]= value
25
+ *
26
+ * Sets a document +property+ (both custom and standard).
27
+ * Property type is automatically deduced from the +value+.
28
+ */
35
29
  VALUE
36
30
  workbook_properties_set_(VALUE self, VALUE key, VALUE value) {
37
31
  char *key_cstr = NULL;
@@ -101,3 +95,56 @@ workbook_properties_set_(VALUE self, VALUE key, VALUE value) {
101
95
  }
102
96
  return value;
103
97
  }
98
+
99
+ VALUE
100
+ workbook_properties_set_dir_(VALUE self, VALUE value) {
101
+ VALUE key = rb_id2str(rb_frame_callee());
102
+ char *key_str = ruby_strdup(RSTRING_PTR(key));
103
+ size_t last_pos = RSTRING_LEN(key) - 1;
104
+ if (last_pos > 0 && key_str[last_pos] == '=') {
105
+ key_str[last_pos] = '\0';
106
+ }
107
+ key = rb_str_new_cstr(key_str);
108
+ workbook_properties_set_(self, key, value);
109
+ xfree(key_str);
110
+ return value;
111
+ }
112
+
113
+ /* Document-class: XlsxWriter::Workbook::Properties
114
+ *
115
+ * The class defines accessors for workbook properties.
116
+ *
117
+ * Setting standard workbook text properties:
118
+ *
119
+ * wb_properties.title = title
120
+ * wb_properties.subject = subjet
121
+ * wb_properties.author = author
122
+ * wb_properties.manager = manager
123
+ * wb_properties.company = company
124
+ * wb_properties.category = category
125
+ * wb_properties.keywords = keywords
126
+ * wb_properties.comments = comments
127
+ * wb_properties.status = status
128
+ *
129
+ * You can see the properties under Office Button -> Prepare -> Properties
130
+ * in Excel.
131
+ */
132
+ void
133
+ init_xlsxwriter_workbook_properties() {
134
+ cWorkbookProperties = rb_define_class_under(cWorkbook, "Properties", rb_cObject);
135
+
136
+ rb_define_method(cWorkbookProperties, "initialize", workbook_properties_init_, 1);
137
+ rb_define_method(cWorkbookProperties, "[]=", workbook_properties_set_, 2);
138
+ #define DEF_PROP_HANDLER(prop) rb_define_method(cWorkbookProperties, #prop "=", workbook_properties_set_dir_, 1);
139
+ DEF_PROP_HANDLER(title);
140
+ DEF_PROP_HANDLER(subject);
141
+ DEF_PROP_HANDLER(author);
142
+ DEF_PROP_HANDLER(manager);
143
+ DEF_PROP_HANDLER(company);
144
+ DEF_PROP_HANDLER(category);
145
+ DEF_PROP_HANDLER(keywords);
146
+ DEF_PROP_HANDLER(comments);
147
+ DEF_PROP_HANDLER(status);
148
+ DEF_PROP_HANDLER(hyperlink_base);
149
+ #undef DEF_PROP_HANDLER
150
+ }