xlsxwriter 0.2.1.pre.2 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +4 -3
  3. data/ext/xlsxwriter/chart.c +20 -2
  4. data/ext/xlsxwriter/extconf.rb +8 -8
  5. data/ext/xlsxwriter/libxlsxwriter/License.txt +24 -2
  6. data/ext/xlsxwriter/libxlsxwriter/Makefile +46 -12
  7. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +1 -1
  8. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +196 -30
  9. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chartsheet.h +3 -3
  10. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  11. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +24 -5
  12. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +5 -1
  13. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  14. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  15. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +6 -17
  16. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +20 -6
  17. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  18. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +3 -1
  19. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  20. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  21. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +11 -5
  22. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  23. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/md5.h +43 -0
  24. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +42 -3
  25. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  26. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +83 -18
  27. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +1519 -109
  28. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +4 -2
  29. data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +3 -2
  30. data/ext/xlsxwriter/libxlsxwriter/src/Makefile +25 -7
  31. data/ext/xlsxwriter/libxlsxwriter/src/app.c +1 -1
  32. data/ext/xlsxwriter/libxlsxwriter/src/chart.c +332 -48
  33. data/ext/xlsxwriter/libxlsxwriter/src/chartsheet.c +20 -19
  34. data/ext/xlsxwriter/libxlsxwriter/src/comment.c +443 -0
  35. data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +20 -1
  36. data/ext/xlsxwriter/libxlsxwriter/src/core.c +2 -2
  37. data/ext/xlsxwriter/libxlsxwriter/src/custom.c +1 -1
  38. data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +58 -20
  39. data/ext/xlsxwriter/libxlsxwriter/src/format.c +98 -25
  40. data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +1 -1
  41. data/ext/xlsxwriter/libxlsxwriter/src/packager.c +269 -12
  42. data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +1 -1
  43. data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +2 -4
  44. data/ext/xlsxwriter/libxlsxwriter/src/styles.c +334 -48
  45. data/ext/xlsxwriter/libxlsxwriter/src/theme.c +1 -1
  46. data/ext/xlsxwriter/libxlsxwriter/src/utility.c +71 -8
  47. data/ext/xlsxwriter/libxlsxwriter/src/vml.c +1032 -0
  48. data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +343 -27
  49. data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +3759 -478
  50. data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +81 -2
  51. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/Makefile +42 -0
  52. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.c +291 -0
  53. data/ext/xlsxwriter/libxlsxwriter/third_party/md5/md5.h +43 -0
  54. data/ext/xlsxwriter/shared_strings.c +65 -0
  55. data/ext/xlsxwriter/shared_strings.h +15 -0
  56. data/ext/xlsxwriter/workbook.c +56 -1
  57. data/ext/xlsxwriter/worksheet.c +31 -2
  58. data/ext/xlsxwriter/worksheet.h +1 -0
  59. data/ext/xlsxwriter/xlsxwriter.c +2 -0
  60. data/lib/xlsxwriter/rich_string.rb +0 -2
  61. data/lib/xlsxwriter/version.rb +1 -1
  62. data/lib/xlsxwriter/worksheet.rb +2 -2
  63. data/test/{run-test.rb → run_test.rb} +3 -3
  64. data/test/support/chart_test.rb +3 -3
  65. data/test/support/with_xlsx_file.rb +4 -2
  66. data/test/support/xlsx_comparable.rb +40 -26
  67. data/test/test_array_formula.rb +42 -0
  68. data/test/test_autofilter.rb +72 -0
  69. data/test/{test-chart-area.rb → test_chart_area.rb} +2 -2
  70. data/test/{test-chart-axis.rb → test_chart_axis.rb} +16 -16
  71. data/test/test_chart_bar.rb +382 -0
  72. data/test/test_chart_blank.rb +27 -0
  73. data/test/{test-chart-column.rb → test_chart_column.rb} +2 -2
  74. data/test/{test-chart-doughnut.rb → test_chart_doughnut.rb} +2 -2
  75. data/test/{test-chart-legend.rb → test_chart_legend.rb} +2 -2
  76. data/test/{test-chart-pie.rb → test_chart_pie.rb} +2 -2
  77. data/test/{test-chart-scatter.rb → test_chart_scatter.rb} +3 -4
  78. data/test/{test-chart-size.rb → test_chart_size.rb} +2 -2
  79. data/test/{test-chart-title.rb → test_chart_title.rb} +3 -3
  80. data/test/{test-chartsheet.rb → test_chartsheet.rb} +2 -2
  81. data/test/{test-data.rb → test_data.rb} +1 -1
  82. data/test/{test-data-validation.rb → test_data_validation.rb} +23 -24
  83. data/test/{test-default-row.rb → test_default_row.rb} +1 -1
  84. data/test/{test-defined-name.rb → test_defined_name.rb} +12 -12
  85. data/test/{test-escapes.rb → test_escapes.rb} +5 -2
  86. data/test/{test-fit-to-pages.rb → test_fit_to_pages.rb} +6 -6
  87. data/test/{test-formatting.rb → test_formatting.rb} +10 -10
  88. data/test/{test-gridlines.rb → test_gridlines.rb} +3 -3
  89. data/test/{test-hyperlink.rb → test_hyperlink.rb} +22 -11
  90. data/test/{test-image.rb → test_image.rb} +6 -4
  91. data/test/{test-macro.rb → test_macro.rb} +1 -1
  92. data/test/{test-merge-range.rb → test_merge_range.rb} +1 -1
  93. data/test/{test-misc.rb → test_misc.rb} +2 -2
  94. data/test/{test-optimize.rb → test_optimize.rb} +2 -4
  95. data/test/{test-outline.rb → test_outline.rb} +14 -14
  96. data/test/{test-page-breaks.rb → test_page_breaks.rb} +2 -2
  97. data/test/{test-page-setup.rb → test_page_setup.rb} +2 -2
  98. data/test/{test-panes.rb → test_panes.rb} +1 -1
  99. data/test/{test-print-area.rb → test_print_area.rb} +3 -3
  100. data/test/{test-print-options.rb → test_print_options.rb} +7 -7
  101. data/test/{test-print-scale.rb → test_print_scale.rb} +2 -2
  102. data/test/{test-properties.rb → test_properties.rb} +2 -2
  103. data/test/{test-protect.rb → test_protect.rb} +3 -3
  104. data/test/{test-repeat.rb → test_repeat.rb} +3 -3
  105. data/test/{test-rich-string.rb → test_rich_string.rb} +5 -9
  106. data/test/{test-row-col-format.rb → test_row_col_format.rb} +1 -1
  107. data/test/{test-ruby-worksheet.rb → test_ruby_worksheet.rb} +2 -2
  108. data/test/{test-set-selection.rb → test_set_selection.rb} +2 -2
  109. data/test/{test-set-start-page.rb → test_set_start_page.rb} +2 -2
  110. data/test/{test-simple.rb → test_simple.rb} +10 -10
  111. data/test/{test-types.rb → test_types.rb} +1 -1
  112. data/test/{xlsx-func-testcase.rb → xlsx_func_testcase.rb} +1 -0
  113. metadata +132 -106
  114. data/test/test-array-formula.rb +0 -35
  115. data/test/test-autofilter.rb +0 -72
  116. data/test/test-chart-bar.rb +0 -74
  117. /data/test/{test-errors.rb → test_errors.rb} +0 -0
