fast_excel 0.4.1 → 0.5.0

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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -7
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +1 -1
  5. data/examples/example.rb +2 -0
  6. data/examples/example_date_time.rb +38 -0
  7. data/fast_excel.gemspec +2 -2
  8. data/lib/fast_excel/binding/format.rb +17 -0
  9. data/lib/fast_excel/binding/workbook.rb +39 -17
  10. data/lib/fast_excel/binding/worksheet.rb +57 -13
  11. data/lib/fast_excel/binding.rb +7 -7
  12. data/lib/fast_excel.rb +27 -20
  13. data/libxlsxwriter/.github/FUNDING.yml +1 -0
  14. data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
  15. data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
  16. data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
  17. data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
  18. data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
  19. data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
  20. data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
  21. data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
  22. data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
  23. data/libxlsxwriter/.gitignore +16 -1
  24. data/libxlsxwriter/.indent.pro +24 -0
  25. data/libxlsxwriter/CMakeLists.txt +156 -56
  26. data/libxlsxwriter/CONTRIBUTING.md +2 -2
  27. data/libxlsxwriter/Changes.txt +344 -2
  28. data/libxlsxwriter/LICENSE.txt +66 -8
  29. data/libxlsxwriter/Makefile +151 -54
  30. data/libxlsxwriter/Package.swift +42 -0
  31. data/libxlsxwriter/Readme.md +4 -2
  32. data/libxlsxwriter/build.zig +324 -0
  33. data/libxlsxwriter/build.zig.zon +11 -0
  34. data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
  35. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
  36. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  37. data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
  38. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
  39. data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  40. data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
  41. data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
  42. data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  43. data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  44. data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
  45. data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
  46. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  47. data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
  48. data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
  49. data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  50. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  51. data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
  52. data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
  53. data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  54. data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
  55. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
  56. data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
  57. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
  58. data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
  59. data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  60. data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
  61. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
  62. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
  63. data/libxlsxwriter/include/xlsxwriter.h +4 -2
  64. data/libxlsxwriter/libxlsxwriter.podspec +8 -5
  65. data/libxlsxwriter/src/Makefile +58 -21
  66. data/libxlsxwriter/src/app.c +5 -2
  67. data/libxlsxwriter/src/chart.c +396 -81
  68. data/libxlsxwriter/src/chartsheet.c +22 -22
  69. data/libxlsxwriter/src/comment.c +443 -0
  70. data/libxlsxwriter/src/content_types.c +40 -1
  71. data/libxlsxwriter/src/core.c +2 -2
  72. data/libxlsxwriter/src/custom.c +1 -1
  73. data/libxlsxwriter/src/drawing.c +160 -40
  74. data/libxlsxwriter/src/format.c +109 -25
  75. data/libxlsxwriter/src/hash_table.c +1 -1
  76. data/libxlsxwriter/src/metadata.c +283 -0
  77. data/libxlsxwriter/src/packager.c +794 -94
  78. data/libxlsxwriter/src/relationships.c +1 -1
  79. data/libxlsxwriter/src/shared_strings.c +2 -4
  80. data/libxlsxwriter/src/styles.c +353 -58
  81. data/libxlsxwriter/src/table.c +304 -0
  82. data/libxlsxwriter/src/theme.c +1 -1
  83. data/libxlsxwriter/src/utility.c +143 -43
  84. data/libxlsxwriter/src/vml.c +1062 -0
  85. data/libxlsxwriter/src/workbook.c +567 -77
  86. data/libxlsxwriter/src/worksheet.c +6668 -1462
  87. data/libxlsxwriter/src/xmlwriter.c +95 -5
  88. data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
  89. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
  90. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
  91. data/libxlsxwriter/third_party/md5/Makefile +42 -0
  92. data/libxlsxwriter/third_party/md5/md5.c +291 -0
  93. data/libxlsxwriter/third_party/md5/md5.h +45 -0
  94. data/libxlsxwriter/third_party/minizip/Makefile +3 -8
  95. data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
  96. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
  97. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  98. data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
  99. data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
  100. data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
  101. data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
  102. data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
  103. data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
  104. data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
  105. data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
  106. data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
  107. data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
  108. data/libxlsxwriter/third_party/minizip/zip.c +165 -218
  109. data/libxlsxwriter/third_party/minizip/zip.h +164 -154
  110. data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
  111. data/libxlsxwriter/version.txt +1 -1
  112. data/test/auto_width_test.rb +20 -0
  113. data/test/default_format_test.rb +1 -1
  114. data/test/validations_test.rb +3 -3
  115. data/test/worksheet_test.rb +6 -1
  116. metadata +33 -7
  117. data/libxlsxwriter/.travis.yml +0 -37
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  */
6
6
 
