fast_excel 0.2.6 → 0.3.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.
- checksums.yaml +4 -4
- data/.dockerignore +2 -0
- data/.gitignore +3 -0
- data/.travis.yml +18 -6
- data/CHANGELOG.md +14 -1
- data/Dockerfile.test +16 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +21 -21
- data/Makefile +13 -2
- data/README.md +148 -38
- data/Rakefile +2 -0
- data/examples/example.rb +3 -3
- data/examples/example_filters.rb +36 -0
- data/examples/example_formula.rb +1 -3
- data/examples/example_hyperlink.rb +20 -0
- data/fast_excel.gemspec +1 -1
- data/lib/fast_excel.rb +36 -12
- data/lib/fast_excel/binding.rb +31 -21
- data/lib/fast_excel/binding/chart.rb +20 -1
- data/lib/fast_excel/binding/workbook.rb +10 -2
- data/lib/fast_excel/binding/worksheet.rb +44 -27
- data/libxlsxwriter/.gitignore +1 -0
- data/libxlsxwriter/.indent.pro +5 -0
- data/libxlsxwriter/CMakeLists.txt +1 -11
- data/libxlsxwriter/CONTRIBUTING.md +1 -1
- data/libxlsxwriter/Changes.txt +84 -0
- data/libxlsxwriter/LICENSE.txt +1 -1
- data/libxlsxwriter/Makefile +7 -5
- data/libxlsxwriter/Readme.md +1 -1
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +1 -0
- data/libxlsxwriter/include/xlsxwriter.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/app.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/chart.h +56 -6
- data/libxlsxwriter/include/xlsxwriter/chartsheet.h +544 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +27 -6
- data/libxlsxwriter/include/xlsxwriter/content_types.h +5 -2
- data/libxlsxwriter/include/xlsxwriter/core.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/custom.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/drawing.h +3 -2
- data/libxlsxwriter/include/xlsxwriter/format.h +3 -3
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/packager.h +13 -8
- data/libxlsxwriter/include/xlsxwriter/relationships.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +5 -3
- data/libxlsxwriter/include/xlsxwriter/styles.h +9 -4
- data/libxlsxwriter/include/xlsxwriter/theme.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/utility.h +26 -2
- data/libxlsxwriter/include/xlsxwriter/workbook.h +232 -55
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +264 -53
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +3 -1
- data/libxlsxwriter/libxlsxwriter.podspec +1 -1
- data/libxlsxwriter/src/Makefile +3 -3
- data/libxlsxwriter/src/app.c +2 -2
- data/libxlsxwriter/src/chart.c +41 -5
- data/libxlsxwriter/src/chartsheet.c +508 -0
- data/libxlsxwriter/src/content_types.c +12 -4
- data/libxlsxwriter/src/core.c +2 -2
- data/libxlsxwriter/src/custom.c +2 -2
- data/libxlsxwriter/src/drawing.c +114 -17
- data/libxlsxwriter/src/format.c +3 -3
- data/libxlsxwriter/src/hash_table.c +1 -1
- data/libxlsxwriter/src/packager.c +369 -65
- data/libxlsxwriter/src/relationships.c +2 -2
- data/libxlsxwriter/src/shared_strings.c +18 -4
- data/libxlsxwriter/src/styles.c +56 -9
- data/libxlsxwriter/src/theme.c +2 -2
- data/libxlsxwriter/src/utility.c +53 -6
- data/libxlsxwriter/src/workbook.c +372 -56
- data/libxlsxwriter/src/worksheet.c +425 -76
- data/libxlsxwriter/src/xmlwriter.c +17 -8
- data/libxlsxwriter/third_party/minizip/ioapi.c +10 -0
- data/libxlsxwriter/third_party/minizip/zip.c +2 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +2 -2
- data/libxlsxwriter/version.txt +1 -1
- data/test/tmpfile_test.rb +1 -0
- data/test/validations_test.rb +26 -6
- data/test/worksheet_test.rb +43 -0
- metadata +9 -6
- data/libxlsxwriter/.drone.yml +0 -27
- data/libxlsxwriter/appveyor.yml +0 -65
- data/libxlsxwriter/cmake/FindZLIB.cmake +0 -123
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, 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-
|
12
|
+
* <!-- Copyright 2014-2019, John McNamara, jmcnamara@cpan.org -->
|
13
13
|
*
|
14
14
|
*/
|
15
15
|
#ifndef __LXW_COMMON_H__
|
@@ -65,13 +65,25 @@ typedef enum lxw_error {
|
|
65
65
|
/** Error encountered when creating a tmpfile during file assembly. */
|
66
66
|
LXW_ERROR_CREATING_TMPFILE,
|
67
67
|
|
68
|
-
/**
|
68
|
+
/** Error reading a tmpfile. */
|
69
|
+
LXW_ERROR_READING_TMPFILE,
|
70
|
+
|
71
|
+
/** Zip generic error ZIP_ERRNO while creating the xlsx file. */
|
69
72
|
LXW_ERROR_ZIP_FILE_OPERATION,
|
70
73
|
|
71
|
-
/**
|
74
|
+
/** Zip error ZIP_PARAMERROR while creating the xlsx file. */
|
75
|
+
LXW_ERROR_ZIP_PARAMETER_ERROR,
|
76
|
+
|
77
|
+
/** Zip error ZIP_BADZIPFILE (use_zip64 option may be required). */
|
78
|
+
LXW_ERROR_ZIP_BAD_ZIP_FILE,
|
79
|
+
|
80
|
+
/** Zip error ZIP_INTERNALERROR while creating the xlsx file. */
|
81
|
+
LXW_ERROR_ZIP_INTERNAL_ERROR,
|
82
|
+
|
83
|
+
/** File error or unknown zip error when adding sub file to xlsx file. */
|
72
84
|
LXW_ERROR_ZIP_FILE_ADD,
|
73
85
|
|
74
|
-
/**
|
86
|
+
/** Unknown zip error when closing xlsx file. */
|
75
87
|
LXW_ERROR_ZIP_CLOSE,
|
76
88
|
|
77
89
|
/** NULL function parameter ignored. */
|
@@ -83,12 +95,18 @@ typedef enum lxw_error {
|
|
83
95
|
/** Worksheet name exceeds Excel's limit of 31 characters. */
|
84
96
|
LXW_ERROR_SHEETNAME_LENGTH_EXCEEDED,
|
85
97
|
|
86
|
-
/** Worksheet name
|
98
|
+
/** Worksheet name cannot contain invalid characters: '[ ] : * ? / \\' */
|
87
99
|
LXW_ERROR_INVALID_SHEETNAME_CHARACTER,
|
88
100
|
|
101
|
+
/** Worksheet name cannot start or end with an apostrophe. */
|
102
|
+
LXW_ERROR_SHEETNAME_START_END_APOSTROPHE,
|
103
|
+
|
89
104
|
/** Worksheet name is already in use. */
|
90
105
|
LXW_ERROR_SHEETNAME_ALREADY_USED,
|
91
106
|
|
107
|
+
/** Worksheet name 'History' is reserved by Excel. */
|
108
|
+
LXW_ERROR_SHEETNAME_RESERVED,
|
109
|
+
|
92
110
|
/** Parameter exceeds Excel's limit of 32 characters. */
|
93
111
|
LXW_ERROR_32_STRING_LENGTH_EXCEEDED,
|
94
112
|
|
@@ -177,6 +195,9 @@ enum lxw_custom_property_types {
|
|
177
195
|
#define LXW_FILENAME_LENGTH 128
|
178
196
|
#define LXW_IGNORE 1
|
179
197
|
|
198
|
+
#define LXW_PORTRAIT 1
|
199
|
+
#define LXW_LANDSCAPE 0
|
200
|
+
|
180
201
|
#define LXW_SCHEMA_MS "http://schemas.microsoft.com/office/2006/relationships"
|
181
202
|
#define LXW_SCHEMA_ROOT "http://schemas.openxmlformats.org"
|
182
203
|
#define LXW_SCHEMA_DRAWING LXW_SCHEMA_ROOT "/drawingml/2006"
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, 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.
|
@@ -17,6 +17,7 @@
|
|
17
17
|
|
18
18
|
#define LXW_APP_PACKAGE "application/vnd.openxmlformats-package."
|
19
19
|
#define LXW_APP_DOCUMENT "application/vnd.openxmlformats-officedocument."
|
20
|
+
#define LXW_APP_MSEXCEL "application/vnd.ms-excel."
|
20
21
|
|
21
22
|
/*
|
22
23
|
* Struct to represent a content_types.
|
@@ -37,7 +38,7 @@ extern "C" {
|
|
37
38
|
#endif
|
38
39
|
/* *INDENT-ON* */
|
39
40
|
|
40
|
-
lxw_content_types *lxw_content_types_new();
|
41
|
+
lxw_content_types *lxw_content_types_new(void);
|
41
42
|
void lxw_content_types_free(lxw_content_types *content_types);
|
42
43
|
void lxw_content_types_assemble_xml_file(lxw_content_types *content_types);
|
43
44
|
void lxw_ct_add_default(lxw_content_types *content_types, const char *key,
|
@@ -46,6 +47,8 @@ void lxw_ct_add_override(lxw_content_types *content_types, const char *key,
|
|
46
47
|
const char *value);
|
47
48
|
void lxw_ct_add_worksheet_name(lxw_content_types *content_types,
|
48
49
|
const char *name);
|
50
|
+
void lxw_ct_add_chartsheet_name(lxw_content_types *content_types,
|
51
|
+
const char *name);
|
49
52
|
void lxw_ct_add_chart_name(lxw_content_types *content_types,
|
50
53
|
const char *name);
|
51
54
|
void lxw_ct_add_drawing_name(lxw_content_types *content_types,
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*
|
6
6
|
* core - A libxlsxwriter library for creating Excel XLSX core files.
|
7
7
|
*
|
@@ -31,7 +31,7 @@ extern "C" {
|
|
31
31
|
#endif
|
32
32
|
/* *INDENT-ON* */
|
33
33
|
|
34
|
-
lxw_core *lxw_core_new();
|
34
|
+
lxw_core *lxw_core_new(void);
|
35
35
|
void lxw_core_free(lxw_core *core);
|
36
36
|
void lxw_core_assemble_xml_file(lxw_core *self);
|
37
37
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*
|
6
6
|
* custom - A libxlsxwriter library for creating Excel custom property files.
|
7
7
|
*
|
@@ -32,7 +32,7 @@ extern "C" {
|
|
32
32
|
#endif
|
33
33
|
/* *INDENT-ON* */
|
34
34
|
|
35
|
-
lxw_custom *lxw_custom_new();
|
35
|
+
lxw_custom *lxw_custom_new(void);
|
36
36
|
void lxw_custom_free(lxw_custom *custom);
|
37
37
|
void lxw_custom_assemble_xml_file(lxw_custom *self);
|
38
38
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*
|
6
6
|
* drawing - A libxlsxwriter library for creating Excel XLSX drawing files.
|
7
7
|
*
|
@@ -77,6 +77,7 @@ typedef struct lxw_drawing {
|
|
77
77
|
FILE *file;
|
78
78
|
|
79
79
|
uint8_t embedded;
|
80
|
+
uint8_t orientation;
|
80
81
|
|
81
82
|
struct lxw_drawing_objects *drawing_objects;
|
82
83
|
|
@@ -89,7 +90,7 @@ extern "C" {
|
|
89
90
|
#endif
|
90
91
|
/* *INDENT-ON* */
|
91
92
|
|
92
|
-
lxw_drawing *lxw_drawing_new();
|
93
|
+
lxw_drawing *lxw_drawing_new(void);
|
93
94
|
void lxw_drawing_free(lxw_drawing *drawing);
|
94
95
|
void lxw_drawing_assemble_xml_file(lxw_drawing *self);
|
95
96
|
void lxw_free_drawing_object(struct lxw_drawing_object *drawing_object);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*/
|
6
6
|
|
7
7
|
/**
|
@@ -480,7 +480,7 @@ extern "C" {
|
|
480
480
|
#endif
|
481
481
|
/* *INDENT-ON* */
|
482
482
|
|
483
|
-
lxw_format *lxw_format_new();
|
483
|
+
lxw_format *lxw_format_new(void);
|
484
484
|
void lxw_format_free(lxw_format *format);
|
485
485
|
int32_t lxw_format_get_xf_index(lxw_format *format);
|
486
486
|
lxw_font *lxw_format_get_font_key(lxw_format *format);
|
@@ -691,7 +691,7 @@ void format_set_num_format(lxw_format *format, const char *num_format);
|
|
691
691
|
*
|
692
692
|
* @code
|
693
693
|
* format = workbook_add_format(workbook);
|
694
|
-
*
|
694
|
+
* format_set_num_format_index(format, 0x0F); // d-mmm-yy
|
695
695
|
* @endcode
|
696
696
|
*
|
697
697
|
* @note
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*
|
6
6
|
* packager - A libxlsxwriter library for creating Excel XLSX packager files.
|
7
7
|
*
|
@@ -32,11 +32,17 @@
|
|
32
32
|
|
33
33
|
#define LXW_ZIP_BUFFER_SIZE (16384)
|
34
34
|
|
35
|
-
/* If
|
36
|
-
* return a default libxlsxwriter error. */
|
35
|
+
/* If zip returns a ZIP_XXX error then errno is set and we can trap that in
|
36
|
+
* workbook.c. Otherwise return a default libxlsxwriter error. */
|
37
37
|
#define RETURN_ON_ZIP_ERROR(err, default_err) \
|
38
|
-
if (err ==
|
38
|
+
if (err == ZIP_ERRNO) \
|
39
39
|
return LXW_ERROR_ZIP_FILE_OPERATION; \
|
40
|
+
else if (err == ZIP_PARAMERROR) \
|
41
|
+
return LXW_ERROR_ZIP_PARAMETER_ERROR; \
|
42
|
+
else if (err == ZIP_BADZIPFILE) \
|
43
|
+
return LXW_ERROR_ZIP_BAD_ZIP_FILE; \
|
44
|
+
else if (err == ZIP_INTERNALERROR) \
|
45
|
+
return LXW_ERROR_ZIP_INTERNAL_ERROR; \
|
40
46
|
else \
|
41
47
|
return default_err;
|
42
48
|
|
@@ -54,9 +60,7 @@ typedef struct lxw_packager {
|
|
54
60
|
char *filename;
|
55
61
|
char *buffer;
|
56
62
|
char *tmpdir;
|
57
|
-
|
58
|
-
uint16_t chart_count;
|
59
|
-
uint16_t drawing_count;
|
63
|
+
uint8_t use_zip64;
|
60
64
|
|
61
65
|
} lxw_packager;
|
62
66
|
|
@@ -67,7 +71,8 @@ extern "C" {
|
|
67
71
|
#endif
|
68
72
|
/* *INDENT-ON* */
|
69
73
|
|
70
|
-
lxw_packager *lxw_packager_new(const char *filename, char *tmpdir
|
74
|
+
lxw_packager *lxw_packager_new(const char *filename, char *tmpdir,
|
75
|
+
uint8_t use_zip64);
|
71
76
|
void lxw_packager_free(lxw_packager *packager);
|
72
77
|
lxw_error lxw_create_package(lxw_packager *self);
|
73
78
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*
|
6
6
|
* relationships - A libxlsxwriter library for creating Excel XLSX
|
7
7
|
* relationships files.
|
@@ -47,7 +47,7 @@ extern "C" {
|
|
47
47
|
#endif
|
48
48
|
/* *INDENT-ON* */
|
49
49
|
|
50
|
-
lxw_relationships *lxw_relationships_new();
|
50
|
+
lxw_relationships *lxw_relationships_new(void);
|
51
51
|
void lxw_free_relationships(lxw_relationships *relationships);
|
52
52
|
void lxw_relationships_assemble_xml_file(lxw_relationships *self);
|
53
53
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, 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.
|
@@ -37,6 +37,7 @@ STAILQ_HEAD(sst_order_list, sst_element);
|
|
37
37
|
struct sst_element {
|
38
38
|
uint32_t index;
|
39
39
|
char *string;
|
40
|
+
uint8_t is_rich_string;
|
40
41
|
|
41
42
|
STAILQ_ENTRY (sst_element) sst_order_pointers;
|
42
43
|
RB_ENTRY (sst_element) sst_tree_pointers;
|
@@ -62,9 +63,10 @@ extern "C" {
|
|
62
63
|
#endif
|
63
64
|
/* *INDENT-ON* */
|
64
65
|
|
65
|
-
lxw_sst *lxw_sst_new();
|
66
|
+
lxw_sst *lxw_sst_new(void);
|
66
67
|
void lxw_sst_free(lxw_sst *sst);
|
67
|
-
struct sst_element *lxw_get_sst_index(lxw_sst *sst, const char *string
|
68
|
+
struct sst_element *lxw_get_sst_index(lxw_sst *sst, const char *string,
|
69
|
+
uint8_t is_rich_string);
|
68
70
|
void lxw_sst_assemble_xml_file(lxw_sst *self);
|
69
71
|
|
70
72
|
/* Declarations required for unit testing. */
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*
|
6
6
|
* styles - A libxlsxwriter library for creating Excel XLSX styles files.
|
7
7
|
*
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#define __LXW_STYLES_H__
|
11
11
|
|
12
12
|
#include <stdint.h>
|
13
|
+
#include <ctype.h>
|
13
14
|
|
14
15
|
#include "format.h"
|
15
16
|
|
@@ -37,9 +38,11 @@ extern "C" {
|
|
37
38
|
#endif
|
38
39
|
/* *INDENT-ON* */
|
39
40
|
|
40
|
-
lxw_styles *lxw_styles_new();
|
41
|
+
lxw_styles *lxw_styles_new(void);
|
41
42
|
void lxw_styles_free(lxw_styles *styles);
|
42
43
|
void lxw_styles_assemble_xml_file(lxw_styles *self);
|
44
|
+
void lxw_styles_write_string_fragment(lxw_styles *self, char *string);
|
45
|
+
void lxw_styles_write_rich_font(lxw_styles *lxw_styles, lxw_format *format);
|
43
46
|
|
44
47
|
/* Declarations required for unit testing. */
|
45
48
|
#ifdef TESTING
|
@@ -48,10 +51,12 @@ STATIC void _styles_xml_declaration(lxw_styles *self);
|
|
48
51
|
STATIC void _write_style_sheet(lxw_styles *self);
|
49
52
|
STATIC void _write_font_size(lxw_styles *self, double font_size);
|
50
53
|
STATIC void _write_font_color_theme(lxw_styles *self, uint8_t theme);
|
51
|
-
STATIC void _write_font_name(lxw_styles *self, const char *font_name
|
54
|
+
STATIC void _write_font_name(lxw_styles *self, const char *font_name,
|
55
|
+
uint8_t is_rich_string);
|
52
56
|
STATIC void _write_font_family(lxw_styles *self, uint8_t font_family);
|
53
57
|
STATIC void _write_font_scheme(lxw_styles *self, const char *font_scheme);
|
54
|
-
STATIC void _write_font(lxw_styles *self, lxw_format *format
|
58
|
+
STATIC void _write_font(lxw_styles *self, lxw_format *format,
|
59
|
+
uint8_t is_rich_string);
|
55
60
|
STATIC void _write_fonts(lxw_styles *self);
|
56
61
|
STATIC void _write_default_fill(lxw_styles *self, const char *pattern);
|
57
62
|
STATIC void _write_fills(lxw_styles *self);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*
|
6
6
|
* theme - A libxlsxwriter library for creating Excel XLSX theme files.
|
7
7
|
*
|
@@ -28,7 +28,7 @@ extern "C" {
|
|
28
28
|
#endif
|
29
29
|
/* *INDENT-ON* */
|
30
30
|
|
31
|
-
lxw_theme *lxw_theme_new();
|
31
|
+
lxw_theme *lxw_theme_new(void);
|
32
32
|
void lxw_theme_free(lxw_theme *theme);
|
33
33
|
void lxw_theme_xml_declaration(lxw_theme *self);
|
34
34
|
void lxw_theme_assemble_xml_file(lxw_theme *self);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, 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-
|
12
|
+
* <!-- Copyright 2014-2019, John McNamara, jmcnamara@cpan.org -->
|
13
13
|
*
|
14
14
|
*/
|
15
15
|
|
@@ -17,6 +17,7 @@
|
|
17
17
|
#define __LXW_UTILITY_H__
|
18
18
|
|
19
19
|
#include <stdint.h>
|
20
|
+
#include <strings.h>
|
20
21
|
#include "common.h"
|
21
22
|
#include "xmlwriter.h"
|
22
23
|
|
@@ -86,6 +87,20 @@ extern "C" {
|
|
86
87
|
#endif
|
87
88
|
/* *INDENT-ON* */
|
88
89
|
|
90
|
+
/**
|
91
|
+
* @brief Retrieve the library version.
|
92
|
+
*
|
93
|
+
* @return The "X.Y.Z" version string.
|
94
|
+
*
|
95
|
+
* Get the library version as a "X.Y.Z" version string
|
96
|
+
*
|
97
|
+
* @code
|
98
|
+
* printf("Libxlsxwriter version = %s\n", lxw_version());
|
99
|
+
* @endcode
|
100
|
+
*
|
101
|
+
*/
|
102
|
+
const char *lxw_version(void);
|
103
|
+
|
89
104
|
/**
|
90
105
|
* @brief Converts a libxlsxwriter error number to a string.
|
91
106
|
*
|
@@ -152,6 +167,13 @@ size_t lxw_utf8_strlen(const char *str);
|
|
152
167
|
|
153
168
|
void lxw_str_tolower(char *str);
|
154
169
|
|
170
|
+
/* Define a portable version of strcasecmp(). */
|
171
|
+
#ifdef _MSC_VER
|
172
|
+
#define lxw_strcasecmp _stricmp
|
173
|
+
#else
|
174
|
+
#define lxw_strcasecmp strcasecmp
|
175
|
+
#endif
|
176
|
+
|
155
177
|
FILE *lxw_tmpfile(char *tmpdir);
|
156
178
|
|
157
179
|
/* Use a user defined function to format doubles in sprintf or else a simple
|
@@ -163,6 +185,8 @@ int lxw_sprintf_dbl(char *data, double number);
|
|
163
185
|
lxw_snprintf(data, LXW_ATTR_32, "%.16g", number)
|
164
186
|
#endif
|
165
187
|
|
188
|
+
uint16_t lxw_hash_password(const char *password);
|
189
|
+
|
166
190
|
/* *INDENT-OFF* */
|
167
191
|
#ifdef __cplusplus
|
168
192
|
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/*
|
2
2
|
* libxlsxwriter
|
3
3
|
*
|
4
|
-
* Copyright 2014-
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
5
|
*/
|
6
6
|
|
7
7
|
/**
|
@@ -46,6 +46,7 @@
|
|
46
46
|
#include <errno.h>
|
47
47
|
|
48
48
|
#include "worksheet.h"
|
49
|
+
#include "chartsheet.h"
|
49
50
|
#include "chart.h"
|
50
51
|
#include "shared_strings.h"
|
51
52
|
#include "hash_table.h"
|
@@ -55,12 +56,27 @@
|
|
55
56
|
|
56
57
|
/* Define the tree.h RB structs for the red-black head types. */
|
57
58
|
RB_HEAD(lxw_worksheet_names, lxw_worksheet_name);
|
59
|
+
RB_HEAD(lxw_chartsheet_names, lxw_chartsheet_name);
|
58
60
|
|
59
61
|
/* Define the queue.h structs for the workbook lists. */
|
62
|
+
STAILQ_HEAD(lxw_sheets, lxw_sheet);
|
60
63
|
STAILQ_HEAD(lxw_worksheets, lxw_worksheet);
|
64
|
+
STAILQ_HEAD(lxw_chartsheets, lxw_chartsheet);
|
61
65
|
STAILQ_HEAD(lxw_charts, lxw_chart);
|
62
66
|
TAILQ_HEAD(lxw_defined_names, lxw_defined_name);
|
63
67
|
|
68
|
+
/* TODO */
|
69
|
+
typedef struct lxw_sheet {
|
70
|
+
uint8_t is_chartsheet;
|
71
|
+
|
72
|
+
union {
|
73
|
+
lxw_worksheet *worksheet;
|
74
|
+
lxw_chartsheet *chartsheet;
|
75
|
+
} u;
|
76
|
+
|
77
|
+
STAILQ_ENTRY (lxw_sheet) list_pointers;
|
78
|
+
} lxw_sheet;
|
79
|
+
|
64
80
|
/* Struct to represent a worksheet name/pointer pair. */
|
65
81
|
typedef struct lxw_worksheet_name {
|
66
82
|
const char *name;
|
@@ -69,18 +85,37 @@ typedef struct lxw_worksheet_name {
|
|
69
85
|
RB_ENTRY (lxw_worksheet_name) tree_pointers;
|
70
86
|
} lxw_worksheet_name;
|
71
87
|
|
88
|
+
/* Struct to represent a chartsheet name/pointer pair. */
|
89
|
+
typedef struct lxw_chartsheet_name {
|
90
|
+
const char *name;
|
91
|
+
lxw_chartsheet *chartsheet;
|
92
|
+
|
93
|
+
RB_ENTRY (lxw_chartsheet_name) tree_pointers;
|
94
|
+
} lxw_chartsheet_name;
|
95
|
+
|
72
96
|
/* Wrapper around RB_GENERATE_STATIC from tree.h to avoid unused function
|
73
97
|
* warnings and to avoid portability issues with the _unused attribute. */
|
74
|
-
#define
|
75
|
-
RB_GENERATE_INSERT_COLOR(name, type, field, static)
|
76
|
-
RB_GENERATE_REMOVE_COLOR(name, type, field, static)
|
77
|
-
RB_GENERATE_INSERT(name, type, field, cmp, static)
|
78
|
-
RB_GENERATE_REMOVE(name, type, field, static)
|
79
|
-
RB_GENERATE_FIND(name, type, field, cmp, static)
|
80
|
-
RB_GENERATE_NEXT(name, type, field, static)
|
81
|
-
RB_GENERATE_MINMAX(name, type, field, static)
|
82
|
-
/* Add unused struct to allow adding a semicolon */
|
83
|
-
struct
|
98
|
+
#define LXW_RB_GENERATE_WORKSHEET_NAMES(name, type, field, cmp) \
|
99
|
+
RB_GENERATE_INSERT_COLOR(name, type, field, static) \
|
100
|
+
RB_GENERATE_REMOVE_COLOR(name, type, field, static) \
|
101
|
+
RB_GENERATE_INSERT(name, type, field, cmp, static) \
|
102
|
+
RB_GENERATE_REMOVE(name, type, field, static) \
|
103
|
+
RB_GENERATE_FIND(name, type, field, cmp, static) \
|
104
|
+
RB_GENERATE_NEXT(name, type, field, static) \
|
105
|
+
RB_GENERATE_MINMAX(name, type, field, static) \
|
106
|
+
/* Add unused struct to allow adding a semicolon */ \
|
107
|
+
struct lxw_rb_generate_worksheet_names{int unused;}
|
108
|
+
|
109
|
+
#define LXW_RB_GENERATE_CHARTSHEET_NAMES(name, type, field, cmp) \
|
110
|
+
RB_GENERATE_INSERT_COLOR(name, type, field, static) \
|
111
|
+
RB_GENERATE_REMOVE_COLOR(name, type, field, static) \
|
112
|
+
RB_GENERATE_INSERT(name, type, field, cmp, static) \
|
113
|
+
RB_GENERATE_REMOVE(name, type, field, static) \
|
114
|
+
RB_GENERATE_FIND(name, type, field, cmp, static) \
|
115
|
+
RB_GENERATE_NEXT(name, type, field, static) \
|
116
|
+
RB_GENERATE_MINMAX(name, type, field, static) \
|
117
|
+
/* Add unused struct to allow adding a semicolon */ \
|
118
|
+
struct lxw_rb_generate_charsheet_names{int unused;}
|
84
119
|
|
85
120
|
/**
|
86
121
|
* @brief Macro to loop over all the worksheets in a workbook.
|
@@ -168,27 +203,40 @@ typedef struct lxw_doc_properties {
|
|
168
203
|
*
|
169
204
|
* The following properties are supported:
|
170
205
|
*
|
171
|
-
* - `constant_memory`:
|
172
|
-
* large files can be written efficiently.
|
173
|
-
*
|
174
|
-
* @note In this mode a row of data is written and then discarded when a
|
175
|
-
* cell in a new row is added via one of the `worksheet_write_*()`
|
176
|
-
* functions. Therefore, once this option is active, data should be written in
|
177
|
-
* sequential row order. For this reason the `worksheet_merge_range()`
|
178
|
-
* doesn't work in this mode. See also @ref ww_mem_constant.
|
206
|
+
* - `constant_memory`: This option reduces the amount of data stored in
|
207
|
+
* memory so that large files can be written efficiently. This option is off
|
208
|
+
* by default. See the note below for limitations when this mode is on.
|
179
209
|
*
|
180
|
-
* - `tmpdir`: libxlsxwriter stores workbook data in temporary files prior
|
181
|
-
*
|
210
|
+
* - `tmpdir`: libxlsxwriter stores workbook data in temporary files prior to
|
211
|
+
* assembling the final XLSX file. The temporary files are created in the
|
182
212
|
* system's temp directory. If the default temporary directory isn't
|
183
213
|
* accessible to your application, or doesn't contain enough space, you can
|
184
|
-
* specify an alternative location using the `
|
214
|
+
* specify an alternative location using the `tmpdir` option.
|
215
|
+
*
|
216
|
+
* - `use_zip64`: Make the zip library use ZIP64 extensions when writing very
|
217
|
+
* large xlsx files to allow the zip container, or individual XML files
|
218
|
+
* within it, to be greater than 4 GB. See [ZIP64 on Wikipedia][zip64_wiki]
|
219
|
+
* for more information. This option is off by default.
|
220
|
+
*
|
221
|
+
* [zip64_wiki]: https://en.wikipedia.org/wiki/Zip_(file_format)#ZIP64
|
222
|
+
*
|
223
|
+
* @note In `constant_memory` mode a row of data is written and then discarded
|
224
|
+
* when a cell in a new row is added via one of the `worksheet_write_*()`
|
225
|
+
* functions. Therefore, once this option is active, data should be written in
|
226
|
+
* sequential row order. For this reason the `worksheet_merge_range()` doesn't
|
227
|
+
* work in this mode. See also @ref ww_mem_constant.
|
228
|
+
*
|
185
229
|
*/
|
186
230
|
typedef struct lxw_workbook_options {
|
187
|
-
/** Optimize the workbook to use constant memory for worksheets */
|
231
|
+
/** Optimize the workbook to use constant memory for worksheets. */
|
188
232
|
uint8_t constant_memory;
|
189
233
|
|
190
234
|
/** Directory to use for the temporary files created by libxlsxwriter. */
|
191
235
|
char *tmpdir;
|
236
|
+
|
237
|
+
/** Allow ZIP64 extensions when creating the xlsx file zip container. */
|
238
|
+
uint8_t use_zip64;
|
239
|
+
|
192
240
|
} lxw_workbook_options;
|
193
241
|
|
194
242
|
/**
|
@@ -201,8 +249,11 @@ typedef struct lxw_workbook_options {
|
|
201
249
|
typedef struct lxw_workbook {
|
202
250
|
|
203
251
|
FILE *file;
|
252
|
+
struct lxw_sheets *sheets;
|
204
253
|
struct lxw_worksheets *worksheets;
|
254
|
+
struct lxw_chartsheets *chartsheets;
|
205
255
|
struct lxw_worksheet_names *worksheet_names;
|
256
|
+
struct lxw_chartsheet_names *chartsheet_names;
|
206
257
|
struct lxw_charts *charts;
|
207
258
|
struct lxw_charts *ordered_charts;
|
208
259
|
struct lxw_formats *formats;
|
@@ -215,6 +266,8 @@ typedef struct lxw_workbook {
|
|
215
266
|
lxw_workbook_options options;
|
216
267
|
|
217
268
|
uint16_t num_sheets;
|
269
|
+
uint16_t num_worksheets;
|
270
|
+
uint16_t num_chartsheets;
|
218
271
|
uint16_t first_sheet;
|
219
272
|
uint16_t active_sheet;
|
220
273
|
uint16_t num_xf_formats;
|
@@ -232,6 +285,9 @@ typedef struct lxw_workbook {
|
|
232
285
|
|
233
286
|
lxw_hash_table *used_xf_formats;
|
234
287
|
|
288
|
+
char *vba_project;
|
289
|
+
char *vba_codename;
|
290
|
+
|
235
291
|
} lxw_workbook;
|
236
292
|
|
237
293
|
|
@@ -273,30 +329,37 @@ lxw_workbook *workbook_new(const char *filename);
|
|
273
329
|
* additional options to be set.
|
274
330
|
*
|
275
331
|
* @code
|
276
|
-
* lxw_workbook_options options = {.constant_memory =
|
277
|
-
* .tmpdir = "C:\\Temp"
|
332
|
+
* lxw_workbook_options options = {.constant_memory = LXW_TRUE,
|
333
|
+
* .tmpdir = "C:\\Temp",
|
334
|
+
* .use_zip64 = LXW_FALSE};
|
278
335
|
*
|
279
336
|
* lxw_workbook *workbook = workbook_new_opt("filename.xlsx", &options);
|
280
337
|
* @endcode
|
281
338
|
*
|
282
339
|
* The options that can be set via #lxw_workbook_options are:
|
283
340
|
*
|
284
|
-
* - `constant_memory`:
|
285
|
-
* large files can be written efficiently.
|
286
|
-
*
|
287
|
-
* @note In this mode a row of data is written and then discarded when a
|
288
|
-
* cell in a new row is added via one of the `worksheet_write_*()`
|
289
|
-
* functions. Therefore, once this option is active, data should be written in
|
290
|
-
* sequential row order. For this reason the `worksheet_merge_range()`
|
291
|
-
* doesn't work in this mode. See also @ref ww_mem_constant.
|
341
|
+
* - `constant_memory`: This option reduces the amount of data stored in
|
342
|
+
* memory so that large files can be written efficiently. This option is off
|
343
|
+
* by default. See the note below for limitations when this mode is on.
|
292
344
|
*
|
293
|
-
* - `tmpdir`: libxlsxwriter stores workbook data in temporary files prior
|
294
|
-
*
|
345
|
+
* - `tmpdir`: libxlsxwriter stores workbook data in temporary files prior to
|
346
|
+
* assembling the final XLSX file. The temporary files are created in the
|
295
347
|
* system's temp directory. If the default temporary directory isn't
|
296
348
|
* accessible to your application, or doesn't contain enough space, you can
|
297
|
-
* specify an alternative location using the `
|
349
|
+
* specify an alternative location using the `tmpdir` option.
|
298
350
|
*
|
299
|
-
*
|
351
|
+
* - `use_zip64`: Make the zip library use ZIP64 extensions when writing very
|
352
|
+
* large xlsx files to allow the zip container, or individual XML files
|
353
|
+
* within it, to be greater than 4 GB. See [ZIP64 on Wikipedia][zip64_wiki]
|
354
|
+
* for more information. This option is off by default.
|
355
|
+
*
|
356
|
+
* [zip64_wiki]: https://en.wikipedia.org/wiki/Zip_(file_format)#ZIP64
|
357
|
+
*
|
358
|
+
* @note In `constant_memory` mode a row of data is written and then discarded
|
359
|
+
* when a cell in a new row is added via one of the `worksheet_write_*()`
|
360
|
+
* functions. Therefore, once this option is active, data should be written in
|
361
|
+
* sequential row order. For this reason the `worksheet_merge_range()` doesn't
|
362
|
+
* work in this mode. See also @ref ww_mem_constant.
|
300
363
|
*
|
301
364
|
*/
|
302
365
|
lxw_workbook *workbook_new_opt(const char *filename,
|
@@ -317,7 +380,7 @@ lxw_workbook *new_workbook_opt(const char *filename,
|
|
317
380
|
*
|
318
381
|
* @return A lxw_worksheet object.
|
319
382
|
*
|
320
|
-
* The `%workbook_add_worksheet()` function adds a new worksheet to a workbook
|
383
|
+
* The `%workbook_add_worksheet()` function adds a new worksheet to a workbook.
|
321
384
|
*
|
322
385
|
* At least one worksheet should be added to a new workbook: The @ref
|
323
386
|
* worksheet.h "Worksheet" object is used to write data and configure a
|
@@ -336,18 +399,65 @@ lxw_workbook *new_workbook_opt(const char *filename,
|
|
336
399
|
*
|
337
400
|
* @image html workbook02.png
|
338
401
|
*
|
339
|
-
* The worksheet name must be a valid Excel worksheet name, i.e
|
340
|
-
* less than 32 character and it cannot contain any of the characters:
|
402
|
+
* The worksheet name must be a valid Excel worksheet name, i.e:
|
341
403
|
*
|
342
|
-
*
|
343
|
-
*
|
344
|
-
*
|
345
|
-
*
|
404
|
+
* - The name is less than or equal to 31 UTF-8 characters.
|
405
|
+
* - The name doesn't contain any of the characters: ` [ ] : * ? / \ `
|
406
|
+
* - The name doesn't start or end with an apostrophe.
|
407
|
+
* - The name isn't "History", which is reserved by Excel. (Case insensitive).
|
408
|
+
* - The name isn't already in use. (Case insensitive).
|
346
409
|
*
|
410
|
+
* If any of these errors are encountered the function will return NULL.
|
411
|
+
* You can check for valid name using the `workbook_validate_sheet_name()`
|
412
|
+
* function.
|
347
413
|
*/
|
348
414
|
lxw_worksheet *workbook_add_worksheet(lxw_workbook *workbook,
|
349
415
|
const char *sheetname);
|
350
416
|
|
417
|
+
/**
|
418
|
+
* @brief Add a new chartsheet to a workbook.
|
419
|
+
*
|
420
|
+
* @param workbook Pointer to a lxw_workbook instance.
|
421
|
+
* @param sheetname Optional chartsheet name, defaults to Chart1, etc.
|
422
|
+
*
|
423
|
+
* @return A lxw_chartsheet object.
|
424
|
+
*
|
425
|
+
* The `%workbook_add_chartsheet()` function adds a new chartsheet to a
|
426
|
+
* workbook. The @ref chartsheet.h "Chartsheet" object is like a worksheet
|
427
|
+
* except it displays a chart instead of cell data.
|
428
|
+
*
|
429
|
+
* @image html chartsheet.png
|
430
|
+
*
|
431
|
+
* The `sheetname` parameter is optional. If it is `NULL` the default
|
432
|
+
* Excel convention will be followed, i.e. Chart1, Chart2, etc.:
|
433
|
+
*
|
434
|
+
* @code
|
435
|
+
* chartsheet = workbook_add_chartsheet(workbook, NULL ); // Chart1
|
436
|
+
* chartsheet = workbook_add_chartsheet(workbook, "My Chart"); // My Chart
|
437
|
+
* chartsheet = workbook_add_chartsheet(workbook, NULL ); // Chart3
|
438
|
+
*
|
439
|
+
* @endcode
|
440
|
+
*
|
441
|
+
* The chartsheet name must be a valid Excel worksheet name, i.e.:
|
442
|
+
*
|
443
|
+
* - The name is less than or equal to 31 UTF-8 characters.
|
444
|
+
* - The name doesn't contain any of the characters: ` [ ] : * ? / \ `
|
445
|
+
* - The name doesn't start or end with an apostrophe.
|
446
|
+
* - The name isn't "History", which is reserved by Excel. (Case insensitive).
|
447
|
+
* - The name isn't already in use. (Case insensitive).
|
448
|
+
*
|
449
|
+
* If any of these errors are encountered the function will return NULL.
|
450
|
+
* You can check for valid name using the `workbook_validate_sheet_name()`
|
451
|
+
* function.
|
452
|
+
*
|
453
|
+
* At least one worksheet should be added to a new workbook when creating a
|
454
|
+
* chartsheet in order to provide data for the chart. The @ref worksheet.h
|
455
|
+
* "Worksheet" object is used to write data and configure a worksheet in the
|
456
|
+
* workbook.
|
457
|
+
*/
|
458
|
+
lxw_chartsheet *workbook_add_chartsheet(lxw_workbook *workbook,
|
459
|
+
const char *sheetname);
|
460
|
+
|
351
461
|
/**
|
352
462
|
* @brief Create a new @ref format.h "Format" object to formats cells in
|
353
463
|
* worksheets.
|
@@ -693,31 +803,98 @@ lxw_worksheet *workbook_get_worksheet_by_name(lxw_workbook *workbook,
|
|
693
803
|
const char *name);
|
694
804
|
|
695
805
|
/**
|
696
|
-
* @brief
|
806
|
+
* @brief Get a chartsheet object from its name.
|
807
|
+
*
|
808
|
+
* @param workbook Pointer to a lxw_workbook instance.
|
809
|
+
* @param name chartsheet name.
|
810
|
+
*
|
811
|
+
* @return A lxw_chartsheet object.
|
812
|
+
*
|
813
|
+
* This function returns a lxw_chartsheet object reference based on its name:
|
814
|
+
*
|
815
|
+
* @code
|
816
|
+
* chartsheet = workbook_get_chartsheet_by_name(workbook, "Chart1");
|
817
|
+
* @endcode
|
818
|
+
*
|
819
|
+
*/
|
820
|
+
lxw_chartsheet *workbook_get_chartsheet_by_name(lxw_workbook *workbook,
|
821
|
+
const char *name);
|
822
|
+
|
823
|
+
/**
|
824
|
+
* @brief Validate a worksheet or chartsheet name.
|
697
825
|
*
|
698
826
|
* @param workbook Pointer to a lxw_workbook instance.
|
699
|
-
* @param sheetname
|
827
|
+
* @param sheetname Sheet name to validate.
|
700
828
|
*
|
701
829
|
* @return A #lxw_error.
|
702
830
|
*
|
703
|
-
* This function is used to validate a worksheet name according
|
704
|
-
* used by Excel:
|
831
|
+
* This function is used to validate a worksheet or chartsheet name according
|
832
|
+
* to the rules used by Excel:
|
705
833
|
*
|
706
834
|
* - The name is less than or equal to 31 UTF-8 characters.
|
707
835
|
* - The name doesn't contain any of the characters: ` [ ] : * ? / \ `
|
708
|
-
* - The name
|
836
|
+
* - The name doesn't start or end with an apostrophe.
|
837
|
+
* - The name isn't "History", which is reserved by Excel. (Case insensitive).
|
838
|
+
* - The name isn't already in use. (Case insensitive, see the note below).
|
709
839
|
*
|
710
840
|
* @code
|
711
|
-
* lxw_error err =
|
841
|
+
* lxw_error err = workbook_validate_sheet_name(workbook, "Foglio");
|
712
842
|
* @endcode
|
713
843
|
*
|
714
|
-
* This function is called by `workbook_add_worksheet()`
|
715
|
-
*
|
716
|
-
* name is valid.
|
844
|
+
* This function is called by `workbook_add_worksheet()` and
|
845
|
+
* `workbook_add_chartsheet()` but it can be explicitly called by the user
|
846
|
+
* beforehand to ensure that the sheet name is valid.
|
847
|
+
*
|
848
|
+
* @note This function does an ASCII lowercase string comparison to determine
|
849
|
+
* if the sheet name is already in use. It doesn't take UTF-8 characters into
|
850
|
+
* account. Thus it would flag "Café" and "café" as a duplicate (just like
|
851
|
+
* Excel) but it wouldn't catch "CAFÉ". If you need a full UTF-8 case
|
852
|
+
* insensitive check you should use a third party library to implement it.
|
853
|
+
*
|
854
|
+
*/
|
855
|
+
lxw_error workbook_validate_sheet_name(lxw_workbook *workbook,
|
856
|
+
const char *sheetname);
|
857
|
+
|
858
|
+
/**
|
859
|
+
* @brief Add a vbaProject binary to the Excel workbook.
|
860
|
+
*
|
861
|
+
* @param workbook Pointer to a lxw_workbook instance.
|
862
|
+
* @param filename The path/filename of the vbaProject.bin file.
|
717
863
|
*
|
864
|
+
* The `%workbook_add_vba_project()` function can be used to add macros or
|
865
|
+
* functions to a workbook using a binary VBA project file that has been
|
866
|
+
* extracted from an existing Excel xlsm file:
|
867
|
+
*
|
868
|
+
* @code
|
869
|
+
* workbook_add_vba_project(workbook, "vbaProject.bin");
|
870
|
+
* @endcode
|
871
|
+
*
|
872
|
+
* Only one `vbaProject.bin file` can be added per workbook.
|
873
|
+
*
|
874
|
+
* @return A #lxw_error.
|
875
|
+
*/
|
876
|
+
lxw_error workbook_add_vba_project(lxw_workbook *workbook,
|
877
|
+
const char *filename);
|
878
|
+
|
879
|
+
/**
|
880
|
+
* @brief Set the VBA name for the workbook.
|
881
|
+
*
|
882
|
+
* @param workbook Pointer to a lxw_workbook instance.
|
883
|
+
* @param name Name of the workbook used by VBA.
|
884
|
+
*
|
885
|
+
* The `workbook_set_vba_name()` function can be used to set the VBA name for
|
886
|
+
* the workbook. This is sometimes required when a vbaProject macro included
|
887
|
+
* via `workbook_add_vba_project()` refers to the workbook.
|
888
|
+
*
|
889
|
+
* @code
|
890
|
+
* workbook_set_vba_name(workbook, "MyWorkbook");
|
891
|
+
* @endcode
|
892
|
+
*
|
893
|
+
* The most common Excel VBA name for a workbook is `ThisWorkbook`.
|
894
|
+
*
|
895
|
+
* @return A #lxw_error.
|
718
896
|
*/
|
719
|
-
lxw_error
|
720
|
-
const char *sheetname);
|
897
|
+
lxw_error workbook_set_vba_name(lxw_workbook *workbook, const char *name);
|
721
898
|
|
722
899
|
void lxw_workbook_free(lxw_workbook *workbook);
|
723
900
|
void lxw_workbook_assemble_xml_file(lxw_workbook *workbook);
|