kmadej_fast_excel_fork 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.travis.yml +28 -0
  4. data/CHANGELOG.md +13 -0
  5. data/Gemfile +17 -0
  6. data/Gemfile.lock +70 -0
  7. data/Makefile +14 -0
  8. data/README.md +95 -0
  9. data/Rakefile +24 -0
  10. data/appveyor.yml +25 -0
  11. data/benchmarks/1k_rows.rb +59 -0
  12. data/benchmarks/20k_rows.rb +26 -0
  13. data/benchmarks/init.rb +59 -0
  14. data/benchmarks/memory.rb +49 -0
  15. data/examples/example.rb +42 -0
  16. data/examples/example_align.rb +23 -0
  17. data/examples/example_chart.rb +21 -0
  18. data/examples/example_colors.rb +37 -0
  19. data/examples/example_formula.rb +18 -0
  20. data/examples/example_image.rb +13 -0
  21. data/examples/example_styles.rb +27 -0
  22. data/examples/logo.png +0 -0
  23. data/extconf.rb +0 -0
  24. data/fast_excel.gemspec +20 -0
  25. data/lib/fast_excel.rb +600 -0
  26. data/lib/fast_excel/binding.rb +2819 -0
  27. data/lib/fast_excel/binding/chart.rb +2666 -0
  28. data/lib/fast_excel/binding/format.rb +1177 -0
  29. data/lib/fast_excel/binding/workbook.rb +338 -0
  30. data/lib/fast_excel/binding/worksheet.rb +1555 -0
  31. data/libxlsxwriter/.gitignore +49 -0
  32. data/libxlsxwriter/.indent.pro +125 -0
  33. data/libxlsxwriter/.travis.yml +25 -0
  34. data/libxlsxwriter/CONTRIBUTING.md +226 -0
  35. data/libxlsxwriter/Changes.txt +557 -0
  36. data/libxlsxwriter/LICENSE.txt +89 -0
  37. data/libxlsxwriter/Makefile +156 -0
  38. data/libxlsxwriter/Readme.md +78 -0
  39. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +30 -0
  40. data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +7 -0
  41. data/libxlsxwriter/include/xlsxwriter.h +23 -0
  42. data/libxlsxwriter/include/xlsxwriter/app.h +79 -0
  43. data/libxlsxwriter/include/xlsxwriter/chart.h +3476 -0
  44. data/libxlsxwriter/include/xlsxwriter/common.h +372 -0
  45. data/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
  46. data/libxlsxwriter/include/xlsxwriter/core.h +51 -0
  47. data/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
  48. data/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
  49. data/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
  50. data/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
  51. data/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
  52. data/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
  53. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
  54. data/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
  55. data/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
  56. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +214 -0
  57. data/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
  58. data/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
  59. data/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
  60. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
  61. data/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
  62. data/libxlsxwriter/include/xlsxwriter/workbook.h +757 -0
  63. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
  64. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
  65. data/libxlsxwriter/lib/.gitignore +0 -0
  66. data/libxlsxwriter/libxlsxwriter.podspec +47 -0
  67. data/libxlsxwriter/src/Makefile +130 -0
  68. data/libxlsxwriter/src/app.c +443 -0
  69. data/libxlsxwriter/src/chart.c +6346 -0
  70. data/libxlsxwriter/src/content_types.c +345 -0
  71. data/libxlsxwriter/src/core.c +293 -0
  72. data/libxlsxwriter/src/custom.c +224 -0
  73. data/libxlsxwriter/src/drawing.c +746 -0
  74. data/libxlsxwriter/src/format.c +729 -0
  75. data/libxlsxwriter/src/hash_table.c +223 -0
  76. data/libxlsxwriter/src/packager.c +948 -0
  77. data/libxlsxwriter/src/relationships.c +245 -0
  78. data/libxlsxwriter/src/shared_strings.c +266 -0
  79. data/libxlsxwriter/src/styles.c +1088 -0
  80. data/libxlsxwriter/src/theme.c +348 -0
  81. data/libxlsxwriter/src/utility.c +515 -0
  82. data/libxlsxwriter/src/workbook.c +1930 -0
  83. data/libxlsxwriter/src/worksheet.c +5022 -0
  84. data/libxlsxwriter/src/xmlwriter.c +355 -0
  85. data/libxlsxwriter/third_party/minizip/Makefile +44 -0
  86. data/libxlsxwriter/third_party/minizip/Makefile.am +45 -0
  87. data/libxlsxwriter/third_party/minizip/Makefile.orig +25 -0
  88. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +6 -0
  89. data/libxlsxwriter/third_party/minizip/MiniZip64_info.txt +74 -0
  90. data/libxlsxwriter/third_party/minizip/README.txt +5 -0
  91. data/libxlsxwriter/third_party/minizip/configure.ac +32 -0
  92. data/libxlsxwriter/third_party/minizip/crypt.h +131 -0
  93. data/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
  94. data/libxlsxwriter/third_party/minizip/ioapi.h +208 -0
  95. data/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
  96. data/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
  97. data/libxlsxwriter/third_party/minizip/make_vms.com +25 -0
  98. data/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
  99. data/libxlsxwriter/third_party/minizip/miniunzip.1 +63 -0
  100. data/libxlsxwriter/third_party/minizip/minizip.1 +46 -0
  101. data/libxlsxwriter/third_party/minizip/minizip.c +520 -0
  102. data/libxlsxwriter/third_party/minizip/minizip.pc.in +12 -0
  103. data/libxlsxwriter/third_party/minizip/mztools.c +291 -0
  104. data/libxlsxwriter/third_party/minizip/mztools.h +37 -0
  105. data/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
  106. data/libxlsxwriter/third_party/minizip/unzip.h +437 -0
  107. data/libxlsxwriter/third_party/minizip/zip.c +2007 -0
  108. data/libxlsxwriter/third_party/minizip/zip.h +367 -0
  109. data/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
  110. data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
  111. data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
  112. data/libxlsxwriter/version.txt +1 -0
  113. data/test/date_test.rb +22 -0
  114. data/test/default_format_test.rb +19 -0
  115. data/test/format_test.rb +171 -0
  116. data/test/test_helper.rb +52 -0
  117. data/test/tmpfile_test.rb +23 -0
  118. data/test/worksheet_test.rb +86 -0
  119. metadata +182 -0