7
7
  /**
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @brief Common functions and defines for the libxlsxwriter library.
11
11
  *
12
- * <!-- Copyright 2014-2019, John McNamara, jmcnamara@cpan.org -->
12
+ * <!-- Copyright 2014-2022, John McNamara, jmcnamara@cpan.org -->
13
13
  *
14
14
  */
15
15
  #ifndef __LXW_COMMON_H__
@@ -25,6 +25,14 @@
25
25
  #define STATIC
26
26
  #endif
27
27
 
28
+ #if __GNUC__ >= 5
29
+ #define DEPRECATED(func, msg) func __attribute__ ((deprecated(msg)))
30
+ #elif defined(_MSC_VER)
31
+ #define DEPRECATED(func, msg) __declspec(deprecated, msg) func
32
+ #else
33
+ #define DEPRECATED(func, msg) func
34
+ #endif
35
+
28
36
  /** Integer data type to represent a row value. Equivalent to `uint32_t`.
29
37
  *
30
38
  * The maximum row in Excel is 1,048,576.
@@ -42,7 +50,10 @@ enum lxw_boolean {
42
50
  /** False value. */
43
51
  LXW_FALSE,
44
52
  /** True value. */
45
- LXW_TRUE
53
+ LXW_TRUE,
54
+ /** False value. Used to turn off a property that is default on, in order
55
+ * to distinguish it from an uninitialized value. */
56
+ LXW_EXPLICIT_FALSE
46
57
  };
47
58
 
48
59
  /**
@@ -86,6 +97,9 @@ typedef enum lxw_error {
86
97
  /** Unknown zip error when closing xlsx file. */
87
98
  LXW_ERROR_ZIP_CLOSE,
88
99
 
100
+ /** Feature is not currently supported in this configuration. */
101
+ LXW_ERROR_FEATURE_NOT_SUPPORTED,
102
+
89
103
  /** NULL function parameter ignored. */
90
104
  LXW_ERROR_NULL_PARAMETER_IGNORED,
91
105
 