@@ -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-2020, 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,
@@ -348,10 +350,13 @@ typedef struct lxw_format {
348
350
  FILE *file;
349
351
 
350
352
  lxw_hash_table *xf_format_indices;
353
+ lxw_hash_table *dxf_format_indices;
351
354
  uint16_t *num_xf_formats;
355
+ uint16_t *num_dxf_formats;
352
356
 
353
357
  int32_t xf_index;
354
358
  int32_t dxf_index;
359
+ int32_t xf_id;
355
360
 
356
361
  char num_format[LXW_FORMAT_FIELD_LEN];
357
362
  char font_name[LXW_FORMAT_FIELD_LEN];
@@ -387,6 +392,8 @@ typedef struct lxw_format {
387
392
 
388
393
  lxw_color_t fg_color;
389
394
  lxw_color_t bg_color;
395
+ lxw_color_t dxf_fg_color;
396
+ lxw_color_t dxf_bg_color;
390
397
  uint8_t pattern;
391
398
  uint8_t has_fill;
392
399
  uint8_t has_dxf_fill;
@@ -431,6 +438,7 @@ typedef struct lxw_font {
431
438
  uint8_t bold;
432
439
  uint8_t italic;
433
440
  uint8_t underline;
441
+ uint8_t theme;
434
442
  uint8_t font_strikeout;
435
443
  uint8_t font_outline;
436
444
  uint8_t font_shadow;
@@ -483,12 +491,11 @@ extern "C" {
483
491
  lxw_format *lxw_format_new(void);
484
492
  void lxw_format_free(lxw_format *format);
485
493
  int32_t lxw_format_get_xf_index(lxw_format *format);
494
+ int32_t lxw_format_get_dxf_index(lxw_format *format);
486
495
  lxw_font *lxw_format_get_font_key(lxw_format *format);
487
496
  lxw_border *lxw_format_get_border_key(lxw_format *format);
488
497
  lxw_fill *lxw_format_get_fill_key(lxw_format *format);
489
498
 
490
- lxw_color_t lxw_format_check_color(lxw_color_t color);
491
-
492
499
  /**
493
500
  * @brief Set the font used in the cell.
494
501
  *
@@ -672,6 +679,9 @@ void format_set_font_script(lxw_format *format, uint8_t style);
672
679
  *
673
680
  * @image html format_set_num_format.png
674
681
  *
682
+ * To set a number format that matches an Excel format category such as "Date"
683
+ * or "Currency" see @ref ww_formats_categories.
684
+ *
675
685
  * The number system used for dates is described in @ref working_with_dates.
676
686
  *
677
687
  * For more information on number formats in Excel refer to the
@@ -749,6 +759,7 @@ void format_set_num_format(lxw_format *format, const char *num_format);
749
759
  * - The dollar sign in the above format appears as the defined local currency
750
760
  * symbol.
751
761
  * - These formats can also be set via format_set_num_format().
762
+ * - See also @ref ww_formats_categories.
752
763
  */
753
764
  void format_set_num_format_index(lxw_format *format, uint8_t index);
754
765
 
@@ -1199,6 +1210,9 @@ void format_set_font_condense(lxw_format *format);
1199
1210
  void format_set_font_extend(lxw_format *format);
1200
1211
  void format_set_reading_order(lxw_format *format, uint8_t value);
1201
1212
  void format_set_theme(lxw_format *format, uint8_t value);
1213
+ void format_set_hyperlink(lxw_format *format);
1214
+ void format_set_color_indexed(lxw_format *format, uint8_t value);
1215
+ void format_set_font_only(lxw_format *format);
1202
1216
 
1203
1217
  /* Declarations required for unit testing. */
1204
1218
  #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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * hash_table - Hash table functions for libxlsxwriter.
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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * packager - A libxlsxwriter library for creating Excel XLSX packager files.
7
7
  *
@@ -29,6 +29,8 @@
29
29
  #include "format.h"
30
30
  #include "content_types.h"
31
31
  #include "relationships.h"
32
+ #include "vml.h"
33
+ #include "comment.h"
32
34
 
33
35
  #define LXW_ZIP_BUFFER_SIZE (16384)
34
36
 
@@ -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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * relationships - A libxlsxwriter library for creating Excel XLSX
7
7
  * relationships files.
@@ -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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * shared_strings - A libxlsxwriter library for creating Excel XLSX
7
7
  * sst files.
@@ -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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * styles - A libxlsxwriter library for creating Excel XLSX styles files.
7
7
  *
@@ -28,6 +28,9 @@ typedef struct lxw_styles {
28
28
  uint32_t fill_count;
29
29
  struct lxw_formats *xf_formats;
30
30
  struct lxw_formats *dxf_formats;
31
+ uint8_t has_hyperlink;
32
+ uint16_t hyperlink_font_id;
33
+ uint8_t has_comments;
31
34
 
32
35
  } lxw_styles;
33
36
 
@@ -55,18 +58,21 @@ STATIC void _write_font_name(lxw_styles *self, const char *font_name,
55
58
  uint8_t is_rich_string);
56
59
  STATIC void _write_font_family(lxw_styles *self, uint8_t font_family);
57
60
  STATIC void _write_font_scheme(lxw_styles *self, const char *font_scheme);
58
- STATIC void _write_font(lxw_styles *self, lxw_format *format,
61
+ STATIC void _write_font(lxw_styles *self, lxw_format *format, uint8_t is_dxf,
59
62
  uint8_t is_rich_string);
60
63
  STATIC void _write_fonts(lxw_styles *self);
61
64
  STATIC void _write_default_fill(lxw_styles *self, const char *pattern);
62
65
  STATIC void _write_fills(lxw_styles *self);
63
- STATIC void _write_border(lxw_styles *self, lxw_format *format);
66
+ STATIC void _write_border(lxw_styles *self, lxw_format *format,
67
+ uint8_t is_dxf);
64
68
  STATIC void _write_borders(lxw_styles *self);
65
- STATIC void _write_style_xf(lxw_styles *self);
69
+ STATIC void _write_style_xf(lxw_styles *self, uint8_t has_hyperlink,
70
+ uint16_t font_id);
66
71
  STATIC void _write_cell_style_xfs(lxw_styles *self);
67
72
  STATIC void _write_xf(lxw_styles *self, lxw_format *format);
68
73
  STATIC void _write_cell_xfs(lxw_styles *self);
69
- STATIC void _write_cell_style(lxw_styles *self);
74
+ STATIC void _write_cell_style(lxw_styles *self, char *name, uint8_t xf_id,
75
+ uint8_t builtin_id);
70
76
  STATIC void _write_cell_styles(lxw_styles *self);
71
77
  STATIC void _write_dxfs(lxw_styles *self);
72
78
  STATIC void _write_table_styles(lxw_styles *self);
@@ -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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  *
6
6
  * theme - A libxlsxwriter library for creating Excel XLSX theme files.
7
7
  *
@@ -0,0 +1,43 @@
1
+ /*
2
+ * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
3
+ * MD5 Message-Digest Algorithm (RFC 1321).
4
+ *
5
+ * Homepage:
6
+ * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5
7
+ *
8
+ * Author:
9
+ * Alexander Peslyak, better known as Solar Designer <solar at openwall.com>
10
+ *
11
+ * This software was written by Alexander Peslyak in 2001. No copyright is
12
+ * claimed, and the software is hereby placed in the public domain.
13
+ * In case this attempt to disclaim copyright and place the software in the
14
+ * public domain is deemed null and void, then the software is
15
+ * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the
16
+ * general public under the following terms:
17
+ *
18
+ * Redistribution and use in source and binary forms, with or without
19
+ * modification, are permitted.
20
+ *
21
+ * There's ABSOLUTELY NO WARRANTY, express or implied.
22
+ *
23
+ * See md5.c for more information.
24
+ */
25
+
26
+ #ifndef __LXW_MD5_H__
27
+ #define __LXW_MD5_H__
28
+
29
+ /* Any 32-bit or wider unsigned integer data type will do */
30
+ typedef unsigned int uint32_t;
31
+
32
+ typedef struct {
33
+ uint32_t lo, hi;
34
+ uint32_t a, b, c, d;
35
+ unsigned char buffer[64];
36
+ uint32_t block[16];
37
+ } lxw_md5_ctx;
38
+
39
+ extern void lxw_md5_init(lxw_md5_ctx *ctx);
40
+ extern void lxw_md5_update(lxw_md5_ctx *ctx, const void *data, unsigned long size);
41
+ extern void lxw_md5_final(unsigned char *result, lxw_md5_ctx *ctx);
42
+
43
+ #endif
@@ -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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  */
6
6
 
7
7
  /**
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @brief Utility functions for libxlsxwriter.
11
11
  *
12
- * <!-- Copyright 2014-2019, John McNamara, jmcnamara@cpan.org -->
12
+ * <!-- Copyright 2014-2020, John McNamara, jmcnamara@cpan.org -->
13
13
  *
14
14
  */
15
15
 
@@ -17,7 +17,9 @@
17
17
  #define __LXW_UTILITY_H__
18
18
 
19
19
  #include <stdint.h>
20
+ #ifndef _MSC_VER
20
21
  #include <strings.h>
22
+ #endif
21
23
  #include "common.h"
22
24
  #include "xmlwriter.h"
23
25
 
@@ -101,6 +103,20 @@ extern "C" {
101
103
  */
102
104
  const char *lxw_version(void);
103
105
 
106
+ /**
107
+ * @brief Retrieve the library version ID.
108
+ *
109
+ * @return The version ID.
110
+ *
111
+ * Get the library version such as "X.Y.Z" as a XYZ integer.
112
+ *
113
+ * @code
114
+ * printf("Libxlsxwriter version id = %d\n", lxw_version_id());
115
+ * @endcode
116
+ *
117
+ */
118
+ uint16_t lxw_version_id(void);
119
+
104
120
  /**
105
121
  * @brief Converts a libxlsxwriter error number to a string.
106
122
  *
@@ -155,10 +171,32 @@ void lxw_rowcol_to_formula_abs(char *formula, const char *sheetname,
155
171
 
156
172
  uint32_t lxw_name_to_row(const char *row_str);
157
173
  uint16_t lxw_name_to_col(const char *col_str);
174
+
158
175
  uint32_t lxw_name_to_row_2(const char *row_str);
159
176
  uint16_t lxw_name_to_col_2(const char *col_str);
160
177
 
161
- double lxw_datetime_to_excel_date(lxw_datetime *datetime, uint8_t date_1904);
178
+ /**
179
+ * @brief Converts a #lxw_datetime to an Excel datetime number.
180
+ *
181
+ * @param datetime A pointer to a #lxw_datetime struct.
182
+ *
183
+ * @return A double representing an Excel datetime.
184
+ *
185
+ * The `%lxw_datetime_to_excel_datetime()` function converts a datetime in
186
+ * #lxw_datetime to and Excel datetime number:
187
+ *
188
+ * @code
189
+ * lxw_datetime datetime = {2013, 2, 28, 12, 0, 0.0};
190
+ *
191
+ * double excel_datetime = lxw_datetime_to_excel_date(&datetime);
192
+ * @endcode
193
+ *
194
+ * See @ref working_with_dates for more details on the Excel datetime format.
195
+ */
196
+ double lxw_datetime_to_excel_datetime(lxw_datetime *datetime);
197
+
198
+ double lxw_datetime_to_excel_date_epoch(lxw_datetime *datetime,
199
+ uint8_t date_1904);
162
200
 
163
201
  char *lxw_strdup(const char *str);
164
202
  char *lxw_strdup_formula(const char *formula);
@@ -175,6 +213,7 @@ void lxw_str_tolower(char *str);
175
213
  #endif
176
214
 
177
215
  FILE *lxw_tmpfile(char *tmpdir);
216
+ FILE *lxw_fopen(const char *filename, const char *mode);
178
217
 
179
218
  /* Use a user defined function to format doubles in sprintf or else a simple
180
219
  * macro (the default). */
@@ -0,0 +1,55 @@
1
+ /*
2
+ * libxlsxwriter
3
+ *
4
+ * Copyright 2014-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
+ *
6
+ * vml - A libxlsxwriter library for creating Excel XLSX vml files.
7
+ *
8
+ */
9
+ #ifndef __LXW_VML_H__
10
+ #define __LXW_VML_H__
11
+
12
+ #include <stdint.h>
13
+
14
+ #include "common.h"
15
+ #include "worksheet.h"
16
+
17
+ /*
18
+ * Struct to represent a vml object.
19
+ */
20
+ typedef struct lxw_vml {
21
+
22
+ FILE *file;
23
+ uint8_t type;
24
+ struct lxw_comment_objs *button_objs;
25
+ struct lxw_comment_objs *comment_objs;
26
+ struct lxw_comment_objs *image_objs;
27
+ char *vml_data_id_str;
28
+ uint32_t vml_shape_id;
29
+ uint8_t comment_display_default;
30
+
31
+ } lxw_vml;
32
+
33
+
34
+ /* *INDENT-OFF* */
35
+ #ifdef __cplusplus
36
+ extern "C" {
37
+ #endif
38
+ /* *INDENT-ON* */
39
+
40
+ lxw_vml *lxw_vml_new(void);
41
+ void lxw_vml_free(lxw_vml *vml);
42
+ void lxw_vml_assemble_xml_file(lxw_vml *self);
43
+
44
+ /* Declarations required for unit testing. */
45
+ #ifdef TESTING
46
+
47
+ #endif /* TESTING */
48
+
49
+ /* *INDENT-OFF* */
50
+ #ifdef __cplusplus
51
+ }
52
+ #endif
53
+ /* *INDENT-ON* */
54
+
55
+ #endif /* __LXW_VML_H__ */
@@ -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-2020, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
5
5
  */
6
6
 
7
7
  /**
@@ -57,6 +57,7 @@
57
57
  /* Define the tree.h RB structs for the red-black head types. */
58
58
  RB_HEAD(lxw_worksheet_names, lxw_worksheet_name);
59
59
  RB_HEAD(lxw_chartsheet_names, lxw_chartsheet_name);
60
+ RB_HEAD(lxw_image_md5s, lxw_image_md5);
60
61
 
61
62
  /* Define the queue.h structs for the workbook lists. */
62
63
  STAILQ_HEAD(lxw_sheets, lxw_sheet);
@@ -65,7 +66,7 @@ STAILQ_HEAD(lxw_chartsheets, lxw_chartsheet);
65
66
  STAILQ_HEAD(lxw_charts, lxw_chart);
66
67
  TAILQ_HEAD(lxw_defined_names, lxw_defined_name);
67
68
 
68
- /* TODO */
69
+ /* Struct to hold the 2 sheet types. */
69
70
  typedef struct lxw_sheet {
70
71
  uint8_t is_chartsheet;
71
72
 
@@ -93,6 +94,14 @@ typedef struct lxw_chartsheet_name {
93
94
  RB_ENTRY (lxw_chartsheet_name) tree_pointers;
94
95
  } lxw_chartsheet_name;
95
96
 
97
+ /* Struct to represent an image MD5/ID pair. */
98
+ typedef struct lxw_image_md5 {
99
+ uint32_t id;
100
+ char *md5;
101
+
102
+ RB_ENTRY (lxw_image_md5) tree_pointers;
103
+ } lxw_image_md5;
104
+
96
105
  /* Wrapper around RB_GENERATE_STATIC from tree.h to avoid unused function
97
106
  * warnings and to avoid portability issues with the _unused attribute. */
98
107
  #define LXW_RB_GENERATE_WORKSHEET_NAMES(name, type, field, cmp) \
@@ -117,6 +126,17 @@ typedef struct lxw_chartsheet_name {
117
126
  /* Add unused struct to allow adding a semicolon */ \
118
127
  struct lxw_rb_generate_charsheet_names{int unused;}
119
128
 
129
+ #define LXW_RB_GENERATE_IMAGE_MD5S(name, type, field, cmp) \
130
+ RB_GENERATE_INSERT_COLOR(name, type, field, static) \
131
+ RB_GENERATE_REMOVE_COLOR(name, type, field, static) \
132
+ RB_GENERATE_INSERT(name, type, field, cmp, static) \
133
+ RB_GENERATE_REMOVE(name, type, field, static) \
134
+ RB_GENERATE_FIND(name, type, field, cmp, static) \
135
+ RB_GENERATE_NEXT(name, type, field, static) \
136
+ RB_GENERATE_MINMAX(name, type, field, static) \
137
+ /* Add unused struct to allow adding a semicolon */ \
138
+ struct lxw_rb_generate_image_md5s{int unused;}
139
+
120
140
  /**
121
141
  * @brief Macro to loop over all the worksheets in a workbook.
122
142
  *
@@ -158,7 +178,7 @@ typedef struct lxw_defined_name {
158
178
  } lxw_defined_name;
159
179
 
160
180
  /**
161
- * Workbook document properties.
181
+ * Workbook document properties. Set any unused fields to NULL or 0.
162
182
  */
163
183
  typedef struct lxw_doc_properties {
164
184
  /** The title of the Excel Document. */
@@ -188,9 +208,13 @@ typedef struct lxw_doc_properties {
188
208
  /** The status of the Excel Document. */
189
209
  char *status;
190
210
 
191
- /** The hyperlink base url of the Excel Document. */
211
+ /** The hyperlink base URL of the Excel Document. */
192
212
  char *hyperlink_base;
193
213
 
214
+ /** The file creation date/time shown in Excel. This defaults to the
215
+ * current time and date if set to 0. If you wish to create files that are
216
+ * binary equivalent (for the same input data) then you should set this
217
+ * creation date/time to a known value. */
194
218
  time_t created;
195
219
 
196
220
  } lxw_doc_properties;
@@ -254,6 +278,8 @@ typedef struct lxw_workbook {
254
278
  struct lxw_chartsheets *chartsheets;
255
279
  struct lxw_worksheet_names *worksheet_names;
256
280
  struct lxw_chartsheet_names *chartsheet_names;
281
+ struct lxw_image_md5s *image_md5s;
282
+ struct lxw_image_md5s *header_image_md5s;
257
283
  struct lxw_charts *charts;
258
284
  struct lxw_charts *ordered_charts;
259
285
  struct lxw_formats *formats;
@@ -271,23 +297,31 @@ typedef struct lxw_workbook {
271
297
  uint16_t first_sheet;
272
298
  uint16_t active_sheet;
273
299
  uint16_t num_xf_formats;
300
+ uint16_t num_dxf_formats;
274
301
  uint16_t num_format_count;
275
302
  uint16_t drawing_count;
303
+ uint16_t comment_count;
276
304
 
277
305
  uint16_t font_count;
278
306
  uint16_t border_count;
279
307
  uint16_t fill_count;
280
308
  uint8_t optimize;
309
+ uint16_t max_url_length;
281
310
 
282
311
  uint8_t has_png;
283
312
  uint8_t has_jpeg;
284
313
  uint8_t has_bmp;
314
+ uint8_t has_vml;
315
+ uint8_t has_comments;
285
316
 
286
317
  lxw_hash_table *used_xf_formats;
318
+ lxw_hash_table *used_dxf_formats;
287
319
 
288
320
  char *vba_project;
289
321
  char *vba_codename;
290
322
 
323
+ lxw_format *default_url_format;
324
+
291
325
  } lxw_workbook;
292
326
 
293
327
 
@@ -365,13 +399,6 @@ lxw_workbook *workbook_new(const char *filename);
365
399
  lxw_workbook *workbook_new_opt(const char *filename,
366
400
  lxw_workbook_options *options);
367
401
 
368
- /* Deprecated function name for backwards compatibility. */
369
- lxw_workbook *new_workbook(const char *filename);
370
-
371
- /* Deprecated function name for backwards compatibility. */
372
- lxw_workbook *new_workbook_opt(const char *filename,
373
- lxw_workbook_options *options);
374
-
375
402
  /**
376
403
  * @brief Add a new worksheet to a workbook.
377
404
  *
@@ -404,12 +431,15 @@ lxw_workbook *new_workbook_opt(const char *filename,
404
431
  * - The name is less than or equal to 31 UTF-8 characters.
405
432
  * - The name doesn't contain any of the characters: ` [ ] : * ? / \ `
406
433
  * - The name doesn't start or end with an apostrophe.
407
- * - The name isn't "History", which is reserved by Excel. (Case insensitive).
408
434
  * - The name isn't already in use. (Case insensitive).
409
435
  *
410
436
  * If any of these errors are encountered the function will return NULL.
411
437
  * You can check for valid name using the `workbook_validate_sheet_name()`
412
438
  * function.
439
+ *
440
+ * @note You should also avoid using the worksheet name "History" (case
441
+ * insensitive) which is reserved in English language versions of
442
+ * Excel. Non-English versions may have restrictions on the equivalent word.
413
443
  */
414
444
  lxw_worksheet *workbook_add_worksheet(lxw_workbook *workbook,
415
445
  const char *sheetname);
@@ -443,13 +473,16 @@ lxw_worksheet *workbook_add_worksheet(lxw_workbook *workbook,
443
473
  * - The name is less than or equal to 31 UTF-8 characters.
444
474
  * - The name doesn't contain any of the characters: ` [ ] : * ? / \ `
445
475
  * - The name doesn't start or end with an apostrophe.
446
- * - The name isn't "History", which is reserved by Excel. (Case insensitive).
447
476
  * - The name isn't already in use. (Case insensitive).
448
477
  *
449
478
  * If any of these errors are encountered the function will return NULL.
450
479
  * You can check for valid name using the `workbook_validate_sheet_name()`
451
480
  * function.
452
481
  *
482
+ * @note You should also avoid using the worksheet name "History" (case
483
+ * insensitive) which is reserved in English language versions of
484
+ * Excel. Non-English versions may have restrictions on the equivalent word.
485
+ *
453
486
  * At least one worksheet should be added to a new workbook when creating a
454
487
  * chartsheet in order to provide data for the chart. The @ref worksheet.h
455
488
  * "Worksheet" object is used to write data and configure a worksheet in the
@@ -527,6 +560,8 @@ lxw_format *workbook_add_format(lxw_workbook *workbook);
527
560
  * | #LXW_CHART_COLUMN_STACKED_PERCENT | Column chart - percentage stacked. |
528
561
  * | #LXW_CHART_DOUGHNUT | Doughnut chart. |
529
562
  * | #LXW_CHART_LINE | Line chart. |
563
+ * | #LXW_CHART_LINE_STACKED | Line chart - stacked. |
564
+ * | #LXW_CHART_LINE_STACKED_PERCENT | Line chart - percentage stacked. |
530
565
  * | #LXW_CHART_PIE | Pie chart. |
531
566
  * | #LXW_CHART_SCATTER | Scatter chart. |
532
567
  * | #LXW_CHART_SCATTER_STRAIGHT | Scatter chart - straight. |
@@ -594,10 +629,11 @@ lxw_error workbook_close(lxw_workbook *workbook);
594
629
  * - `keywords`
595
630
  * - `comments`
596
631
  * - `hyperlink_base`
632
+ * - `created`
597
633
  *
598
634
  * The properties are specified via a `lxw_doc_properties` struct. All the
599
- * members are `char *` and they are all optional. An example of how to create
600
- * and pass the properties is:
635
+ * fields are all optional. An example of how to create and pass the
636
+ * properties is:
601
637
  *
602
638
  * @code
603
639
  * // Create a properties structure and set some of the fields.
@@ -619,6 +655,12 @@ lxw_error workbook_close(lxw_workbook *workbook);
619
655
  *
620
656
  * @image html doc_properties.png
621
657
  *
658
+ * The `created` parameter sets the file creation date/time shown in
659
+ * Excel. This defaults to the current time and date if set to 0. If you wish
660
+ * to create files that are binary equivalent (for the same input data) then
661
+ * you should set this creation date/time to a known value using a `time_t`
662
+ * value.
663
+ *
622
664
  */
623
665
  lxw_error workbook_set_properties(lxw_workbook *workbook,
624
666
  lxw_doc_properties *properties);
@@ -771,13 +813,32 @@ lxw_error workbook_set_custom_property_datetime(lxw_workbook *workbook,
771
813
  * @endcode
772
814
  *
773
815
  * The rules for names in Excel are explained in the
774
- * [Microsoft Office
775
- documentation](http://office.microsoft.com/en-001/excel-help/define-and-use-names-in-formulas-HA010147120.aspx).
816
+ * [Microsoft Office documentation](http://office.microsoft.com/en-001/excel-help/define-and-use-names-in-formulas-HA010147120.aspx).
776
817
  *
777
818
  */
778
819
  lxw_error workbook_define_name(lxw_workbook *workbook, const char *name,
779
820
  const char *formula);
780
821
 
822
+ /**
823
+ * @brief Get the default URL format used with `worksheet_write_url()`.
824
+ *
825
+ * @param workbook Pointer to a lxw_workbook instance.
826
+ * @return A lxw_format instance that has hyperlink properties set.
827
+ *
828
+ * This function returns a lxw_format instance that is used for the default
829
+ * blue underline hyperlink in the `worksheet_write_url()` function when a
830
+ * format isn't specified:
831
+ *
832
+ * @code
833
+ * lxw_format *url_format = workbook_get_default_url_format(workbook);
834
+ * @endcode
835
+ *
836
+ * The format is the hyperlink style defined by Excel for the default theme.
837
+ * This format is only ever required when overwriting a string URL with
838
+ * data of a different type. See the example below.
839
+ */
840
+ lxw_format *workbook_get_default_url_format(lxw_workbook *workbook);
841
+
781
842
  /**
782
843
  * @brief Get a worksheet object from its name.
783
844
  *
@@ -828,7 +889,6 @@ lxw_chartsheet *workbook_get_chartsheet_by_name(lxw_workbook *workbook,
828
889
  * - The name is less than or equal to 31 UTF-8 characters.
829
890
  * - The name doesn't contain any of the characters: ` [ ] : * ? / \ `
830
891
  * - The name doesn't start or end with an apostrophe.
831
- * - The name isn't "History", which is reserved by Excel. (Case insensitive).
832
892
  * - The name isn't already in use. (Case insensitive, see the note below).
833
893
  *
834
894
  * @code
@@ -839,6 +899,10 @@ lxw_chartsheet *workbook_get_chartsheet_by_name(lxw_workbook *workbook,
839
899
  * `workbook_add_chartsheet()` but it can be explicitly called by the user
840
900
  * beforehand to ensure that the sheet name is valid.
841
901
  *
902
+ * @note You should also avoid using the worksheet name "History" (case
903
+ * insensitive) which is reserved in English language versions of
904
+ * Excel. Non-English versions may have restrictions on the equivalent word.
905
+ *
842
906
  * @note This function does an ASCII lowercase string comparison to determine
843
907
  * if the sheet name is already in use. It doesn't take UTF-8 characters into
844
908
  * account. Thus it would flag "Café" and "café" as a duplicate (just like
@@ -909,6 +973,7 @@ lxw_error workbook_set_vba_name(lxw_workbook *workbook, const char *name);
909
973
  void lxw_workbook_free(lxw_workbook *workbook);
910
974
  void lxw_workbook_assemble_xml_file(lxw_workbook *workbook);
911
975
  void lxw_workbook_set_default_xf_indices(lxw_workbook *workbook);
976
+ void workbook_unset_default_url_format(lxw_workbook *workbook);
912
977
 
913
978
  /* Declarations required for unit testing. */
914
979
  #ifdef TESTING