xlsxwriter 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (112) hide show
  1. checksums.yaml +7 -0
  2. data/Rakefile +40 -0
  3. data/ext/xlsxwriter/chart.c +105 -0
  4. data/ext/xlsxwriter/chart.h +27 -0
  5. data/ext/xlsxwriter/extconf.rb +14 -0
  6. data/ext/xlsxwriter/format.c +67 -0
  7. data/ext/xlsxwriter/format.h +9 -0
  8. data/ext/xlsxwriter/libxlsxwriter/LICENSE.txt +89 -0
  9. data/ext/xlsxwriter/libxlsxwriter/Makefile +141 -0
  10. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +23 -0
  11. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +79 -0
  12. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +1093 -0
  13. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +336 -0
  14. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
  15. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +51 -0
  16. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
  17. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
  18. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
  19. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
  20. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
  21. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
  22. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
  23. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
  24. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
  25. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +215 -0
  26. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
  27. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
  28. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
  29. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
  30. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
  31. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +751 -0
  32. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
  33. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
  34. data/ext/xlsxwriter/libxlsxwriter/lib/.gitignore +0 -0
  35. data/ext/xlsxwriter/libxlsxwriter/src/Makefile +125 -0
  36. data/ext/xlsxwriter/libxlsxwriter/src/app.c +439 -0
  37. data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3420 -0
  38. data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +341 -0
  39. data/ext/xlsxwriter/libxlsxwriter/src/core.c +293 -0
  40. data/ext/xlsxwriter/libxlsxwriter/src/custom.c +224 -0
  41. data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +746 -0
  42. data/ext/xlsxwriter/libxlsxwriter/src/format.c +728 -0
  43. data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +223 -0
  44. data/ext/xlsxwriter/libxlsxwriter/src/packager.c +877 -0
  45. data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +242 -0
  46. data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +264 -0
  47. data/ext/xlsxwriter/libxlsxwriter/src/styles.c +1086 -0
  48. data/ext/xlsxwriter/libxlsxwriter/src/theme.c +348 -0
  49. data/ext/xlsxwriter/libxlsxwriter/src/utility.c +512 -0
  50. data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +1895 -0
  51. data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +4992 -0
  52. data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +355 -0
  53. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +44 -0
  54. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/crypt.h +131 -0
  55. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
  56. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.h +209 -0
  57. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
  58. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
  59. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
  60. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/minizip.c +520 -0
  61. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.c +291 -0
  62. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.h +37 -0
  63. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
  64. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.h +437 -0
  65. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2007 -0
  66. data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.h +367 -0
  67. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
  68. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
  69. data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
  70. data/ext/xlsxwriter/workbook.c +257 -0
  71. data/ext/xlsxwriter/workbook.h +42 -0
  72. data/ext/xlsxwriter/workbook_properties.c +103 -0
  73. data/ext/xlsxwriter/workbook_properties.h +10 -0
  74. data/ext/xlsxwriter/worksheet.c +1064 -0
  75. data/ext/xlsxwriter/worksheet.h +74 -0
  76. data/ext/xlsxwriter/xlsxwriter.c +239 -0
  77. data/lib/xlsxwriter.rb +6 -0
  78. data/lib/xlsxwriter/version.rb +3 -0
  79. data/lib/xlsxwriter/worksheet.rb +72 -0
  80. data/test/run-test.rb +11 -0
  81. data/test/support/xlsx_comparable.rb +109 -0
  82. data/test/test-array-formula.rb +33 -0
  83. data/test/test-autofilter.rb +70 -0
  84. data/test/test-chart-area.rb +25 -0
  85. data/test/test-data.rb +65 -0
  86. data/test/test-default-row.rb +25 -0
  87. data/test/test-defined-name.rb +46 -0
  88. data/test/test-escapes.rb +33 -0
  89. data/test/test-fit-to-pages.rb +21 -0
  90. data/test/test-formatting.rb +137 -0
  91. data/test/test-gridlines.rb +15 -0
  92. data/test/test-hyperlink.rb +67 -0
  93. data/test/test-image.rb +84 -0
  94. data/test/test-merge-range.rb +18 -0
  95. data/test/test-misc.rb +29 -0
  96. data/test/test-optimize.rb +32 -0
  97. data/test/test-page-breaks.rb +13 -0
  98. data/test/test-page-setup.rb +28 -0
  99. data/test/test-panes.rb +45 -0
  100. data/test/test-print-area.rb +19 -0
  101. data/test/test-print-options.rb +61 -0
  102. data/test/test-print-scale.rb +12 -0
  103. data/test/test-properties.rb +51 -0
  104. data/test/test-protect.rb +27 -0
  105. data/test/test-repeat.rb +23 -0
  106. data/test/test-row-col-format.rb +35 -0
  107. data/test/test-set-selection.rb +13 -0
  108. data/test/test-set-start-page.rb +13 -0
  109. data/test/test-simple.rb +62 -0
  110. data/test/test-types.rb +17 -0
  111. data/test/xlsx-func-testcase.rb +36 -0
  112. metadata +228 -0