@@ -104,9 +118,6 @@ typedef enum lxw_error {
104
118
  /** Worksheet name is already in use. */
105
119
  LXW_ERROR_SHEETNAME_ALREADY_USED,
106
120
 
107
- /** Worksheet name 'History' is reserved by Excel. */
108
- LXW_ERROR_SHEETNAME_RESERVED,
109
-
110
121
  /** Parameter exceeds Excel's limit of 32 characters. */
111
122
  LXW_ERROR_32_STRING_LENGTH_EXCEEDED,
112
123
 
@@ -125,6 +136,9 @@ typedef enum lxw_error {
125
136
  /** Worksheet row or column index out of range. */
126
137
  LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE,
127
138
 
139
+ /** Maximum hyperlink length (2079) exceeded. */
140
+ LXW_ERROR_WORKSHEET_MAX_URL_LENGTH_EXCEEDED,
141
+
128
142
  /** Maximum number of worksheet URLs (65530) exceeded. */
129
143
  LXW_ERROR_WORKSHEET_MAX_NUMBER_URLS_EXCEEDED,
130
144
 
@@ -164,6 +178,9 @@ enum lxw_custom_property_types {
164
178
  LXW_CUSTOM_DATETIME
165
179
  };
166
180
 
181
+ /* Size of MD5 byte arrays. */
182
+ #define LXW_MD5_SIZE 16
183
+
167
184
  /* Excel sheetname max of 31 chars. */
168
185
  #define LXW_SHEETNAME_MAX 31
169
186
 
@@ -188,6 +205,9 @@ enum lxw_custom_property_types {
188
205
  /* Datetime string length. */
189
206
  #define LXW_DATETIME_LENGTH sizeof("2016-12-12T23:00:00Z")
190
207
 
208
+ /* GUID string length. */
209
+ #define LXW_GUID_LENGTH sizeof("{12345678-1234-1234-1234-1234567890AB}\0")
210
+
191
211
  #define LXW_EPOCH_1900 0
192
212
  #define LXW_EPOCH_1904 1
193
213
 
@@ -206,93 +226,134 @@ enum lxw_custom_property_types {
206
226
  #define LXW_SCHEMA_DOCUMENT LXW_SCHEMA_ROOT "/officeDocument/2006/relationships"
207
227
  #define LXW_SCHEMA_CONTENT LXW_SCHEMA_ROOT "/package/2006/content-types"
208
228
 
229
+ /* Use REprintf() for error handling when compiled as an R library. */
230
+ #ifdef USE_R_LANG
231
+ #include <R.h>
232
+ #define LXW_PRINTF REprintf
233
+ #define LXW_STDERR
234
+ #else
235
+ #define LXW_PRINTF fprintf
236
+ #define LXW_STDERR stderr,
237
+ #endif
238
+
209
239
  #define LXW_ERROR(message) \
210
- fprintf(stderr, "[ERROR][%s:%d]: " message "\n", __FILE__, __LINE__)
240
+ LXW_PRINTF(LXW_STDERR "[ERROR][%s:%d]: " message "\n", __FILE__, __LINE__)
211
241
 
212
242
  #define LXW_MEM_ERROR() \
213
243
  LXW_ERROR("Memory allocation failed.")
214
244
 
215
245
  #define GOTO_LABEL_ON_MEM_ERROR(pointer, label) \
216
- if (!pointer) { \
217
- LXW_MEM_ERROR(); \
218
- goto label; \
219
- }
246
+ do { \
247
+ if (!pointer) { \
248
+ LXW_MEM_ERROR(); \
249
+ goto label; \
250
+ } \
251
+ } while (0)
220
252
 
221
253
  #define RETURN_ON_MEM_ERROR(pointer, error) \
222
- if (!pointer) { \
223
- LXW_MEM_ERROR(); \
224
- return error; \
225
- }
254
+ do { \
255
+ if (!pointer) { \
256
+ LXW_MEM_ERROR(); \
257
+ return error; \
258
+ } \
259
+ } while (0)
226
260
 
227
261
  #define RETURN_VOID_ON_MEM_ERROR(pointer) \
228
- if (!pointer) { \
229
- LXW_MEM_ERROR(); \
230
- return; \
231
- }
262
+ do { \
263
+ if (!pointer) { \
264
+ LXW_MEM_ERROR(); \
265
+ return; \
266
+ } \
267
+ } while (0)
232
268
 
233
269
  #define RETURN_ON_ERROR(error) \
234
- if (error) \
235
- return error;
270
+ do { \
271
+ if (error) \
272
+ return error; \
273
+ } while (0)
274
+
275
+ #define RETURN_AND_ZIPCLOSE_ON_ERROR(error) \
276
+ do { \
277
+ if (error) { \
278
+ zipClose(self->zipfile, NULL); \
279
+ return error; \
280
+ } \
281
+ } while (0)
236
282
 
237
283
  #define LXW_WARN(message) \
238
- fprintf(stderr, "[WARNING]: " message "\n")
284
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n")
239
285
 
240
286
  /* We can't use variadic macros here since we support ANSI C. */
241
287
  #define LXW_WARN_FORMAT(message) \
242
- fprintf(stderr, "[WARNING]: " message "\n")
288
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n")
243
289
 
244
290
  #define LXW_WARN_FORMAT1(message, var) \
245
- fprintf(stderr, "[WARNING]: " message "\n", var)
291
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n", var)
246
292
 
247
293
  #define LXW_WARN_FORMAT2(message, var1, var2) \
248
- fprintf(stderr, "[WARNING]: " message "\n", var1, var2)
294
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n", var1, var2)
295
+
296
+ #define LXW_WARN_FORMAT3(message, var1, var2, var3) \
297
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n", var1, var2, var3)
249
298
 
250
299
  /* Chart axis type checks. */
251
300
  #define LXW_WARN_CAT_AXIS_ONLY(function) \
252
- if (!axis->is_category) { \
253
- fprintf(stderr, "[WARNING]: " \
254
- function "() is only valid for category axes\n"); \
255
- return; \
256
- }
301
+ do { \
302
+ if (!axis->is_category) { \
303
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " \
304
+ function "() is only valid for category axes\n"); \
305
+ return; \
306
+ } \
307
+ } while (0)
257
308
 
258
309
  #define LXW_WARN_VALUE_AXIS_ONLY(function) \
259
- if (!axis->is_value) { \
260
- fprintf(stderr, "[WARNING]: " \
310
+ do { \
311
+ if (!axis->is_value) { \
312
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " \
261
313
  function "() is only valid for value axes\n"); \
262
- return; \
263
- }
314
+ return; \
315
+ } \
316
+ } while (0)
264
317
 
265
318
  #define LXW_WARN_DATE_AXIS_ONLY(function) \
266
- if (!axis->is_date) { \
267
- fprintf(stderr, "[WARNING]: " \
268
- function "() is only valid for date axes\n"); \
269
- return; \
270
- }
319
+ do { \
320
+ if (!axis->is_date) { \
321
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " \
322
+ function "() is only valid for date axes\n"); \
323
+ return; \
324
+ } \
325
+ } while (0)
271
326
 
272
327
  #define LXW_WARN_CAT_AND_DATE_AXIS_ONLY(function) \
273
- if (!axis->is_category && !axis->is_date) { \
274
- fprintf(stderr, "[WARNING]: " \
328
+ do { \
329
+ if (!axis->is_category && !axis->is_date) { \
330
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " \
275
331
  function "() is only valid for category and date axes\n"); \
276
- return; \
277
- }
332
+ return; \
333
+ } \
334
+ } while (0)
278
335
 
279
336
  #define LXW_WARN_VALUE_AND_DATE_AXIS_ONLY(function) \
280
- if (!axis->is_value && !axis->is_date) { \
281
- fprintf(stderr, "[WARNING]: " \
337
+ do { \
338
+ if (!axis->is_value && !axis->is_date) { \
339
+ LXW_PRINTF(LXW_STDERR "[WARNING]: " \
282
340
  function "() is only valid for value and date axes\n"); \
283
- return; \
284
- }
341
+ return; \
342
+ } \
343
+ } while (0)
285
344
 
286
345
  #ifndef LXW_BIG_ENDIAN
346
+ #define LXW_UINT16_HOST(n) (n)
347
+ #define LXW_UINT32_HOST(n) (n)
348
+ #define LXW_UINT16_NETWORK(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
287
349
  #define LXW_UINT32_NETWORK(n) ((((n) & 0xFF) << 24) | \
288
350
  (((n) & 0xFF00) << 8) | \
289
351
  (((n) & 0xFF0000) >> 8) | \
290
352
  (((n) & 0xFF000000) >> 24))
291
- #define LXW_UINT16_NETWORK(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
292
- #define LXW_UINT32_HOST(n) (n)
293
353
  #else
294
- #define LXW_UINT32_NETWORK(n) (n)
295
354
  #define LXW_UINT16_NETWORK(n) (n)
355
+ #define LXW_UINT32_NETWORK(n) (n)
356
+ #define LXW_UINT16_HOST(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
296
357
  #define LXW_UINT32_HOST(n) ((((n) & 0xFF) << 24) | \
297
358
  (((n) & 0xFF00) << 8) | \
298
359
  (((n) & 0xFF0000) >> 8) | \
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * content_types - A libxlsxwriter library for creating Excel XLSX
7
7
  * content_types files.
@@ -53,9 +53,16 @@ void lxw_ct_add_chart_name(lxw_content_types *content_types,
53
53
  const char *name);
54
54
  void lxw_ct_add_drawing_name(lxw_content_types *content_types,
55
55
  const char *name);
56
+ void lxw_ct_add_table_name(lxw_content_types *content_types,
57
+ const char *name);
58
+ void lxw_ct_add_comment_name(lxw_content_types *content_types,
59
+ const char *name);
60
+ void lxw_ct_add_vml_name(lxw_content_types *content_types);
61
+
56
62
  void lxw_ct_add_shared_strings(lxw_content_types *content_types);
57
63
  void lxw_ct_add_calc_chain(lxw_content_types *content_types);
58
64
  void lxw_ct_add_custom_properties(lxw_content_types *content_types);
65
+ void lxw_ct_add_metadata(lxw_content_types *content_types);
59
66
 
60
67
  /* Declarations required for unit testing. */
61
68
  #ifdef TESTING
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * core - A libxlsxwriter library for creating Excel XLSX core files.
7
7
  *
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * custom - A libxlsxwriter library for creating Excel custom property files.
7
7
  *
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * drawing - A libxlsxwriter library for creating Excel XLSX drawing files.
7
7
  *
@@ -10,6 +10,7 @@
10
10
  #define __LXW_DRAWING_H__
11
11
 
12
12
  #include <stdint.h>
13
+ #include <string.h>
13
14
 
14
15
  #include "common.h"
15
16
 
@@ -22,24 +23,12 @@ enum lxw_drawing_types {
22
23
  LXW_DRAWING_SHAPE
23
24
  };
24
25
 
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
26
  enum image_types {
39
27
  LXW_IMAGE_UNKNOWN = 0,
40
28
  LXW_IMAGE_PNG,
41
29
  LXW_IMAGE_JPEG,
42
- LXW_IMAGE_BMP
30
+ LXW_IMAGE_BMP,
31
+ LXW_IMAGE_GIF
43
32
  };
44
33
 
45
34
  /* Coordinates used in a drawing object. */
@@ -52,18 +41,20 @@ typedef struct lxw_drawing_coords {
52
41
 
53
42
  /* Object to represent the properties of a drawing. */
54
43
  typedef struct lxw_drawing_object {
55
- uint8_t anchor_type;
56
- uint8_t edit_as;
44
+ uint8_t type;
45
+ uint8_t anchor;
57
46
  struct lxw_drawing_coords from;
58
47
  struct lxw_drawing_coords to;
59
- uint32_t col_absolute;
60
- uint32_t row_absolute;
48
+ uint64_t col_absolute;
49
+ uint64_t row_absolute;
61
50
  uint32_t width;
62
51
  uint32_t height;
63
52
  uint8_t shape;
53
+ uint32_t rel_index;
54
+ uint32_t url_rel_index;
64
55
  char *description;
65
- char *url;
66
56
  char *tip;
57
+ uint8_t decorative;
67
58
 
68
59
  STAILQ_ENTRY (lxw_drawing_object) list_pointers;
69
60
 
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  */
6
6
 
7
7
  /**
@@ -72,14 +72,14 @@
72
72
  * The type for RGB colors in libxlsxwriter. The valid range is `0x000000`
73
73
  * (black) to `0xFFFFFF` (white). See @ref working_with_colors.
74
74
  */
75
- typedef int32_t lxw_color_t;
75
+ typedef uint32_t lxw_color_t;
76
76
 
77
77
  #define LXW_FORMAT_FIELD_LEN 128
78
78
  #define LXW_DEFAULT_FONT_NAME "Calibri"
79
79
  #define LXW_DEFAULT_FONT_FAMILY 2
80
80
  #define LXW_DEFAULT_FONT_THEME 1
81
81
  #define LXW_PROPERTY_UNSET -1
82
- #define LXW_COLOR_UNSET -1
82
+ #define LXW_COLOR_UNSET 0x000000
83
83
  #define LXW_COLOR_MASK 0xFFFFFF
84
84
  #define LXW_MIN_FONT_SIZE 1.0
85
85
  #define LXW_MAX_FONT_SIZE 409.0
@@ -92,8 +92,10 @@ typedef int32_t lxw_color_t;
92
92
 
93
93
  /** Format underline values for format_set_underline(). */
94
94
  enum lxw_format_underlines {
95
+ LXW_UNDERLINE_NONE = 0,
96
+
95
97
  /** Single underline */
96
- LXW_UNDERLINE_SINGLE = 1,
98
+ LXW_UNDERLINE_SINGLE,
97
99
 
98
100
  /** Double underline */
99
101
  LXW_UNDERLINE_DOUBLE,
@@ -157,9 +159,19 @@ enum lxw_format_alignments {
157
159
  LXW_ALIGN_VERTICAL_DISTRIBUTED
158
160
  };
159
161
 
162
+ /**
163
+ * Diagonal border types.
164
+ *
165
+ */
160
166
  enum lxw_format_diagonal_types {
167
+
168
+ /** Cell diagonal border from bottom left to top right. */
161
169
  LXW_DIAGONAL_BORDER_UP = 1,
170
+
171
+ /** Cell diagonal border from top left to bottom right. */
162
172
  LXW_DIAGONAL_BORDER_DOWN,
173
+
174
+ /** Cell diagonal border in both directions. */
163
175
  LXW_DIAGONAL_BORDER_UP_DOWN
164
176
  };
165
177
 
@@ -348,10 +360,13 @@ typedef struct lxw_format {
348
360
  FILE *file;
349
361
 
350
362
  lxw_hash_table *xf_format_indices;
363
+ lxw_hash_table *dxf_format_indices;
351
364
  uint16_t *num_xf_formats;
365
+ uint16_t *num_dxf_formats;
352
366
 
353
367
  int32_t xf_index;
354
368
  int32_t dxf_index;
369
+ int32_t xf_id;
355
370
 
356
371
  char num_format[LXW_FORMAT_FIELD_LEN];
357
372
  char font_name[LXW_FORMAT_FIELD_LEN];
@@ -387,6 +402,8 @@ typedef struct lxw_format {
387
402
 
388
403
  lxw_color_t fg_color;
389
404
  lxw_color_t bg_color;
405
+ lxw_color_t dxf_fg_color;
406
+ lxw_color_t dxf_bg_color;
390
407
  uint8_t pattern;
391
408
  uint8_t has_fill;
392
409
  uint8_t has_dxf_fill;
@@ -418,6 +435,8 @@ typedef struct lxw_format {
418
435
  uint8_t color_indexed;
419
436
  uint8_t font_only;
420
437
 
438
+ uint8_t quote_prefix;
439
+
421
440
  STAILQ_ENTRY (lxw_format) list_pointers;
422
441
  } lxw_format;
423
442
 
@@ -431,6 +450,7 @@ typedef struct lxw_font {
431
450
  uint8_t bold;
432
451
  uint8_t italic;
433
452
  uint8_t underline;
453
+ uint8_t theme;
434
454
  uint8_t font_strikeout;
435
455
  uint8_t font_outline;
436
456
  uint8_t font_shadow;
@@ -483,12 +503,11 @@ extern "C" {
483
503
  lxw_format *lxw_format_new(void);
484
504
  void lxw_format_free(lxw_format *format);
485
505
  int32_t lxw_format_get_xf_index(lxw_format *format);
506
+ int32_t lxw_format_get_dxf_index(lxw_format *format);
486
507
  lxw_font *lxw_format_get_font_key(lxw_format *format);
487
508
  lxw_border *lxw_format_get_border_key(lxw_format *format);
488
509
  lxw_fill *lxw_format_get_fill_key(lxw_format *format);
489
510
 
490
- lxw_color_t lxw_format_check_color(lxw_color_t color);
491
-
492
511
  /**
493
512
  * @brief Set the font used in the cell.
494
513
  *
@@ -672,6 +691,9 @@ void format_set_font_script(lxw_format *format, uint8_t style);
672
691
  *
673
692
  * @image html format_set_num_format.png
674
693
  *
694
+ * To set a number format that matches an Excel format category such as "Date"
695
+ * or "Currency" see @ref ww_formats_categories.
696
+ *
675
697
  * The number system used for dates is described in @ref working_with_dates.
676
698
  *
677
699
  * For more information on number formats in Excel refer to the
@@ -749,6 +771,7 @@ void format_set_num_format(lxw_format *format, const char *num_format);
749
771
  * - The dollar sign in the above format appears as the defined local currency
750
772
  * symbol.
751
773
  * - These formats can also be set via format_set_num_format().
774
+ * - See also @ref ww_formats_categories.
752
775
  */
753
776
  void format_set_num_format_index(lxw_format *format, uint8_t index);
754
777
 
@@ -1187,9 +1210,96 @@ void format_set_left_color(lxw_format *format, lxw_color_t color);
1187
1210
  */
1188
1211
  void format_set_right_color(lxw_format *format, lxw_color_t color);
1189
1212
 
1190
- void format_set_diag_type(lxw_format *format, uint8_t value);
1213
+ /**
1214
+ * @brief Set the diagonal cell border type.
1215
+ *
1216
+ * @param format Pointer to a Format instance.
1217
+ * @param type The #lxw_format_diagonal_types diagonal border type.
1218
+ *
1219
+ * Set the diagonal cell border type:
1220
+ *
1221
+ * @code
1222
+ * lxw_format *format1 = workbook_add_format(workbook);
1223
+ * format_set_diag_type( format1, LXW_DIAGONAL_BORDER_UP);
1224
+ *
1225
+ * lxw_format *format2 = workbook_add_format(workbook);
1226
+ * format_set_diag_type( format2, LXW_DIAGONAL_BORDER_DOWN);
1227
+ *
1228
+ * lxw_format *format3 = workbook_add_format(workbook);
1229
+ * format_set_diag_type( format3, LXW_DIAGONAL_BORDER_UP_DOWN);
1230
+ *
1231
+ * lxw_format *format4 = workbook_add_format(workbook);
1232
+ * format_set_diag_type( format4, LXW_DIAGONAL_BORDER_UP_DOWN);
1233
+ * format_set_diag_border(format4, LXW_BORDER_HAIR);
1234
+ * format_set_diag_color( format4, LXW_COLOR_RED);
1235
+ *
1236
+ * worksheet_write_string(worksheet, CELL("B3"), "Text", format1);
1237
+ * worksheet_write_string(worksheet, CELL("B6"), "Text", format2);
1238
+ * worksheet_write_string(worksheet, CELL("B9"), "Text", format3);
1239
+ * worksheet_write_string(worksheet, CELL("B12"), "Text", format4);
1240
+ * @endcode
1241
+ *
1242
+ * @image html diagonal_border.png
1243
+ *
1244
+ * The allowable border types are defined in #lxw_format_diagonal_types:
1245
+ *
1246
+ * - #LXW_DIAGONAL_BORDER_UP: Cell diagonal border from bottom left to top
1247
+ * right.
1248
+ *
1249
+ * - #LXW_DIAGONAL_BORDER_DOWN: Cell diagonal border from top left to bottom
1250
+ * right.
1251
+ *
1252
+ * - #LXW_DIAGONAL_BORDER_UP_DOWN: Cell diagonal border from top left to
1253
+ * bottom right. A combination of the 2 previous types.
1254
+ *
1255
+ * If the border style isn't specified with `format_set_diag_border()` then it
1256
+ * will default to #LXW_BORDER_THIN.
1257
+ */
1258
+ void format_set_diag_type(lxw_format *format, uint8_t type);
1259
+
1260
+ /**
1261
+ * @brief Set the diagonal cell border style.
1262
+ *
1263
+ * @param format Pointer to a Format instance.
1264
+ * @param style The #lxw_format_borders style.
1265
+ *
1266
+ * Set the diagonal border style. This should be a #lxw_format_borders value.
1267
+ * See the example above.
1268
+ *
1269
+ */
1270
+ void format_set_diag_border(lxw_format *format, uint8_t style);
1271
+
1272
+ /**
1273
+ * @brief Set the diagonal cell border color.
1274
+ *
1275
+ * @param format Pointer to a Format instance.
1276
+ * @param color The cell diagonal border color.
1277
+ *
1278
+ * Set the diagonal border color. The color should be an RGB integer value,
1279
+ * see @ref working_with_colors and the above example.
1280
+ */
1191
1281
  void format_set_diag_color(lxw_format *format, lxw_color_t color);
1192
- void format_set_diag_border(lxw_format *format, uint8_t value);
1282
+
1283
+ /**
1284
+ * @brief Turn on quote prefix for the format.
1285
+ *
1286
+ * @param format Pointer to a Format instance.
1287
+ *
1288
+ * Set the quote prefix property of a format to ensure a string is treated
1289
+ * as a string after editing. This is the same as prefixing the string with
1290
+ * a single quote in Excel. You don't need to add the quote to the
1291
+ * string but you do need to add the format.
1292
+ *
1293
+ * @code
1294
+ * format = workbook_add_format(workbook);
1295
+ * format_set_quote_prefix(format);
1296
+ *
1297
+ * worksheet_write_string(worksheet, 0, 0, "=Foo", format);
1298
+ * @endcode
1299
+ *
1300
+ */
1301
+ void format_set_quote_prefix(lxw_format *format);
1302
+
1193
1303
  void format_set_font_outline(lxw_format *format);
1194
1304
  void format_set_font_shadow(lxw_format *format);
1195
1305
  void format_set_font_family(lxw_format *format, uint8_t value);
@@ -1199,6 +1309,9 @@ void format_set_font_condense(lxw_format *format);
1199
1309
  void format_set_font_extend(lxw_format *format);
1200
1310
  void format_set_reading_order(lxw_format *format, uint8_t value);
1201
1311
  void format_set_theme(lxw_format *format, uint8_t value);
1312
+ void format_set_hyperlink(lxw_format *format);
1313
+ void format_set_color_indexed(lxw_format *format, uint8_t value);
1314
+ void format_set_font_only(lxw_format *format);
1202
1315
 
1203
1316
  /* Declarations required for unit testing. */
1204
1317
  #ifdef TESTING
@@ -1,7 +1,7 @@
1
1
  /*
2
2
  * libxlsxwriter
3
3
  *
4
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * hash_table - Hash table functions for libxlsxwriter.
7
7
  *
@@ -0,0 +1,49 @@
1
+ /*
2
+ * libxlsxwriter
3
+ *
4
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
+ *
6
+ * metadata - A libxlsxwriter library for creating Excel XLSX metadata files.
7
+ *
8
+ */
9
+ #ifndef __LXW_METADATA_H__
10
+ #define __LXW_METADATA_H__
11
+
12
+ #include <stdint.h>
13
+
14
+ #include "common.h"
15
+
16
+ /*
17
+ * Struct to represent a metadata object.
18
+ */
19
+ typedef struct lxw_metadata {
20
+
21
+ FILE *file;
22
+
23
+ } lxw_metadata;
24
+
25
+
26
+ /* *INDENT-OFF* */
27
+ #ifdef __cplusplus
28
+ extern "C" {
29
+ #endif
30
+ /* *INDENT-ON* */
31
+
32
+ lxw_metadata *lxw_metadata_new(void);
33
+ void lxw_metadata_free(lxw_metadata *metadata);
34
+ void lxw_metadata_assemble_xml_file(lxw_metadata *self);
35
+
36
+ /* Declarations required for unit testing. */
37
+ #ifdef TESTING
38
+
39
+ STATIC void _metadata_xml_declaration(lxw_metadata *self);
40
+
41
+ #endif /* TESTING */
42
+
43
+ /* *INDENT-OFF* */
44
+ #ifdef __cplusplus
45
+ }
46
+ #endif
47
+ /* *INDENT-ON* */
48
+
49
+ #endif /* __LXW_METADATA_H__ */