@@ -0,0 +1,52 @@
1
+ /*
2
+ * libxlsxwriter
3
+ *
4
+ * Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
+ *
6
+ * custom - A libxlsxwriter library for creating Excel custom property files.
7
+ *
8
+ */
9
+ #ifndef __LXW_CUSTOM_H__
10
+ #define __LXW_CUSTOM_H__
11
+
12
+ #include <stdint.h>
13
+
14
+ #include "common.h"
15
+
16
+ /*
17
+ * Struct to represent a custom property file object.
18
+ */
19
+ typedef struct lxw_custom {
20
+
21
+ FILE *file;
22
+
23
+ struct lxw_custom_properties *custom_properties;
24
+ uint32_t pid;
25
+
26
+ } lxw_custom;
27
+
28
+
29
+ /* *INDENT-OFF* */
30
+ #ifdef __cplusplus
31
+ extern "C" {
32
+ #endif
33
+ /* *INDENT-ON* */
34
+
35
+ lxw_custom *lxw_custom_new();
36
+ void lxw_custom_free(lxw_custom *custom);
37
+ void lxw_custom_assemble_xml_file(lxw_custom *self);
38
+
39
+ /* Declarations required for unit testing. */
40
+ #ifdef TESTING
41
+
42
+ STATIC void _custom_xml_declaration(lxw_custom *self);
43
+
44
+ #endif /* TESTING */
45
+
46
+ /* *INDENT-OFF* */
47
+ #ifdef __cplusplus
48
+ }
49
+ #endif
50
+ /* *INDENT-ON* */
51
+
52
+ #endif /* __LXW_CUSTOM_H__ */
@@ -0,0 +1,111 @@
1
+ /*
2
+ * libxlsxwriter
3
+ *
4
+ * Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
+ *
6
+ * drawing - A libxlsxwriter library for creating Excel XLSX drawing files.
7
+ *
8
+ */
9
+ #ifndef __LXW_DRAWING_H__
10
+ #define __LXW_DRAWING_H__
11
+
12
+ #include <stdint.h>
13
+
14
+ #include "common.h"
15
+
16
+ STAILQ_HEAD(lxw_drawing_objects, lxw_drawing_object);
17
+
18
+ enum lxw_drawing_types {
19
+ LXW_DRAWING_NONE = 0,
20
+ LXW_DRAWING_IMAGE,
21
+ LXW_DRAWING_CHART,
22
+ LXW_DRAWING_SHAPE
23
+ };
24
+
25
+ enum lxw_anchor_types {
26
+ LXW_ANCHOR_TYPE_NONE = 0,
27
+ LXW_ANCHOR_TYPE_IMAGE,
28
+ LXW_ANCHOR_TYPE_CHART
29
+ };
30
+
31
+ enum lxw_anchor_edit_types {
32
+ LXW_ANCHOR_EDIT_AS_NONE = 0,
33
+ LXW_ANCHOR_EDIT_AS_RELATIVE,
34
+ LXW_ANCHOR_EDIT_AS_ONE_CELL,
35
+ LXW_ANCHOR_EDIT_AS_ABSOLUTE
36
+ };
37
+
38
+ enum image_types {
39
+ LXW_IMAGE_UNKNOWN = 0,
40
+ LXW_IMAGE_PNG,
41
+ LXW_IMAGE_JPEG,
42
+ LXW_IMAGE_BMP
43
+ };
44
+
45
+ /* Coordinates used in a drawing object. */
46
+ typedef struct lxw_drawing_coords {
47
+ uint32_t col;
48
+ uint32_t row;
49
+ double col_offset;
50
+ double row_offset;
51
+ } lxw_drawing_coords;
52
+
53
+ /* Object to represent the properties of a drawing. */
54
+ typedef struct lxw_drawing_object {
55
+ uint8_t anchor_type;
56
+ uint8_t edit_as;
57
+ struct lxw_drawing_coords from;
58
+ struct lxw_drawing_coords to;
59
+ uint32_t col_absolute;
60
+ uint32_t row_absolute;
61
+ uint32_t width;
62
+ uint32_t height;
63
+ uint8_t shape;
64
+ char *description;
65
+ char *url;
66
+ char *tip;
67
+
68
+ STAILQ_ENTRY (lxw_drawing_object) list_pointers;
69
+
70
+ } lxw_drawing_object;
71
+
72
+ /*
73
+ * Struct to represent a collection of drawings.
74
+ */
75
+ typedef struct lxw_drawing {
76
+
77
+ FILE *file;
78
+
79
+ uint8_t embedded;
80
+
81
+ struct lxw_drawing_objects *drawing_objects;
82
+
83
+ } lxw_drawing;
84
+
85
+
86
+ /* *INDENT-OFF* */
87
+ #ifdef __cplusplus
88
+ extern "C" {
89
+ #endif
90
+ /* *INDENT-ON* */
91
+
92
+ lxw_drawing *lxw_drawing_new();
93
+ void lxw_drawing_free(lxw_drawing *drawing);
94
+ void lxw_drawing_assemble_xml_file(lxw_drawing *self);
95
+ void lxw_free_drawing_object(struct lxw_drawing_object *drawing_object);
96
+ void lxw_add_drawing_object(lxw_drawing *drawing,
97
+ lxw_drawing_object *drawing_object);
98
+
99
+ /* Declarations required for unit testing. */
100
+ #ifdef TESTING
101
+
102
+ STATIC void _drawing_xml_declaration(lxw_drawing *self);
103
+ #endif /* TESTING */
104
+
105
+ /* *INDENT-OFF* */
106
+ #ifdef __cplusplus
107
+ }
108
+ #endif
109
+ /* *INDENT-ON* */
110
+
111
+ #endif /* __LXW_DRAWING_H__ */
@@ -0,0 +1,1214 @@
1
+ /*
2
+ * libxlsxwriter
3
+ *
4
+ * Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
+ */
6
+
7
+ /**
8
+ * @page format_page The Format object
9
+ *
10
+ * The Format object represents an the formatting properties that can be
11
+ * applied to a cell including: fonts, colors, patterns,
12
+ * borders, alignment and number formatting.
13
+ *
14
+ * See @ref format.h for full details of the functionality.
15
+ *
16
+ * @file format.h
17
+ *
18
+ * @brief Functions and properties for adding formatting to cells in Excel.
19
+ *
20
+ * This section describes the functions and properties that are available for
21
+ * formatting cells in Excel.
22
+ *
23
+ * The properties of a cell that can be formatted include: fonts, colors,
24
+ * patterns, borders, alignment and number formatting.
25
+ *
26
+ * @image html formats_intro.png
27
+ *
28
+ * Formats in `libxlsxwriter` are accessed via the lxw_format
29
+ * struct. Throughout this document these will be referred to simply as
30
+ * *Formats*.
31
+ *
32
+ * Formats are created by calling the workbook_add_format() method as
33
+ * follows:
34
+ *
35
+ * @code
36
+ * lxw_format *format = workbook_add_format(workbook);
37
+ * @endcode
38
+ *
39
+ * The members of the lxw_format struct aren't modified directly. Instead the
40
+ * format properties are set by calling the functions shown in this section.
41
+ * For example:
42
+ *
43
+ * @code
44
+ * // Create the Format.
45
+ * lxw_format *format = workbook_add_format(workbook);
46
+ *
47
+ * // Set some of the format properties.
48
+ * format_set_bold(format);
49
+ * format_set_font_color(format, LXW_COLOR_RED);
50
+ *
51
+ * // Use the format to change the text format in a cell.
52
+ * worksheet_write_string(worksheet, 0, 0, "Hello", format);
53
+ *
54
+ * @endcode
55
+ *
56
+ * The full range of formatting options that can be applied using
57
+ * `libxlsxwriter` are shown below.
58
+ *
59
+ */
60
+ #ifndef __LXW_FORMAT_H__
61
+ #define __LXW_FORMAT_H__
62
+
63
+ #include <stdint.h>
64
+ #include <string.h>
65
+ #include "hash_table.h"
66
+
67
+ #include "common.h"
68
+
69
+ /**
70
+ * @brief The type for RGB colors in libxlsxwriter.
71
+ *
72
+ * The type for RGB colors in libxlsxwriter. The valid range is `0x000000`
73
+ * (black) to `0xFFFFFF` (white). See @ref working_with_colors.
74
+ */
75
+ typedef int32_t lxw_color_t;
76
+
77
+ #define LXW_FORMAT_FIELD_LEN 128
78
+ #define LXW_DEFAULT_FONT_NAME "Calibri"
79
+ #define LXW_DEFAULT_FONT_FAMILY 2
80
+ #define LXW_DEFAULT_FONT_THEME 1
81
+ #define LXW_PROPERTY_UNSET -1
82
+ #define LXW_COLOR_UNSET -1
83
+ #define LXW_COLOR_MASK 0xFFFFFF
84
+ #define LXW_MIN_FONT_SIZE 1
85
+ #define LXW_MAX_FONT_SIZE 409
86
+
87
+ #define LXW_FORMAT_FIELD_COPY(dst, src) \
88
+ do{ \
89
+ strncpy(dst, src, LXW_FORMAT_FIELD_LEN -1); \
90
+ dst[LXW_FORMAT_FIELD_LEN - 1] = '\0'; \
91
+ } while (0)
92
+
93
+ /** Format underline values for format_set_underline(). */
94
+ enum lxw_format_underlines {
95
+ /** Single underline */
96
+ LXW_UNDERLINE_SINGLE = 1,
97
+
98
+ /** Double underline */
99
+ LXW_UNDERLINE_DOUBLE,
100
+
101
+ /** Single accounting underline */
102
+ LXW_UNDERLINE_SINGLE_ACCOUNTING,
103
+
104
+ /** Double accounting underline */
105
+ LXW_UNDERLINE_DOUBLE_ACCOUNTING
106
+ };
107
+
108
+ /** Superscript and subscript values for format_set_font_script(). */
109
+ enum lxw_format_scripts {
110
+
111
+ /** Superscript font */
112
+ LXW_FONT_SUPERSCRIPT = 1,
113
+
114
+ /** Subscript font */
115
+ LXW_FONT_SUBSCRIPT
116
+ };
117
+
118
+ /** Alignment values for format_set_align(). */
119
+ enum lxw_format_alignments {
120
+ /** No alignment. Cell will use Excel's default for the data type */
121
+ LXW_ALIGN_NONE = 0,
122
+
123
+ /** Left horizontal alignment */
124
+ LXW_ALIGN_LEFT,
125
+
126
+ /** Center horizontal alignment */
127
+ LXW_ALIGN_CENTER,
128
+
129
+ /** Right horizontal alignment */
130
+ LXW_ALIGN_RIGHT,
131
+
132
+ /** Cell fill horizontal alignment */
133
+ LXW_ALIGN_FILL,
134
+
135
+ /** Justify horizontal alignment */
136
+ LXW_ALIGN_JUSTIFY,
137
+
138
+ /** Center Across horizontal alignment */
139
+ LXW_ALIGN_CENTER_ACROSS,
140
+
141
+ /** Left horizontal alignment */
142
+ LXW_ALIGN_DISTRIBUTED,
143
+
144
+ /** Top vertical alignment */
145
+ LXW_ALIGN_VERTICAL_TOP,
146
+
147
+ /** Bottom vertical alignment */
148
+ LXW_ALIGN_VERTICAL_BOTTOM,
149
+
150
+ /** Center vertical alignment */
151
+ LXW_ALIGN_VERTICAL_CENTER,
152
+
153
+ /** Justify vertical alignment */
154
+ LXW_ALIGN_VERTICAL_JUSTIFY,
155
+
156
+ /** Distributed vertical alignment */
157
+ LXW_ALIGN_VERTICAL_DISTRIBUTED
158
+ };
159
+
160
+ enum lxw_format_diagonal_types {
161
+ LXW_DIAGONAL_BORDER_UP = 1,
162
+ LXW_DIAGONAL_BORDER_DOWN,
163
+ LXW_DIAGONAL_BORDER_UP_DOWN
164
+ };
165
+
166
+ /** Predefined values for common colors. */
167
+ enum lxw_defined_colors {
168
+ /** Black */
169
+ LXW_COLOR_BLACK = 0x1000000,
170
+
171
+ /** Blue */
172
+ LXW_COLOR_BLUE = 0x0000FF,
173
+
174
+ /** Brown */
175
+ LXW_COLOR_BROWN = 0x800000,
176
+
177
+ /** Cyan */
178
+ LXW_COLOR_CYAN = 0x00FFFF,
179
+
180
+ /** Gray */
181
+ LXW_COLOR_GRAY = 0x808080,
182
+
183
+ /** Green */
184
+ LXW_COLOR_GREEN = 0x008000,
185
+
186
+ /** Lime */
187
+ LXW_COLOR_LIME = 0x00FF00,
188
+
189
+ /** Magenta */
190
+ LXW_COLOR_MAGENTA = 0xFF00FF,
191
+
192
+ /** Navy */
193
+ LXW_COLOR_NAVY = 0x000080,
194
+
195
+ /** Orange */
196
+ LXW_COLOR_ORANGE = 0xFF6600,
197
+
198
+ /** Pink */
199
+ LXW_COLOR_PINK = 0xFF00FF,
200
+
201
+ /** Purple */
202
+ LXW_COLOR_PURPLE = 0x800080,
203
+
204
+ /** Red */
205
+ LXW_COLOR_RED = 0xFF0000,
206
+
207
+ /** Silver */
208
+ LXW_COLOR_SILVER = 0xC0C0C0,
209
+
210
+ /** White */
211
+ LXW_COLOR_WHITE = 0xFFFFFF,
212
+
213
+ /** Yellow */
214
+ LXW_COLOR_YELLOW = 0xFFFF00
215
+ };
216
+
217
+ /** Pattern value for use with format_set_pattern(). */
218
+ enum lxw_format_patterns {
219
+ /** Empty pattern */
220
+ LXW_PATTERN_NONE = 0,
221
+
222
+ /** Solid pattern */
223
+ LXW_PATTERN_SOLID,
224
+
225
+ /** Medium gray pattern */
226
+ LXW_PATTERN_MEDIUM_GRAY,
227
+
228
+ /** Dark gray pattern */
229
+ LXW_PATTERN_DARK_GRAY,
230
+
231
+ /** Light gray pattern */
232
+ LXW_PATTERN_LIGHT_GRAY,
233
+
234
+ /** Dark horizontal line pattern */
235
+ LXW_PATTERN_DARK_HORIZONTAL,
236
+
237
+ /** Dark vertical line pattern */
238
+ LXW_PATTERN_DARK_VERTICAL,
239
+
240
+ /** Dark diagonal stripe pattern */
241
+ LXW_PATTERN_DARK_DOWN,
242
+
243
+ /** Reverse dark diagonal stripe pattern */
244
+ LXW_PATTERN_DARK_UP,
245
+
246
+ /** Dark grid pattern */
247
+ LXW_PATTERN_DARK_GRID,
248
+
249
+ /** Dark trellis pattern */
250
+ LXW_PATTERN_DARK_TRELLIS,
251
+
252
+ /** Light horizontal Line pattern */
253
+ LXW_PATTERN_LIGHT_HORIZONTAL,
254
+
255
+ /** Light vertical line pattern */
256
+ LXW_PATTERN_LIGHT_VERTICAL,
257
+
258
+ /** Light diagonal stripe pattern */
259
+ LXW_PATTERN_LIGHT_DOWN,
260
+
261
+ /** Reverse light diagonal stripe pattern */
262
+ LXW_PATTERN_LIGHT_UP,
263
+
264
+ /** Light grid pattern */
265
+ LXW_PATTERN_LIGHT_GRID,
266
+
267
+ /** Light trellis pattern */
268
+ LXW_PATTERN_LIGHT_TRELLIS,
269
+
270
+ /** 12.5% gray pattern */
271
+ LXW_PATTERN_GRAY_125,
272
+
273
+ /** 6.25% gray pattern */
274
+ LXW_PATTERN_GRAY_0625
275
+ };
276
+
277
+ /** Cell border styles for use with format_set_border(). */
278
+ enum lxw_format_borders {
279
+ /** No border */
280
+ LXW_BORDER_NONE,
281
+
282
+ /** Thin border style */
283
+ LXW_BORDER_THIN,
284
+
285
+ /** Medium border style */
286
+ LXW_BORDER_MEDIUM,
287
+
288
+ /** Dashed border style */
289
+ LXW_BORDER_DASHED,
290
+
291
+ /** Dotted border style */
292
+ LXW_BORDER_DOTTED,
293
+
294
+ /** Thick border style */
295
+ LXW_BORDER_THICK,
296
+
297
+ /** Double border style */
298
+ LXW_BORDER_DOUBLE,
299
+
300
+ /** Hair border style */
301
+ LXW_BORDER_HAIR,
302
+
303
+ /** Medium dashed border style */
304
+ LXW_BORDER_MEDIUM_DASHED,
305
+
306
+ /** Dash-dot border style */
307
+ LXW_BORDER_DASH_DOT,
308
+
309
+ /** Medium dash-dot border style */
310
+ LXW_BORDER_MEDIUM_DASH_DOT,
311
+
312
+ /** Dash-dot-dot border style */
313
+ LXW_BORDER_DASH_DOT_DOT,
314
+
315
+ /** Medium dash-dot-dot border style */
316
+ LXW_BORDER_MEDIUM_DASH_DOT_DOT,
317
+
318
+ /** Slant dash-dot border style */
319
+ LXW_BORDER_SLANT_DASH_DOT
320
+ };
321
+
322
+ /**
323
+ * @brief Struct to represent the formatting properties of an Excel format.
324
+ *
325
+ * Formats in `libxlsxwriter` are accessed via this struct.
326
+ *
327
+ * The members of the lxw_format struct aren't modified directly. Instead the
328
+ * format properties are set by calling the functions shown in format.h.
329
+ *
330
+ * For example:
331
+ *
332
+ * @code
333
+ * // Create the Format.
334
+ * lxw_format *format = workbook_add_format(workbook);
335
+ *
336
+ * // Set some of the format properties.
337
+ * format_set_bold(format);
338
+ * format_set_font_color(format, LXW_COLOR_RED);
339
+ *
340
+ * // Use the format to change the text format in a cell.
341
+ * worksheet_write_string(worksheet, 0, 0, "Hello", format);
342
+ *
343
+ * @endcode
344
+ *
345
+ */
346
+ typedef struct lxw_format {
347
+
348
+ FILE *file;
349
+
350
+ lxw_hash_table *xf_format_indices;
351
+ uint16_t *num_xf_formats;
352
+
353
+ int32_t xf_index;
354
+ int32_t dxf_index;
355
+
356
+ char num_format[LXW_FORMAT_FIELD_LEN];
357
+ char font_name[LXW_FORMAT_FIELD_LEN];
358
+ char font_scheme[LXW_FORMAT_FIELD_LEN];
359
+ uint16_t num_format_index;
360
+ uint16_t font_index;
361
+ uint8_t has_font;
362
+ uint8_t has_dxf_font;
363
+ uint16_t font_size;
364
+ uint8_t bold;
365
+ uint8_t italic;
366
+ lxw_color_t font_color;
367
+ uint8_t underline;
368
+ uint8_t font_strikeout;
369
+ uint8_t font_outline;
370
+ uint8_t font_shadow;
371
+ uint8_t font_script;
372
+ uint8_t font_family;
373
+ uint8_t font_charset;
374
+ uint8_t font_condense;
375
+ uint8_t font_extend;
376
+ uint8_t theme;
377
+ uint8_t hyperlink;
378
+
379
+ uint8_t hidden;
380
+ uint8_t locked;
381
+
382
+ uint8_t text_h_align;
383
+ uint8_t text_wrap;
384
+ uint8_t text_v_align;
385
+ uint8_t text_justlast;
386
+ int16_t rotation;
387
+
388
+ lxw_color_t fg_color;
389
+ lxw_color_t bg_color;
390
+ uint8_t pattern;
391
+ uint8_t has_fill;
392
+ uint8_t has_dxf_fill;
393
+ int32_t fill_index;
394
+ int32_t fill_count;
395
+
396
+ int32_t border_index;
397
+ uint8_t has_border;
398
+ uint8_t has_dxf_border;
399
+ int32_t border_count;
400
+
401
+ uint8_t bottom;
402
+ uint8_t diag_border;
403
+ uint8_t diag_type;
404
+ uint8_t left;
405
+ uint8_t right;
406
+ uint8_t top;
407
+ lxw_color_t bottom_color;
408
+ lxw_color_t diag_color;
409
+ lxw_color_t left_color;
410
+ lxw_color_t right_color;
411
+ lxw_color_t top_color;
412
+
413
+ uint8_t indent;
414
+ uint8_t shrink;
415
+ uint8_t merge_range;
416
+ uint8_t reading_order;
417
+ uint8_t just_distrib;
418
+ uint8_t color_indexed;
419
+ uint8_t font_only;
420
+
421
+ STAILQ_ENTRY (lxw_format) list_pointers;
422
+ } lxw_format;
423
+
424
+ /*
425
+ * Struct to represent the font component of a format.
426
+ */
427
+ typedef struct lxw_font {
428
+
429
+ char font_name[LXW_FORMAT_FIELD_LEN];
430
+ uint16_t font_size;
431
+ uint8_t bold;
432
+ uint8_t italic;
433
+ uint8_t underline;
434
+ uint8_t font_strikeout;
435
+ uint8_t font_outline;
436
+ uint8_t font_shadow;
437
+ uint8_t font_script;
438
+ uint8_t font_family;
439
+ uint8_t font_charset;
440
+ uint8_t font_condense;
441
+ uint8_t font_extend;
442
+ lxw_color_t font_color;
443
+ } lxw_font;
444
+
445
+ /*
446
+ * Struct to represent the border component of a format.
447
+ */
448
+ typedef struct lxw_border {
449
+
450
+ uint8_t bottom;
451
+ uint8_t diag_border;
452
+ uint8_t diag_type;
453
+ uint8_t left;
454
+ uint8_t right;
455
+ uint8_t top;
456
+
457
+ lxw_color_t bottom_color;
458
+ lxw_color_t diag_color;
459
+ lxw_color_t left_color;
460
+ lxw_color_t right_color;
461
+ lxw_color_t top_color;
462
+
463
+ } lxw_border;
464
+
465
+ /*
466
+ * Struct to represent the fill component of a format.
467
+ */
468
+ typedef struct lxw_fill {
469
+
470
+ lxw_color_t fg_color;
471
+ lxw_color_t bg_color;
472
+ uint8_t pattern;
473
+
474
+ } lxw_fill;
475
+
476
+
477
+ /* *INDENT-OFF* */
478
+ #ifdef __cplusplus
479
+ extern "C" {
480
+ #endif
481
+ /* *INDENT-ON* */
482
+
483
+ lxw_format *lxw_format_new();
484
+ void lxw_format_free(lxw_format *format);
485
+ int32_t lxw_format_get_xf_index(lxw_format *format);
486
+ lxw_font *lxw_format_get_font_key(lxw_format *format);
487
+ lxw_border *lxw_format_get_border_key(lxw_format *format);
488
+ lxw_fill *lxw_format_get_fill_key(lxw_format *format);
489
+
490
+ lxw_color_t lxw_format_check_color(lxw_color_t color);
491
+
492
+ /**
493
+ * @brief Set the font used in the cell.
494
+ *
495
+ * @param format Pointer to a Format instance.
496
+ * @param font_name Cell font name.
497
+ *
498
+ * Specify the font used used in the cell format:
499
+ *
500
+ * @code
501
+ * format_set_font_name(format, "Avenir Black Oblique");
502
+ * @endcode
503
+ *
504
+ * @image html format_set_font_name.png
505
+ *
506
+ * Excel can only display fonts that are installed on the system that it is
507
+ * running on. Therefore it is generally best to use the fonts that come as
508
+ * standard with Excel such as Calibri, Times New Roman and Courier New.
509
+ *
510
+ * The default font in Excel 2007, and later, is Calibri.
511
+ */
512
+ void format_set_font_name(lxw_format *format, const char *font_name);
513
+
514
+ /**
515
+ * @brief Set the size of the font used in the cell.
516
+ *
517
+ * @param format Pointer to a Format instance.
518
+ * @param size The cell font size.
519
+ *
520
+ * Set the font size of the cell format:
521
+ *
522
+ * @code
523
+ * format_set_font_size(format, 30);
524
+ * @endcode
525
+ *
526
+ * @image html format_font_size.png
527
+ *
528
+ * Excel adjusts the height of a row to accommodate the largest font
529
+ * size in the row. You can also explicitly specify the height of a
530
+ * row using the worksheet_set_row() function.
531
+ */
532
+ void format_set_font_size(lxw_format *format, uint16_t size);
533
+
534
+ /**
535
+ * @brief Set the color of the font used in the cell.
536
+ *
537
+ * @param format Pointer to a Format instance.
538
+ * @param color The cell font color.
539
+ *
540
+ *
541
+ * Set the font color:
542
+ *
543
+ * @code
544
+ * format = workbook_add_format(workbook);
545
+ * format_set_font_color(format, LXW_COLOR_RED);
546
+ *
547
+ * worksheet_write_string(worksheet, 0, 0, "Wheelbarrow", format);
548
+ * @endcode
549
+ *
550
+ * @image html format_font_color.png
551
+ *
552
+ * The color should be an RGB integer value, see @ref working_with_colors.
553
+ *
554
+ * @note
555
+ * The format_set_font_color() method is used to set the font color in a
556
+ * cell. To set the color of a cell background use the format_set_bg_color()
557
+ * and format_set_pattern() methods.
558
+ */
559
+ void format_set_font_color(lxw_format *format, lxw_color_t color);
560
+
561
+ /**
562
+ * @brief Turn on bold for the format font.
563
+ *
564
+ * @param format Pointer to a Format instance.
565
+ *
566
+ * Set the bold property of the font:
567
+ *
568
+ * @code
569
+ * format = workbook_add_format(workbook);
570
+ * format_set_bold(format);
571
+ *
572
+ * worksheet_write_string(worksheet, 0, 0, "Bold Text", format);
573
+ * @endcode
574
+ *
575
+ * @image html format_font_bold.png
576
+ */
577
+ void format_set_bold(lxw_format *format);
578
+
579
+ /**
580
+ * @brief Turn on italic for the format font.
581
+ *
582
+ * @param format Pointer to a Format instance.
583
+ *
584
+ * Set the italic property of the font:
585
+ *
586
+ * @code
587
+ * format = workbook_add_format(workbook);
588
+ * format_set_italic(format);
589
+ *
590
+ * worksheet_write_string(worksheet, 0, 0, "Italic Text", format);
591
+ * @endcode
592
+ *
593
+ * @image html format_font_italic.png
594
+ */
595
+ void format_set_italic(lxw_format *format);
596
+
597
+ /**
598
+ * @brief Turn on underline for the format:
599
+ *
600
+ * @param format Pointer to a Format instance.
601
+ * @param style Underline style.
602
+ *
603
+ * Set the underline property of the format:
604
+ *
605
+ * @code
606
+ * format_set_underline(format, LXW_UNDERLINE_SINGLE);
607
+ * @endcode
608
+ *
609
+ * @image html format_font_underlined.png
610
+ *
611
+ * The available underline styles are:
612
+ *
613
+ * - #LXW_UNDERLINE_SINGLE
614
+ * - #LXW_UNDERLINE_DOUBLE
615
+ * - #LXW_UNDERLINE_SINGLE_ACCOUNTING
616
+ * - #LXW_UNDERLINE_DOUBLE_ACCOUNTING
617
+ *
618
+ */
619
+ void format_set_underline(lxw_format *format, uint8_t style);
620
+
621
+ /**
622
+ * @brief Set the strikeout property of the font.
623
+ *
624
+ * @param format Pointer to a Format instance.
625
+ *
626
+ * @image html format_font_strikeout.png
627
+ *
628
+ */
629
+ void format_set_font_strikeout(lxw_format *format);
630
+
631
+ /**
632
+ * @brief Set the superscript/subscript property of the font.
633
+ *
634
+ * @param format Pointer to a Format instance.
635
+ * @param style Superscript or subscript style.
636
+ *
637
+ * Set the superscript o subscript property of the font.
638
+ *
639
+ * @image html format_font_script.png
640
+ *
641
+ * The available script styles are:
642
+ *
643
+ * - #LXW_FONT_SUPERSCRIPT
644
+ * - #LXW_FONT_SUBSCRIPT
645
+ */
646
+ void format_set_font_script(lxw_format *format, uint8_t style);
647
+
648
+ /**
649
+ * @brief Set the number format for a cell.
650
+ *
651
+ * @param format Pointer to a Format instance.
652
+ * @param num_format The cell number format string.
653
+ *
654
+ * This method is used to define the numerical format of a number in
655
+ * Excel. It controls whether a number is displayed as an integer, a
656
+ * floating point number, a date, a currency value or some other user
657
+ * defined format.
658
+ *
659
+ * The numerical format of a cell can be specified by using a format
660
+ * string:
661
+ *
662
+ * @code
663
+ * format = workbook_add_format(workbook);
664
+ * format_set_num_format(format, "d mmm yyyy");
665
+ * @endcode
666
+ *
667
+ * Format strings can control any aspect of number formatting allowed by Excel:
668
+ *
669
+ * @dontinclude format_num_format.c
670
+ * @skipline set_num_format
671
+ * @until 1209
672
+ *
673
+ * @image html format_set_num_format.png
674
+ *
675
+ * The number system used for dates is described in @ref working_with_dates.
676
+ *
677
+ * For more information on number formats in Excel refer to the
678
+ * [Microsoft documentation on cell formats](http://office.microsoft.com/en-gb/assistance/HP051995001033.aspx).
679
+ */
680
+ void format_set_num_format(lxw_format *format, const char *num_format);
681
+
682
+ /**
683
+ * @brief Set the Excel built-in number format for a cell.
684
+ *
685
+ * @param format Pointer to a Format instance.
686
+ * @param index The built-in number format index for the cell.
687
+ *
688
+ * This function is similar to format_set_num_format() except that it takes an
689
+ * index to a limited number of Excel's built-in number formats instead of a
690
+ * user defined format string:
691
+ *
692
+ * @code
693
+ * format = workbook_add_format(workbook);
694
+ * format_set_num_format(format, 0x0F); // d-mmm-yy
695
+ * @endcode
696
+ *
697
+ * @note
698
+ * Unless you need to specifically access one of Excel's built-in number
699
+ * formats the format_set_num_format() function above is a better
700
+ * solution. The format_set_num_format_index() function is mainly included for
701
+ * backward compatibility and completeness.
702
+ *
703
+ * The Excel built-in number formats as shown in the table below:
704
+ *
705
+ * | Index | Index | Format String |
706
+ * | ----- | ----- | ---------------------------------------------------- |
707
+ * | 0 | 0x00 | `General` |
708
+ * | 1 | 0x01 | `0` |
709
+ * | 2 | 0x02 | `0.00` |
710
+ * | 3 | 0x03 | `#,##0` |
711
+ * | 4 | 0x04 | `#,##0.00` |
712
+ * | 5 | 0x05 | `($#,##0_);($#,##0)` |
713
+ * | 6 | 0x06 | `($#,##0_);[Red]($#,##0)` |
714
+ * | 7 | 0x07 | `($#,##0.00_);($#,##0.00)` |
715
+ * | 8 | 0x08 | `($#,##0.00_);[Red]($#,##0.00)` |
716
+ * | 9 | 0x09 | `0%` |
717
+ * | 10 | 0x0a | `0.00%` |
718
+ * | 11 | 0x0b | `0.00E+00` |
719
+ * | 12 | 0x0c | `# ?/?` |
720
+ * | 13 | 0x0d | `# ??/??` |
721
+ * | 14 | 0x0e | `m/d/yy` |
722
+ * | 15 | 0x0f | `d-mmm-yy` |
723
+ * | 16 | 0x10 | `d-mmm` |
724
+ * | 17 | 0x11 | `mmm-yy` |
725
+ * | 18 | 0x12 | `h:mm AM/PM` |
726
+ * | 19 | 0x13 | `h:mm:ss AM/PM` |
727
+ * | 20 | 0x14 | `h:mm` |
728
+ * | 21 | 0x15 | `h:mm:ss` |
729
+ * | 22 | 0x16 | `m/d/yy h:mm` |
730
+ * | ... | ... | ... |
731
+ * | 37 | 0x25 | `(#,##0_);(#,##0)` |
732
+ * | 38 | 0x26 | `(#,##0_);[Red](#,##0)` |
733
+ * | 39 | 0x27 | `(#,##0.00_);(#,##0.00)` |
734
+ * | 40 | 0x28 | `(#,##0.00_);[Red](#,##0.00)` |
735
+ * | 41 | 0x29 | `_(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)` |
736
+ * | 42 | 0x2a | `_($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)` |
737
+ * | 43 | 0x2b | `_(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)` |
738
+ * | 44 | 0x2c | `_($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)` |
739
+ * | 45 | 0x2d | `mm:ss` |
740
+ * | 46 | 0x2e | `[h]:mm:ss` |
741
+ * | 47 | 0x2f | `mm:ss.0` |
742
+ * | 48 | 0x30 | `##0.0E+0` |
743
+ * | 49 | 0x31 | `@` |
744
+ *
745
+ * @note
746
+ * - Numeric formats 23 to 36 are not documented by Microsoft and may differ
747
+ * in international versions. The listed date and currency formats may also
748
+ * vary depending on system settings.
749
+ * - The dollar sign in the above format appears as the defined local currency
750
+ * symbol.
751
+ * - These formats can also be set via format_set_num_format().
752
+ */
753
+ void format_set_num_format_index(lxw_format *format, uint8_t index);
754
+
755
+ /**
756
+ * @brief Set the cell unlocked state.
757
+ *
758
+ * @param format Pointer to a Format instance.
759
+ *
760
+ * This property can be used to allow modification of a cell in a protected
761
+ * worksheet. In Excel, cell locking is turned on by default for all
762
+ * cells. However, it only has an effect if the worksheet has been protected
763
+ * using the worksheet worksheet_protect() function:
764
+ *
765
+ * @code
766
+ * format = workbook_add_format(workbook);
767
+ * format_set_unlocked(format);
768
+ *
769
+ * // Enable worksheet protection, without password or options.
770
+ * worksheet_protect(worksheet, NULL, NULL);
771
+ *
772
+ * // This cell cannot be edited.
773
+ * worksheet_write_formula(worksheet, 0, 0, "=1+2", NULL);
774
+ *
775
+ * // This cell can be edited.
776
+ * worksheet_write_formula(worksheet, 1, 0, "=1+2", format);
777
+ * @endcode
778
+ */
779
+ void format_set_unlocked(lxw_format *format);
780
+
781
+ /**
782
+ * @brief Hide formulas in a cell.
783
+ *
784
+ * @param format Pointer to a Format instance.
785
+ *
786
+ * This property is used to hide a formula while still displaying its
787
+ * result. This is generally used to hide complex calculations from end users
788
+ * who are only interested in the result. It only has an effect if the
789
+ * worksheet has been protected using the worksheet worksheet_protect()
790
+ * function:
791
+ *
792
+ * @code
793
+ * format = workbook_add_format(workbook);
794
+ * format_set_hidden(format);
795
+ *
796
+ * // Enable worksheet protection, without password or options.
797
+ * worksheet_protect(worksheet, NULL, NULL);
798
+ *
799
+ * // The formula in this cell isn't visible.
800
+ * worksheet_write_formula(worksheet, 0, 0, "=1+2", format);
801
+ * @endcode
802
+ */
803
+ void format_set_hidden(lxw_format *format);
804
+
805
+ /**
806
+ * @brief Set the alignment for data in the cell.
807
+ *
808
+ * @param format Pointer to a Format instance.
809
+ * @param alignment The horizontal and or vertical alignment direction.
810
+ *
811
+ * This method is used to set the horizontal and vertical text alignment within a
812
+ * cell. The following are the available horizontal alignments:
813
+ *
814
+ * - #LXW_ALIGN_LEFT
815
+ * - #LXW_ALIGN_CENTER
816
+ * - #LXW_ALIGN_RIGHT
817
+ * - #LXW_ALIGN_FILL
818
+ * - #LXW_ALIGN_JUSTIFY
819
+ * - #LXW_ALIGN_CENTER_ACROSS
820
+ * - #LXW_ALIGN_DISTRIBUTED
821
+ *
822
+ * The following are the available vertical alignments:
823
+ *
824
+ * - #LXW_ALIGN_VERTICAL_TOP
825
+ * - #LXW_ALIGN_VERTICAL_BOTTOM
826
+ * - #LXW_ALIGN_VERTICAL_CENTER
827
+ * - #LXW_ALIGN_VERTICAL_JUSTIFY
828
+ * - #LXW_ALIGN_VERTICAL_DISTRIBUTED
829
+ *
830
+ * As in Excel, vertical and horizontal alignments can be combined:
831
+ *
832
+ * @code
833
+ * format = workbook_add_format(workbook);
834
+ *
835
+ * format_set_align(format, LXW_ALIGN_CENTER);
836
+ * format_set_align(format, LXW_ALIGN_VERTICAL_CENTER);
837
+ *
838
+ * worksheet_set_row(0, 30);
839
+ * worksheet_write_string(worksheet, 0, 0, "Some Text", format);
840
+ * @endcode
841
+ *
842
+ * @image html format_font_align.png
843
+ *
844
+ * Text can be aligned across two or more adjacent cells using the
845
+ * center_across property. However, for genuine merged cells it is better to
846
+ * use the worksheet_merge_range() worksheet method.
847
+ *
848
+ * The vertical justify option can be used to provide automatic text wrapping
849
+ * in a cell. The height of the cell will be adjusted to accommodate the
850
+ * wrapped text. To specify where the text wraps use the
851
+ * format_set_text_wrap() method.
852
+ */
853
+ void format_set_align(lxw_format *format, uint8_t alignment);
854
+
855
+ /**
856
+ * @brief Wrap text in a cell.
857
+ *
858
+ * Turn text wrapping on for text in a cell.
859
+ *
860
+ * @code
861
+ * format = workbook_add_format(workbook);
862
+ * format_set_text_wrap(format);
863
+ *
864
+ * worksheet_write_string(worksheet, 0, 0, "Some long text to wrap in a cell", format);
865
+ * @endcode
866
+ *
867
+ * If you wish to control where the text is wrapped you can add newline characters
868
+ * to the string:
869
+ *
870
+ * @code
871
+ * format = workbook_add_format(workbook);
872
+ * format_set_text_wrap(format);
873
+ *
874
+ * worksheet_write_string(worksheet, 0, 0, "It's\na bum\nwrap", format);
875
+ * @endcode
876
+ *
877
+ * @image html format_font_text_wrap.png
878
+ *
879
+ * Excel will adjust the height of the row to accommodate the wrapped text. A
880
+ * similar effect can be obtained without newlines using the
881
+ * format_set_align() function with #LXW_ALIGN_VERTICAL_JUSTIFY.
882
+ */
883
+ void format_set_text_wrap(lxw_format *format);
884
+
885
+ /**
886
+ * @brief Set the rotation of the text in a cell.
887
+ *
888
+ * @param format Pointer to a Format instance.
889
+ * @param angle Rotation angle in the range -90 to 90 and 270.
890
+ *
891
+ * Set the rotation of the text in a cell. The rotation can be any angle in the
892
+ * range -90 to 90 degrees:
893
+ *
894
+ * @code
895
+ * format = workbook_add_format(workbook);
896
+ * format_set_rotation(format, 30);
897
+ *
898
+ * worksheet_write_string(worksheet, 0, 0, "This text is rotated", format);
899
+ * @endcode
900
+ *
901
+ * @image html format_font_text_rotated.png
902
+ *
903
+ * The angle 270 is also supported. This indicates text where the letters run from
904
+ * top to bottom.
905
+ */
906
+ void format_set_rotation(lxw_format *format, int16_t angle);
907
+
908
+ /**
909
+ * @brief Set the cell text indentation level.
910
+ *
911
+ * @param format Pointer to a Format instance.
912
+ * @param level Indentation level.
913
+ *
914
+ * This method can be used to indent text in a cell. The argument, which should be
915
+ * an integer, is taken as the level of indentation:
916
+ *
917
+ * @code
918
+ * format1 = workbook_add_format(workbook);
919
+ * format2 = workbook_add_format(workbook);
920
+ *
921
+ * format_set_indent(format1, 1);
922
+ * format_set_indent(format2, 2);
923
+ *
924
+ * worksheet_write_string(worksheet, 0, 0, "This text is indented 1 level", format1);
925
+ * worksheet_write_string(worksheet, 1, 0, "This text is indented 2 levels", format2);
926
+ * @endcode
927
+ *
928
+ * @image html text_indent.png
929
+ *
930
+ * @note
931
+ * Indentation is a horizontal alignment property. It will override any other
932
+ * horizontal properties but it can be used in conjunction with vertical
933
+ * properties.
934
+ */
935
+ void format_set_indent(lxw_format *format, uint8_t level);
936
+
937
+ /**
938
+ * @brief Turn on the text "shrink to fit" for a cell.
939
+ *
940
+ * @param format Pointer to a Format instance.
941
+ *
942
+ * This method can be used to shrink text so that it fits in a cell:
943
+ *
944
+ * @code
945
+ * format = workbook_add_format(workbook);
946
+ * format_set_shrink(format);
947
+ *
948
+ * worksheet_write_string(worksheet, 0, 0, "Honey, I shrunk the text!", format);
949
+ * @endcode
950
+ */
951
+ void format_set_shrink(lxw_format *format);
952
+
953
+ /**
954
+ * @brief Set the background fill pattern for a cell
955
+ *
956
+ * @param format Pointer to a Format instance.
957
+ * @param index Pattern index.
958
+ *
959
+ * Set the background pattern for a cell.
960
+ *
961
+ * The most common pattern is a solid fill of the background color:
962
+ *
963
+ * @code
964
+ * format = workbook_add_format(workbook);
965
+ *
966
+ * format_set_pattern (format, LXW_PATTERN_SOLID);
967
+ * format_set_bg_color(format, LXW_COLOR_YELLOW);
968
+ * @endcode
969
+ *
970
+ * The available fill patterns are:
971
+ *
972
+ * Fill Type | Define
973
+ * ----------------------------- | -----------------------------
974
+ * Solid | #LXW_PATTERN_SOLID
975
+ * Medium gray | #LXW_PATTERN_MEDIUM_GRAY
976
+ * Dark gray | #LXW_PATTERN_DARK_GRAY
977
+ * Light gray | #LXW_PATTERN_LIGHT_GRAY
978
+ * Dark horizontal line | #LXW_PATTERN_DARK_HORIZONTAL
979
+ * Dark vertical line | #LXW_PATTERN_DARK_VERTICAL
980
+ * Dark diagonal stripe | #LXW_PATTERN_DARK_DOWN
981
+ * Reverse dark diagonal stripe | #LXW_PATTERN_DARK_UP
982
+ * Dark grid | #LXW_PATTERN_DARK_GRID
983
+ * Dark trellis | #LXW_PATTERN_DARK_TRELLIS
984
+ * Light horizontal line | #LXW_PATTERN_LIGHT_HORIZONTAL
985
+ * Light vertical line | #LXW_PATTERN_LIGHT_VERTICAL
986
+ * Light diagonal stripe | #LXW_PATTERN_LIGHT_DOWN
987
+ * Reverse light diagonal stripe | #LXW_PATTERN_LIGHT_UP
988
+ * Light grid | #LXW_PATTERN_LIGHT_GRID
989
+ * Light trellis | #LXW_PATTERN_LIGHT_TRELLIS
990
+ * 12.5% gray | #LXW_PATTERN_GRAY_125
991
+ * 6.25% gray | #LXW_PATTERN_GRAY_0625
992
+ *
993
+ */
994
+ void format_set_pattern(lxw_format *format, uint8_t index);
995
+
996
+ /**
997
+ * @brief Set the pattern background color for a cell.
998
+ *
999
+ * @param format Pointer to a Format instance.
1000
+ * @param color The cell pattern background color.
1001
+ *
1002
+ * The format_set_bg_color() method can be used to set the background color of
1003
+ * a pattern. Patterns are defined via the format_set_pattern() method. If a
1004
+ * pattern hasn't been defined then a solid fill pattern is used as the
1005
+ * default.
1006
+ *
1007
+ * Here is an example of how to set up a solid fill in a cell:
1008
+ *
1009
+ * @code
1010
+ * format = workbook_add_format(workbook);
1011
+ *
1012
+ * format_set_pattern (format, LXW_PATTERN_SOLID);
1013
+ * format_set_bg_color(format, LXW_COLOR_GREEN);
1014
+ *
1015
+ * worksheet_write_string(worksheet, 0, 0, "Ray", format);
1016
+ * @endcode
1017
+ *
1018
+ * @image html formats_set_bg_color.png
1019
+ *
1020
+ * The color should be an RGB integer value, see @ref working_with_colors.
1021
+ *
1022
+ */
1023
+ void format_set_bg_color(lxw_format *format, lxw_color_t color);
1024
+
1025
+ /**
1026
+ * @brief Set the pattern foreground color for a cell.
1027
+ *
1028
+ * @param format Pointer to a Format instance.
1029
+ * @param color The cell pattern foreground color.
1030
+ *
1031
+ * The format_set_fg_color() method can be used to set the foreground color of
1032
+ * a pattern.
1033
+ *
1034
+ * The color should be an RGB integer value, see @ref working_with_colors.
1035
+ *
1036
+ */
1037
+ void format_set_fg_color(lxw_format *format, lxw_color_t color);
1038
+
1039
+ /**
1040
+ * @brief Set the cell border style.
1041
+ *
1042
+ * @param format Pointer to a Format instance.
1043
+ * @param style Border style index.
1044
+ *
1045
+ * Set the cell border style:
1046
+ *
1047
+ * @code
1048
+ * format_set_border(format, LXW_BORDER_THIN);
1049
+ * @endcode
1050
+ *
1051
+ * Individual border elements can be configured using the following functions with
1052
+ * the same parameters:
1053
+ *
1054
+ * - format_set_bottom()
1055
+ * - format_set_top()
1056
+ * - format_set_left()
1057
+ * - format_set_right()
1058
+ *
1059
+ * A cell border is comprised of a border on the bottom, top, left and right.
1060
+ * These can be set to the same value using format_set_border() or
1061
+ * individually using the relevant method calls shown above.
1062
+ *
1063
+ * The following border styles are available:
1064
+ *
1065
+ * - #LXW_BORDER_THIN
1066
+ * - #LXW_BORDER_MEDIUM
1067
+ * - #LXW_BORDER_DASHED
1068
+ * - #LXW_BORDER_DOTTED
1069
+ * - #LXW_BORDER_THICK
1070
+ * - #LXW_BORDER_DOUBLE
1071
+ * - #LXW_BORDER_HAIR
1072
+ * - #LXW_BORDER_MEDIUM_DASHED
1073
+ * - #LXW_BORDER_DASH_DOT
1074
+ * - #LXW_BORDER_MEDIUM_DASH_DOT
1075
+ * - #LXW_BORDER_DASH_DOT_DOT
1076
+ * - #LXW_BORDER_MEDIUM_DASH_DOT_DOT
1077
+ * - #LXW_BORDER_SLANT_DASH_DOT
1078
+ *
1079
+ * The most commonly used style is the `thin` style.
1080
+ */
1081
+ void format_set_border(lxw_format *format, uint8_t style);
1082
+
1083
+ /**
1084
+ * @brief Set the cell bottom border style.
1085
+ *
1086
+ * @param format Pointer to a Format instance.
1087
+ * @param style Border style index.
1088
+ *
1089
+ * Set the cell bottom border style. See format_set_border() for details on the
1090
+ * border styles.
1091
+ */
1092
+ void format_set_bottom(lxw_format *format, uint8_t style);
1093
+
1094
+ /**
1095
+ * @brief Set the cell top border style.
1096
+ *
1097
+ * @param format Pointer to a Format instance.
1098
+ * @param style Border style index.
1099
+ *
1100
+ * Set the cell top border style. See format_set_border() for details on the border
1101
+ * styles.
1102
+ */
1103
+ void format_set_top(lxw_format *format, uint8_t style);
1104
+
1105
+ /**
1106
+ * @brief Set the cell left border style.
1107
+ *
1108
+ * @param format Pointer to a Format instance.
1109
+ * @param style Border style index.
1110
+ *
1111
+ * Set the cell left border style. See format_set_border() for details on the
1112
+ * border styles.
1113
+ */
1114
+ void format_set_left(lxw_format *format, uint8_t style);
1115
+
1116
+ /**
1117
+ * @brief Set the cell right border style.
1118
+ *
1119
+ * @param format Pointer to a Format instance.
1120
+ * @param style Border style index.
1121
+ *
1122
+ * Set the cell right border style. See format_set_border() for details on the
1123
+ * border styles.
1124
+ */
1125
+ void format_set_right(lxw_format *format, uint8_t style);
1126
+
1127
+ /**
1128
+ * @brief Set the color of the cell border.
1129
+ *
1130
+ * @param format Pointer to a Format instance.
1131
+ * @param color The cell border color.
1132
+ *
1133
+ * Individual border elements can be configured using the following methods with
1134
+ * the same parameters:
1135
+ *
1136
+ * - format_set_bottom_color()
1137
+ * - format_set_top_color()
1138
+ * - format_set_left_color()
1139
+ * - format_set_right_color()
1140
+ *
1141
+ * Set the color of the cell borders. A cell border is comprised of a border
1142
+ * on the bottom, top, left and right. These can be set to the same color
1143
+ * using format_set_border_color() or individually using the relevant method
1144
+ * calls shown above.
1145
+ *
1146
+ * The color should be an RGB integer value, see @ref working_with_colors.
1147
+ */
1148
+ void format_set_border_color(lxw_format *format, lxw_color_t color);
1149
+
1150
+ /**
1151
+ * @brief Set the color of the bottom cell border.
1152
+ *
1153
+ * @param format Pointer to a Format instance.
1154
+ * @param color The cell border color.
1155
+ *
1156
+ * See format_set_border_color() for details on the border colors.
1157
+ */
1158
+ void format_set_bottom_color(lxw_format *format, lxw_color_t color);
1159
+
1160
+ /**
1161
+ * @brief Set the color of the top cell border.
1162
+ *
1163
+ * @param format Pointer to a Format instance.
1164
+ * @param color The cell border color.
1165
+ *
1166
+ * See format_set_border_color() for details on the border colors.
1167
+ */
1168
+ void format_set_top_color(lxw_format *format, lxw_color_t color);
1169
+
1170
+ /**
1171
+ * @brief Set the color of the left cell border.
1172
+ *
1173
+ * @param format Pointer to a Format instance.
1174
+ * @param color The cell border color.
1175
+ *
1176
+ * See format_set_border_color() for details on the border colors.
1177
+ */
1178
+ void format_set_left_color(lxw_format *format, lxw_color_t color);
1179
+
1180
+ /**
1181
+ * @brief Set the color of the right cell border.
1182
+ *
1183
+ * @param format Pointer to a Format instance.
1184
+ * @param color The cell border color.
1185
+ *
1186
+ * See format_set_border_color() for details on the border colors.
1187
+ */
1188
+ void format_set_right_color(lxw_format *format, lxw_color_t color);
1189
+
1190
+ void format_set_diag_type(lxw_format *format, uint8_t value);
1191
+ void format_set_diag_color(lxw_format *format, lxw_color_t color);
1192
+ void format_set_diag_border(lxw_format *format, uint8_t value);
1193
+ void format_set_font_outline(lxw_format *format);
1194
+ void format_set_font_shadow(lxw_format *format);
1195
+ void format_set_font_family(lxw_format *format, uint8_t value);
1196
+ void format_set_font_charset(lxw_format *format, uint8_t value);
1197
+ void format_set_font_scheme(lxw_format *format, const char *font_scheme);
1198
+ void format_set_font_condense(lxw_format *format);
1199
+ void format_set_font_extend(lxw_format *format);
1200
+ void format_set_reading_order(lxw_format *format, uint8_t value);
1201
+ void format_set_theme(lxw_format *format, uint8_t value);
1202
+
1203
+ /* Declarations required for unit testing. */
1204
+ #ifdef TESTING
1205
+
1206
+ #endif /* TESTING */
1207
+
1208
+ /* *INDENT-OFF* */
1209
+ #ifdef __cplusplus
1210
+ }
1211
+ #endif
1212
+ /* *INDENT-ON* */
1213
+
1214
+ #endif /* __LXW_FORMAT_H__ */