@@ -0,0 +1,1086 @@
1
+ /*****************************************************************************
2
+ * styles - A library for creating Excel XLSX styles files.
3
+ *
4
+ * Used in conjunction with the libxlsxwriter library.
5
+ *
6
+ * Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
7
+ *
8
+ */
9
+
10
+ #include "xlsxwriter/xmlwriter.h"
11
+ #include "xlsxwriter/styles.h"
12
+ #include "xlsxwriter/utility.h"
13
+
14
+ /*
15
+ * Forward declarations.
16
+ */
17
+
18
+ /*****************************************************************************
19
+ *
20
+ * Private functions.
21
+ *
22
+ ****************************************************************************/
23
+
24
+ /*
25
+ * Create a new styles object.
26
+ */
27
+ lxw_styles *
28
+ lxw_styles_new()
29
+ {
30
+ lxw_styles *styles = calloc(1, sizeof(lxw_styles));
31
+ GOTO_LABEL_ON_MEM_ERROR(styles, mem_error);
32
+
33
+ styles->xf_formats = calloc(1, sizeof(struct lxw_formats));
34
+ GOTO_LABEL_ON_MEM_ERROR(styles->xf_formats, mem_error);
35
+
36
+ STAILQ_INIT(styles->xf_formats);
37
+
38
+ return styles;
39
+
40
+ mem_error:
41
+ lxw_styles_free(styles);
42
+ return NULL;
43
+ }
44
+
45
+ /*
46
+ * Free a styles object.
47
+ */
48
+ void
49
+ lxw_styles_free(lxw_styles *styles)
50
+ {
51
+ lxw_format *format;
52
+
53
+ if (!styles)
54
+ return;
55
+
56
+ /* Free the formats in the styles. */
57
+ while (!STAILQ_EMPTY(styles->xf_formats)) {
58
+ format = STAILQ_FIRST(styles->xf_formats);
59
+ STAILQ_REMOVE_HEAD(styles->xf_formats, list_pointers);
60
+ free(format);
61
+ }
62
+
63
+ free(styles->xf_formats);
64
+ free(styles);
65
+ }
66
+
67
+ /*****************************************************************************
68
+ *
69
+ * XML functions.
70
+ *
71
+ ****************************************************************************/
72
+
73
+ /*
74
+ * Write the XML declaration.
75
+ */
76
+ STATIC void
77
+ _styles_xml_declaration(lxw_styles *self)
78
+ {
79
+ lxw_xml_declaration(self->file);
80
+ }
81
+
82
+ /*
83
+ * Write the <styleSheet> element.
84
+ */
85
+ STATIC void
86
+ _write_style_sheet(lxw_styles *self)
87
+ {
88
+ struct xml_attribute_list attributes;
89
+ struct xml_attribute *attribute;
90
+ LXW_INIT_ATTRIBUTES();
91
+ LXW_PUSH_ATTRIBUTES_STR("xmlns",
92
+ "http://schemas.openxmlformats.org/spreadsheetml/2006/main");
93
+
94
+ lxw_xml_start_tag(self->file, "styleSheet", &attributes);
95
+
96
+ LXW_FREE_ATTRIBUTES();
97
+ }
98
+
99
+ /*
100
+ * Write the <numFmt> element.
101
+ */
102
+ STATIC void
103
+ _write_num_fmt(lxw_styles *self, uint16_t num_fmt_id, char *format_code)
104
+ {
105
+ struct xml_attribute_list attributes;
106
+ struct xml_attribute *attribute;
107
+
108
+ LXW_INIT_ATTRIBUTES();
109
+ LXW_PUSH_ATTRIBUTES_INT("numFmtId", num_fmt_id);
110
+ LXW_PUSH_ATTRIBUTES_STR("formatCode", format_code);
111
+
112
+ lxw_xml_empty_tag(self->file, "numFmt", &attributes);
113
+
114
+ LXW_FREE_ATTRIBUTES();
115
+ }
116
+
117
+ /*
118
+ * Write the <numFmts> element.
119
+ */
120
+ STATIC void
121
+ _write_num_fmts(lxw_styles *self)
122
+ {
123
+ struct xml_attribute_list attributes;
124
+ struct xml_attribute *attribute;
125
+ lxw_format *format;
126
+
127
+ if (!self->num_format_count)
128
+ return;
129
+
130
+ LXW_INIT_ATTRIBUTES();
131
+ LXW_PUSH_ATTRIBUTES_INT("count", self->num_format_count);
132
+
133
+ lxw_xml_start_tag(self->file, "numFmts", &attributes);
134
+
135
+ /* Write the numFmts elements. */
136
+ STAILQ_FOREACH(format, self->xf_formats, list_pointers) {
137
+
138
+ /* Ignore built-in number formats, i.e., < 164. */
139
+ if (format->num_format_index < 164)
140
+ continue;
141
+
142
+ _write_num_fmt(self, format->num_format_index, format->num_format);
143
+ }
144
+
145
+ lxw_xml_end_tag(self->file, "numFmts");
146
+
147
+ LXW_FREE_ATTRIBUTES();
148
+ }
149
+
150
+ /*
151
+ * Write the <sz> element.
152
+ */
153
+ STATIC void
154
+ _write_font_size(lxw_styles *self, uint16_t font_size)
155
+ {
156
+ struct xml_attribute_list attributes;
157
+ struct xml_attribute *attribute;
158
+
159
+ LXW_INIT_ATTRIBUTES();
160
+ LXW_PUSH_ATTRIBUTES_INT("val", font_size);
161
+
162
+ lxw_xml_empty_tag(self->file, "sz", &attributes);
163
+
164
+ LXW_FREE_ATTRIBUTES();
165
+ }
166
+
167
+ /*
168
+ * Write the <color> element for themes.
169
+ */
170
+ STATIC void
171
+ _write_font_color_theme(lxw_styles *self, uint8_t theme)
172
+ {
173
+ struct xml_attribute_list attributes;
174
+ struct xml_attribute *attribute;
175
+
176
+ LXW_INIT_ATTRIBUTES();
177
+ LXW_PUSH_ATTRIBUTES_INT("theme", theme);
178
+
179
+ lxw_xml_empty_tag(self->file, "color", &attributes);
180
+
181
+ LXW_FREE_ATTRIBUTES();
182
+ }
183
+
184
+ /*
185
+ * Write the <color> element for RGB colors.
186
+ */
187
+ STATIC void
188
+ _write_font_color_rgb(lxw_styles *self, int32_t rgb)
189
+ {
190
+ struct xml_attribute_list attributes;
191
+ struct xml_attribute *attribute;
192
+ char rgb_str[LXW_ATTR_32];
193
+
194
+ lxw_snprintf(rgb_str, LXW_ATTR_32, "FF%06X", rgb & LXW_COLOR_MASK);
195
+
196
+ LXW_INIT_ATTRIBUTES();
197
+ LXW_PUSH_ATTRIBUTES_STR("rgb", rgb_str);
198
+
199
+ lxw_xml_empty_tag(self->file, "color", &attributes);
200
+
201
+ LXW_FREE_ATTRIBUTES();
202
+ }
203
+
204
+ /*
205
+ * Write the <name> element.
206
+ */
207
+ STATIC void
208
+ _write_font_name(lxw_styles *self, const char *font_name)
209
+ {
210
+ struct xml_attribute_list attributes;
211
+ struct xml_attribute *attribute;
212
+
213
+ LXW_INIT_ATTRIBUTES();
214
+
215
+ if (*font_name)
216
+ LXW_PUSH_ATTRIBUTES_STR("val", font_name);
217
+ else
218
+ LXW_PUSH_ATTRIBUTES_STR("val", LXW_DEFAULT_FONT_NAME);
219
+
220
+ lxw_xml_empty_tag(self->file, "name", &attributes);
221
+
222
+ LXW_FREE_ATTRIBUTES();
223
+ }
224
+
225
+ /*
226
+ * Write the <family> element.
227
+ */
228
+ STATIC void
229
+ _write_font_family(lxw_styles *self, uint8_t font_family)
230
+ {
231
+ struct xml_attribute_list attributes;
232
+ struct xml_attribute *attribute;
233
+
234
+ LXW_INIT_ATTRIBUTES();
235
+ LXW_PUSH_ATTRIBUTES_INT("val", font_family);
236
+
237
+ lxw_xml_empty_tag(self->file, "family", &attributes);
238
+
239
+ LXW_FREE_ATTRIBUTES();
240
+ }
241
+
242
+ /*
243
+ * Write the <scheme> element.
244
+ */
245
+ STATIC void
246
+ _write_font_scheme(lxw_styles *self, const char *font_scheme)
247
+ {
248
+ struct xml_attribute_list attributes;
249
+ struct xml_attribute *attribute;
250
+
251
+ LXW_INIT_ATTRIBUTES();
252
+
253
+ if (*font_scheme)
254
+ LXW_PUSH_ATTRIBUTES_STR("val", font_scheme);
255
+ else
256
+ LXW_PUSH_ATTRIBUTES_STR("val", "minor");
257
+
258
+ lxw_xml_empty_tag(self->file, "scheme", &attributes);
259
+
260
+ LXW_FREE_ATTRIBUTES();
261
+ }
262
+
263
+ /*
264
+ * Write the underline font element.
265
+ */
266
+ STATIC void
267
+ _write_font_underline(lxw_styles *self, uint8_t underline)
268
+ {
269
+ struct xml_attribute_list attributes;
270
+ struct xml_attribute *attribute;
271
+
272
+ LXW_INIT_ATTRIBUTES();
273
+
274
+ /* Handle the underline variants. */
275
+ if (underline == LXW_UNDERLINE_DOUBLE)
276
+ LXW_PUSH_ATTRIBUTES_STR("val", "double");
277
+ else if (underline == LXW_UNDERLINE_SINGLE_ACCOUNTING)
278
+ LXW_PUSH_ATTRIBUTES_STR("val", "singleAccounting");
279
+ else if (underline == LXW_UNDERLINE_DOUBLE_ACCOUNTING)
280
+ LXW_PUSH_ATTRIBUTES_STR("val", "doubleAccounting");
281
+ /* Default to single underline. */
282
+
283
+ lxw_xml_empty_tag(self->file, "u", &attributes);
284
+
285
+ LXW_FREE_ATTRIBUTES();
286
+
287
+ }
288
+
289
+ /*
290
+ * Write the <vertAlign> font sub-element.
291
+ */
292
+ STATIC void
293
+ _write_vert_align(lxw_styles *self, const char *align)
294
+ {
295
+ struct xml_attribute_list attributes;
296
+ struct xml_attribute *attribute;
297
+
298
+ LXW_INIT_ATTRIBUTES();
299
+ LXW_PUSH_ATTRIBUTES_STR("val", align);
300
+
301
+ lxw_xml_empty_tag(self->file, "vertAlign", &attributes);
302
+
303
+ LXW_FREE_ATTRIBUTES();
304
+ }
305
+
306
+ /*
307
+ * Write the <font> element.
308
+ */
309
+ STATIC void
310
+ _write_font(lxw_styles *self, lxw_format *format)
311
+ {
312
+ lxw_xml_start_tag(self->file, "font", NULL);
313
+
314
+ if (format->bold)
315
+ lxw_xml_empty_tag(self->file, "b", NULL);
316
+
317
+ if (format->italic)
318
+ lxw_xml_empty_tag(self->file, "i", NULL);
319
+
320
+ if (format->font_strikeout)
321
+ lxw_xml_empty_tag(self->file, "strike", NULL);
322
+
323
+ if (format->font_outline)
324
+ lxw_xml_empty_tag(self->file, "outline", NULL);
325
+
326
+ if (format->font_shadow)
327
+ lxw_xml_empty_tag(self->file, "shadow", NULL);
328
+
329
+ if (format->underline)
330
+ _write_font_underline(self, format->underline);
331
+
332
+ if (format->font_script == LXW_FONT_SUPERSCRIPT)
333
+ _write_vert_align(self, "superscript");
334
+
335
+ if (format->font_script == LXW_FONT_SUBSCRIPT)
336
+ _write_vert_align(self, "subscript");
337
+
338
+ if (format->font_size)
339
+ _write_font_size(self, format->font_size);
340
+
341
+ if (format->theme)
342
+ _write_font_color_theme(self, format->theme);
343
+ else if (format->font_color != LXW_COLOR_UNSET)
344
+ _write_font_color_rgb(self, format->font_color);
345
+ else
346
+ _write_font_color_theme(self, LXW_DEFAULT_FONT_THEME);
347
+
348
+ _write_font_name(self, format->font_name);
349
+ _write_font_family(self, format->font_family);
350
+
351
+ /* Only write the scheme element for the default font type if it
352
+ * is a hyperlink. */
353
+ if ((!*format->font_name
354
+ || strcmp(LXW_DEFAULT_FONT_NAME, format->font_name) == 0)
355
+ && !format->hyperlink) {
356
+ _write_font_scheme(self, format->font_scheme);
357
+ }
358
+
359
+ lxw_xml_end_tag(self->file, "font");
360
+ }
361
+
362
+ /*
363
+ * Write the <fonts> element.
364
+ */
365
+ STATIC void
366
+ _write_fonts(lxw_styles *self)
367
+ {
368
+ struct xml_attribute_list attributes;
369
+ struct xml_attribute *attribute;
370
+ lxw_format *format;
371
+
372
+ LXW_INIT_ATTRIBUTES();
373
+ LXW_PUSH_ATTRIBUTES_INT("count", self->font_count);
374
+
375
+ lxw_xml_start_tag(self->file, "fonts", &attributes);
376
+
377
+ STAILQ_FOREACH(format, self->xf_formats, list_pointers) {
378
+ if (format->has_font)
379
+ _write_font(self, format);
380
+ }
381
+
382
+ lxw_xml_end_tag(self->file, "fonts");
383
+
384
+ LXW_FREE_ATTRIBUTES();
385
+ }
386
+
387
+ /*
388
+ * Write the default <fill> element.
389
+ */
390
+ STATIC void
391
+ _write_default_fill(lxw_styles *self, const char *pattern)
392
+ {
393
+ struct xml_attribute_list attributes;
394
+ struct xml_attribute *attribute;
395
+
396
+ LXW_INIT_ATTRIBUTES();
397
+ LXW_PUSH_ATTRIBUTES_STR("patternType", pattern);
398
+
399
+ lxw_xml_start_tag(self->file, "fill", NULL);
400
+ lxw_xml_empty_tag(self->file, "patternFill", &attributes);
401
+ lxw_xml_end_tag(self->file, "fill");
402
+
403
+ LXW_FREE_ATTRIBUTES();
404
+ }
405
+
406
+ /*
407
+ * Write the <fgColor> element.
408
+ */
409
+ STATIC void
410
+ _write_fg_color(lxw_styles *self, lxw_color_t color)
411
+ {
412
+ struct xml_attribute_list attributes;
413
+ struct xml_attribute *attribute;
414
+ char rgb_str[LXW_ATTR_32];
415
+
416
+ LXW_INIT_ATTRIBUTES();
417
+
418
+ lxw_snprintf(rgb_str, LXW_ATTR_32, "FF%06X", color & LXW_COLOR_MASK);
419
+ LXW_PUSH_ATTRIBUTES_STR("rgb", rgb_str);
420
+
421
+ lxw_xml_empty_tag(self->file, "fgColor", &attributes);
422
+
423
+ LXW_FREE_ATTRIBUTES();
424
+ }
425
+
426
+ /*
427
+ * Write the <bgColor> element.
428
+ */
429
+ STATIC void
430
+ _write_bg_color(lxw_styles *self, lxw_color_t color)
431
+ {
432
+ struct xml_attribute_list attributes;
433
+ struct xml_attribute *attribute;
434
+ char rgb_str[LXW_ATTR_32];
435
+
436
+ LXW_INIT_ATTRIBUTES();
437
+
438
+ if (color == LXW_COLOR_UNSET) {
439
+ LXW_PUSH_ATTRIBUTES_STR("indexed", "64");
440
+ }
441
+ else {
442
+ lxw_snprintf(rgb_str, LXW_ATTR_32, "FF%06X", color & LXW_COLOR_MASK);
443
+ LXW_PUSH_ATTRIBUTES_STR("rgb", rgb_str);
444
+ }
445
+
446
+ lxw_xml_empty_tag(self->file, "bgColor", &attributes);
447
+
448
+ LXW_FREE_ATTRIBUTES();
449
+ }
450
+
451
+ /*
452
+ * Write the <fill> element.
453
+ */
454
+ STATIC void
455
+ _write_fill(lxw_styles *self, lxw_format *format)
456
+ {
457
+ struct xml_attribute_list attributes;
458
+ struct xml_attribute *attribute;
459
+
460
+ uint8_t pattern = format->pattern;
461
+ lxw_color_t bg_color = format->bg_color;
462
+ lxw_color_t fg_color = format->fg_color;
463
+
464
+ char *patterns[] = {
465
+ "none",
466
+ "solid",
467
+ "mediumGray",
468
+ "darkGray",
469
+ "lightGray",
470
+ "darkHorizontal",
471
+ "darkVertical",
472
+ "darkDown",
473
+ "darkUp",
474
+ "darkGrid",
475
+ "darkTrellis",
476
+ "lightHorizontal",
477
+ "lightVertical",
478
+ "lightDown",
479
+ "lightUp",
480
+ "lightGrid",
481
+ "lightTrellis",
482
+ "gray125",
483
+ "gray0625",
484
+ };
485
+
486
+ LXW_INIT_ATTRIBUTES();
487
+
488
+ lxw_xml_start_tag(self->file, "fill", NULL);
489
+
490
+ if (pattern)
491
+ LXW_PUSH_ATTRIBUTES_STR("patternType", patterns[pattern]);
492
+
493
+ lxw_xml_start_tag(self->file, "patternFill", &attributes);
494
+
495
+ if (fg_color != LXW_COLOR_UNSET)
496
+ _write_fg_color(self, fg_color);
497
+
498
+ _write_bg_color(self, bg_color);
499
+
500
+ lxw_xml_end_tag(self->file, "patternFill");
501
+ lxw_xml_end_tag(self->file, "fill");
502
+
503
+ LXW_FREE_ATTRIBUTES();
504
+ }
505
+
506
+ /*
507
+ * Write the <fills> element.
508
+ */
509
+ STATIC void
510
+ _write_fills(lxw_styles *self)
511
+ {
512
+ struct xml_attribute_list attributes;
513
+ struct xml_attribute *attribute;
514
+ lxw_format *format;
515
+
516
+ LXW_INIT_ATTRIBUTES();
517
+ LXW_PUSH_ATTRIBUTES_INT("count", self->fill_count);
518
+
519
+ lxw_xml_start_tag(self->file, "fills", &attributes);
520
+
521
+ /* Write the default fills. */
522
+ _write_default_fill(self, "none");
523
+ _write_default_fill(self, "gray125");
524
+
525
+ STAILQ_FOREACH(format, self->xf_formats, list_pointers) {
526
+ if (format->has_fill)
527
+ _write_fill(self, format);
528
+ }
529
+
530
+ lxw_xml_end_tag(self->file, "fills");
531
+
532
+ LXW_FREE_ATTRIBUTES();
533
+ }
534
+
535
+ /*
536
+ * Write the border <color> element.
537
+ */
538
+ STATIC void
539
+ _write_border_color(lxw_styles *self, lxw_color_t color)
540
+ {
541
+ struct xml_attribute_list attributes;
542
+ struct xml_attribute *attribute;
543
+ char rgb_str[LXW_ATTR_32];
544
+
545
+ LXW_INIT_ATTRIBUTES();
546
+
547
+ if (color != LXW_COLOR_UNSET) {
548
+ lxw_snprintf(rgb_str, LXW_ATTR_32, "FF%06X", color & LXW_COLOR_MASK);
549
+ LXW_PUSH_ATTRIBUTES_STR("rgb", rgb_str);
550
+ }
551
+ else {
552
+ LXW_PUSH_ATTRIBUTES_STR("auto", "1");
553
+ }
554
+
555
+ lxw_xml_empty_tag(self->file, "color", &attributes);
556
+
557
+ LXW_FREE_ATTRIBUTES();
558
+ }
559
+
560
+ /*
561
+ * Write the <border> sub elements such as <right>, <top>, etc.
562
+ */
563
+ STATIC void
564
+ _write_sub_border(lxw_styles *self, const char *type, uint8_t style,
565
+ lxw_color_t color)
566
+ {
567
+ struct xml_attribute_list attributes;
568
+ struct xml_attribute *attribute;
569
+
570
+ char *border_styles[] = {
571
+ "none",
572
+ "thin",
573
+ "medium",
574
+ "dashed",
575
+ "dotted",
576
+ "thick",
577
+ "double",
578
+ "hair",
579
+ "mediumDashed",
580
+ "dashDot",
581
+ "mediumDashDot",
582
+ "dashDotDot",
583
+ "mediumDashDotDot",
584
+ "slantDashDot",
585
+ };
586
+
587
+ if (!style) {
588
+ lxw_xml_empty_tag(self->file, type, NULL);
589
+ return;
590
+ }
591
+
592
+ LXW_INIT_ATTRIBUTES();
593
+ LXW_PUSH_ATTRIBUTES_STR("style", border_styles[style]);
594
+
595
+ lxw_xml_start_tag(self->file, type, &attributes);
596
+
597
+ _write_border_color(self, color);
598
+
599
+ lxw_xml_end_tag(self->file, type);
600
+
601
+ LXW_FREE_ATTRIBUTES();
602
+ }
603
+
604
+ /*
605
+ * Write the <border> element.
606
+ */
607
+ STATIC void
608
+ _write_border(lxw_styles *self, lxw_format *format)
609
+ {
610
+ struct xml_attribute_list attributes;
611
+ struct xml_attribute *attribute;
612
+
613
+ LXW_INIT_ATTRIBUTES();
614
+
615
+ /* Add attributes for diagonal borders. */
616
+ if (format->diag_type == LXW_DIAGONAL_BORDER_UP) {
617
+ LXW_PUSH_ATTRIBUTES_STR("diagonalUp", "1");
618
+ }
619
+ else if (format->diag_type == LXW_DIAGONAL_BORDER_DOWN) {
620
+ LXW_PUSH_ATTRIBUTES_STR("diagonalDown", "1");
621
+ }
622
+ else if (format->diag_type == LXW_DIAGONAL_BORDER_UP_DOWN) {
623
+ LXW_PUSH_ATTRIBUTES_STR("diagonalUp", "1");
624
+ LXW_PUSH_ATTRIBUTES_STR("diagonalDown", "1");
625
+ }
626
+
627
+ /* Ensure that a default diag border is set if the diag type is set. */
628
+ if (format->diag_type && !format->diag_border) {
629
+ format->diag_border = 1;
630
+ }
631
+
632
+ /* Write the start border tag. */
633
+ lxw_xml_start_tag(self->file, "border", &attributes);
634
+
635
+ /* Write the <border> sub elements. */
636
+ _write_sub_border(self, "left", format->left, format->left_color);
637
+ _write_sub_border(self, "right", format->right, format->right_color);
638
+ _write_sub_border(self, "top", format->top, format->top_color);
639
+ _write_sub_border(self, "bottom", format->bottom, format->bottom_color);
640
+ _write_sub_border(self,
641
+ "diagonal", format->diag_border, format->diag_color);
642
+
643
+ lxw_xml_end_tag(self->file, "border");
644
+
645
+ LXW_FREE_ATTRIBUTES();
646
+ }
647
+
648
+ /*
649
+ * Write the <borders> element.
650
+ */
651
+ STATIC void
652
+ _write_borders(lxw_styles *self)
653
+ {
654
+ struct xml_attribute_list attributes;
655
+ struct xml_attribute *attribute;
656
+ lxw_format *format;
657
+
658
+ LXW_INIT_ATTRIBUTES();
659
+ LXW_PUSH_ATTRIBUTES_INT("count", self->border_count);
660
+
661
+ lxw_xml_start_tag(self->file, "borders", &attributes);
662
+
663
+ STAILQ_FOREACH(format, self->xf_formats, list_pointers) {
664
+ if (format->has_border)
665
+ _write_border(self, format);
666
+ }
667
+
668
+ lxw_xml_end_tag(self->file, "borders");
669
+
670
+ LXW_FREE_ATTRIBUTES();
671
+ }
672
+
673
+ /*
674
+ * Write the <xf> element for styles.
675
+ */
676
+ STATIC void
677
+ _write_style_xf(lxw_styles *self)
678
+ {
679
+ struct xml_attribute_list attributes;
680
+ struct xml_attribute *attribute;
681
+
682
+ LXW_INIT_ATTRIBUTES();
683
+ LXW_PUSH_ATTRIBUTES_STR("numFmtId", "0");
684
+ LXW_PUSH_ATTRIBUTES_STR("fontId", "0");
685
+ LXW_PUSH_ATTRIBUTES_STR("fillId", "0");
686
+ LXW_PUSH_ATTRIBUTES_STR("borderId", "0");
687
+
688
+ lxw_xml_empty_tag(self->file, "xf", &attributes);
689
+
690
+ LXW_FREE_ATTRIBUTES();
691
+ }
692
+
693
+ /*
694
+ * Write the <cellStyleXfs> element.
695
+ */
696
+ STATIC void
697
+ _write_cell_style_xfs(lxw_styles *self)
698
+ {
699
+ struct xml_attribute_list attributes;
700
+ struct xml_attribute *attribute;
701
+
702
+ LXW_INIT_ATTRIBUTES();
703
+ LXW_PUSH_ATTRIBUTES_STR("count", "1");
704
+
705
+ lxw_xml_start_tag(self->file, "cellStyleXfs", &attributes);
706
+ _write_style_xf(self);
707
+ lxw_xml_end_tag(self->file, "cellStyleXfs");
708
+
709
+ LXW_FREE_ATTRIBUTES();
710
+ }
711
+
712
+ /*
713
+ * Check if a format struct has alignment properties set and the
714
+ * "applyAlignment" attribute should be set.
715
+ */
716
+ STATIC uint8_t
717
+ _apply_alignment(lxw_format *format)
718
+ {
719
+ return format->text_h_align != LXW_ALIGN_NONE
720
+ || format->text_v_align != LXW_ALIGN_NONE
721
+ || format->indent != 0
722
+ || format->rotation != 0
723
+ || format->text_wrap != 0
724
+ || format->shrink != 0 || format->reading_order != 0;
725
+ }
726
+
727
+ /*
728
+ * Check if a format struct has alignment properties set apart from the
729
+ * LXW_ALIGN_VERTICAL_BOTTOM which Excel treats as a default.
730
+ */
731
+ STATIC uint8_t
732
+ _has_alignment(lxw_format *format)
733
+ {
734
+ return format->text_h_align != LXW_ALIGN_NONE
735
+ || !(format->text_v_align == LXW_ALIGN_NONE ||
736
+ format->text_v_align == LXW_ALIGN_VERTICAL_BOTTOM)
737
+ || format->indent != 0
738
+ || format->rotation != 0
739
+ || format->text_wrap != 0
740
+ || format->shrink != 0 || format->reading_order != 0;
741
+ }
742
+
743
+ /*
744
+ * Write the <alignment> element.
745
+ */
746
+ STATIC void
747
+ _write_alignment(lxw_styles *self, lxw_format *format)
748
+ {
749
+ struct xml_attribute_list attributes;
750
+ struct xml_attribute *attribute;
751
+ int16_t rotation = format->rotation;
752
+
753
+ LXW_INIT_ATTRIBUTES();
754
+
755
+ /* Indent is only allowed for horizontal left, right and distributed. */
756
+ /* If it is defined for any other alignment or no alignment has been */
757
+ /* set then default to left alignment. */
758
+ if (format->indent
759
+ && format->text_h_align != LXW_ALIGN_LEFT
760
+ && format->text_h_align != LXW_ALIGN_RIGHT
761
+ && format->text_h_align != LXW_ALIGN_DISTRIBUTED) {
762
+ format->text_h_align = LXW_ALIGN_LEFT;
763
+ }
764
+
765
+ /* Check for properties that are mutually exclusive. */
766
+ if (format->text_wrap)
767
+ format->shrink = 0;
768
+
769
+ if (format->text_h_align == LXW_ALIGN_FILL)
770
+ format->shrink = 0;
771
+
772
+ if (format->text_h_align == LXW_ALIGN_JUSTIFY)
773
+ format->shrink = 0;
774
+
775
+ if (format->text_h_align == LXW_ALIGN_DISTRIBUTED)
776
+ format->shrink = 0;
777
+
778
+ if (format->text_h_align != LXW_ALIGN_DISTRIBUTED)
779
+ format->just_distrib = 0;
780
+
781
+ if (format->indent)
782
+ format->just_distrib = 0;
783
+
784
+ if (format->text_h_align == LXW_ALIGN_LEFT)
785
+ LXW_PUSH_ATTRIBUTES_STR("horizontal", "left");
786
+
787
+ if (format->text_h_align == LXW_ALIGN_CENTER)
788
+ LXW_PUSH_ATTRIBUTES_STR("horizontal", "center");
789
+
790
+ if (format->text_h_align == LXW_ALIGN_RIGHT)
791
+ LXW_PUSH_ATTRIBUTES_STR("horizontal", "right");
792
+
793
+ if (format->text_h_align == LXW_ALIGN_FILL)
794
+ LXW_PUSH_ATTRIBUTES_STR("horizontal", "fill");
795
+
796
+ if (format->text_h_align == LXW_ALIGN_JUSTIFY)
797
+ LXW_PUSH_ATTRIBUTES_STR("horizontal", "justify");
798
+
799
+ if (format->text_h_align == LXW_ALIGN_CENTER_ACROSS)
800
+ LXW_PUSH_ATTRIBUTES_STR("horizontal", "centerContinuous");
801
+
802
+ if (format->text_h_align == LXW_ALIGN_DISTRIBUTED)
803
+ LXW_PUSH_ATTRIBUTES_STR("horizontal", "distributed");
804
+
805
+ if (format->just_distrib)
806
+ LXW_PUSH_ATTRIBUTES_STR("justifyLastLine", "1");
807
+
808
+ if (format->text_v_align == LXW_ALIGN_VERTICAL_TOP)
809
+ LXW_PUSH_ATTRIBUTES_STR("vertical", "top");
810
+
811
+ if (format->text_v_align == LXW_ALIGN_VERTICAL_CENTER)
812
+ LXW_PUSH_ATTRIBUTES_STR("vertical", "center");
813
+
814
+ if (format->text_v_align == LXW_ALIGN_VERTICAL_JUSTIFY)
815
+ LXW_PUSH_ATTRIBUTES_STR("vertical", "justify");
816
+
817
+ if (format->text_v_align == LXW_ALIGN_VERTICAL_DISTRIBUTED)
818
+ LXW_PUSH_ATTRIBUTES_STR("vertical", "distributed");
819
+
820
+ if (format->indent)
821
+ LXW_PUSH_ATTRIBUTES_INT("indent", format->indent);
822
+
823
+ /* Map rotation to Excel values. */
824
+ if (rotation) {
825
+ if (rotation == 270)
826
+ rotation = 255;
827
+ else if (rotation < 0)
828
+ rotation = -rotation + 90;
829
+
830
+ LXW_PUSH_ATTRIBUTES_INT("textRotation", rotation);
831
+ }
832
+
833
+ if (format->text_wrap)
834
+ LXW_PUSH_ATTRIBUTES_STR("wrapText", "1");
835
+
836
+ if (format->shrink)
837
+ LXW_PUSH_ATTRIBUTES_STR("shrinkToFit", "1");
838
+
839
+ if (format->reading_order == 1)
840
+ LXW_PUSH_ATTRIBUTES_STR("readingOrder", "1");
841
+
842
+ if (format->reading_order == 2)
843
+ LXW_PUSH_ATTRIBUTES_STR("readingOrder", "2");
844
+
845
+ if (!STAILQ_EMPTY(&attributes))
846
+ lxw_xml_empty_tag(self->file, "alignment", &attributes);
847
+
848
+ LXW_FREE_ATTRIBUTES();
849
+ }
850
+
851
+ /*
852
+ * Write the <protection> element.
853
+ */
854
+ STATIC void
855
+ _write_protection(lxw_styles *self, lxw_format *format)
856
+ {
857
+ struct xml_attribute_list attributes;
858
+ struct xml_attribute *attribute;
859
+
860
+ LXW_INIT_ATTRIBUTES();
861
+
862
+ if (!format->locked)
863
+ LXW_PUSH_ATTRIBUTES_STR("locked", "0");
864
+
865
+ if (format->hidden)
866
+ LXW_PUSH_ATTRIBUTES_STR("hidden", "1");
867
+
868
+ lxw_xml_empty_tag(self->file, "protection", &attributes);
869
+
870
+ LXW_FREE_ATTRIBUTES();
871
+ }
872
+
873
+ /*
874
+ * Write the <xf> element.
875
+ */
876
+ STATIC void
877
+ _write_xf(lxw_styles *self, lxw_format *format)
878
+ {
879
+ struct xml_attribute_list attributes;
880
+ struct xml_attribute *attribute;
881
+ uint8_t has_protection = (!format->locked) | format->hidden;
882
+ uint8_t has_alignment = _has_alignment(format);
883
+ uint8_t apply_alignment = _apply_alignment(format);
884
+
885
+ LXW_INIT_ATTRIBUTES();
886
+ LXW_PUSH_ATTRIBUTES_INT("numFmtId", format->num_format_index);
887
+ LXW_PUSH_ATTRIBUTES_INT("fontId", format->font_index);
888
+ LXW_PUSH_ATTRIBUTES_INT("fillId", format->fill_index);
889
+ LXW_PUSH_ATTRIBUTES_INT("borderId", format->border_index);
890
+ LXW_PUSH_ATTRIBUTES_STR("xfId", "0");
891
+
892
+ if (format->num_format_index > 0)
893
+ LXW_PUSH_ATTRIBUTES_STR("applyNumberFormat", "1");
894
+
895
+ /* Add applyFont attribute if XF format uses a font element. */
896
+ if (format->font_index > 0)
897
+ LXW_PUSH_ATTRIBUTES_STR("applyFont", "1");
898
+
899
+ /* Add applyFill attribute if XF format uses a fill element. */
900
+ if (format->fill_index > 0)
901
+ LXW_PUSH_ATTRIBUTES_STR("applyFill", "1");
902
+
903
+ /* Add applyBorder attribute if XF format uses a border element. */
904
+ if (format->border_index > 0)
905
+ LXW_PUSH_ATTRIBUTES_STR("applyBorder", "1");
906
+
907
+ /* We can also have applyAlignment without a sub-element. */
908
+ if (apply_alignment)
909
+ LXW_PUSH_ATTRIBUTES_STR("applyAlignment", "1");
910
+
911
+ if (has_protection)
912
+ LXW_PUSH_ATTRIBUTES_STR("applyProtection", "1");
913
+
914
+ /* Write XF with sub-elements if required. */
915
+ if (has_alignment || has_protection) {
916
+ lxw_xml_start_tag(self->file, "xf", &attributes);
917
+
918
+ if (has_alignment)
919
+ _write_alignment(self, format);
920
+
921
+ if (has_protection)
922
+ _write_protection(self, format);
923
+
924
+ lxw_xml_end_tag(self->file, "xf");
925
+ }
926
+ else {
927
+ lxw_xml_empty_tag(self->file, "xf", &attributes);
928
+ }
929
+
930
+ LXW_FREE_ATTRIBUTES();
931
+ }
932
+
933
+ /*
934
+ * Write the <cellXfs> element.
935
+ */
936
+ STATIC void
937
+ _write_cell_xfs(lxw_styles *self)
938
+ {
939
+ struct xml_attribute_list attributes;
940
+ struct xml_attribute *attribute;
941
+ lxw_format *format;
942
+
943
+ LXW_INIT_ATTRIBUTES();
944
+ LXW_PUSH_ATTRIBUTES_INT("count", self->xf_count);
945
+
946
+ lxw_xml_start_tag(self->file, "cellXfs", &attributes);
947
+
948
+ STAILQ_FOREACH(format, self->xf_formats, list_pointers) {
949
+ _write_xf(self, format);
950
+ }
951
+
952
+ lxw_xml_end_tag(self->file, "cellXfs");
953
+
954
+ LXW_FREE_ATTRIBUTES();
955
+ }
956
+
957
+ /*
958
+ * Write the <cellStyle> element.
959
+ */
960
+ STATIC void
961
+ _write_cell_style(lxw_styles *self)
962
+ {
963
+ struct xml_attribute_list attributes;
964
+ struct xml_attribute *attribute;
965
+
966
+ LXW_INIT_ATTRIBUTES();
967
+ LXW_PUSH_ATTRIBUTES_STR("name", "Normal");
968
+ LXW_PUSH_ATTRIBUTES_STR("xfId", "0");
969
+ LXW_PUSH_ATTRIBUTES_STR("builtinId", "0");
970
+
971
+ lxw_xml_empty_tag(self->file, "cellStyle", &attributes);
972
+
973
+ LXW_FREE_ATTRIBUTES();
974
+ }
975
+
976
+ /*
977
+ * Write the <cellStyles> element.
978
+ */
979
+ STATIC void
980
+ _write_cell_styles(lxw_styles *self)
981
+ {
982
+ struct xml_attribute_list attributes;
983
+ struct xml_attribute *attribute;
984
+ LXW_INIT_ATTRIBUTES();
985
+ LXW_PUSH_ATTRIBUTES_STR("count", "1");
986
+
987
+ lxw_xml_start_tag(self->file, "cellStyles", &attributes);
988
+ _write_cell_style(self);
989
+ lxw_xml_end_tag(self->file, "cellStyles");
990
+
991
+ LXW_FREE_ATTRIBUTES();
992
+ }
993
+
994
+ /*
995
+ * Write the <dxfs> element.
996
+ */
997
+ STATIC void
998
+ _write_dxfs(lxw_styles *self)
999
+ {
1000
+ struct xml_attribute_list attributes;
1001
+ struct xml_attribute *attribute;
1002
+
1003
+ LXW_INIT_ATTRIBUTES();
1004
+ LXW_PUSH_ATTRIBUTES_STR("count", "0");
1005
+
1006
+ lxw_xml_empty_tag(self->file, "dxfs", &attributes);
1007
+
1008
+ LXW_FREE_ATTRIBUTES();
1009
+ }
1010
+
1011
+ /*
1012
+ * Write the <tableStyles> element.
1013
+ */
1014
+ STATIC void
1015
+ _write_table_styles(lxw_styles *self)
1016
+ {
1017
+ struct xml_attribute_list attributes;
1018
+ struct xml_attribute *attribute;
1019
+
1020
+ LXW_INIT_ATTRIBUTES();
1021
+ LXW_PUSH_ATTRIBUTES_STR("count", "0");
1022
+ LXW_PUSH_ATTRIBUTES_STR("defaultTableStyle", "TableStyleMedium9");
1023
+ LXW_PUSH_ATTRIBUTES_STR("defaultPivotStyle", "PivotStyleLight16");
1024
+
1025
+ lxw_xml_empty_tag(self->file, "tableStyles", &attributes);
1026
+
1027
+ LXW_FREE_ATTRIBUTES();
1028
+ }
1029
+
1030
+ /*****************************************************************************
1031
+ *
1032
+ * XML file assembly functions.
1033
+ *
1034
+ ****************************************************************************/
1035
+
1036
+ /*
1037
+ * Assemble and write the XML file.
1038
+ */
1039
+ void
1040
+ lxw_styles_assemble_xml_file(lxw_styles *self)
1041
+ {
1042
+ /* Write the XML declaration. */
1043
+ _styles_xml_declaration(self);
1044
+
1045
+ /* Add the style sheet. */
1046
+ _write_style_sheet(self);
1047
+
1048
+ /* Write the number formats. */
1049
+ _write_num_fmts(self);
1050
+
1051
+ /* Write the fonts. */
1052
+ _write_fonts(self);
1053
+
1054
+ /* Write the fills. */
1055
+ _write_fills(self);
1056
+
1057
+ /* Write the borders element. */
1058
+ _write_borders(self);
1059
+
1060
+ /* Write the cellStyleXfs element. */
1061
+ _write_cell_style_xfs(self);
1062
+
1063
+ /* Write the cellXfs element. */
1064
+ _write_cell_xfs(self);
1065
+
1066
+ /* Write the cellStyles element. */
1067
+ _write_cell_styles(self);
1068
+
1069
+ /* Write the dxfs element. */
1070
+ _write_dxfs(self);
1071
+
1072
+ /* Write the tableStyles element. */
1073
+ _write_table_styles(self);
1074
+
1075
+ /* Write the colors element. */
1076
+ /* _write_colors(self); */
1077
+
1078
+ /* Close the style sheet tag. */
1079
+ lxw_xml_end_tag(self->file, "styleSheet");
1080
+ }
1081
+
1082
+ /*****************************************************************************
1083
+ *
1084
+ * Public functions.
1085
+ *
1086
+ ****************************************************************************/