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.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -7
- data/CHANGELOG.md +9 -0
- data/Gemfile +1 -1
- data/examples/example.rb +2 -0
- data/examples/example_date_time.rb +38 -0
- data/fast_excel.gemspec +2 -2
- data/lib/fast_excel/binding/format.rb +17 -0
- data/lib/fast_excel/binding/workbook.rb +39 -17
- data/lib/fast_excel/binding/worksheet.rb +57 -13
- data/lib/fast_excel/binding.rb +7 -7
- data/lib/fast_excel.rb +27 -20
- data/libxlsxwriter/.github/FUNDING.yml +1 -0
- data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
- data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
- data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
- data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
- data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
- data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
- data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
- data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
- data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
- data/libxlsxwriter/.gitignore +16 -1
- data/libxlsxwriter/.indent.pro +24 -0
- data/libxlsxwriter/CMakeLists.txt +156 -56
- data/libxlsxwriter/CONTRIBUTING.md +2 -2
- data/libxlsxwriter/Changes.txt +344 -2
- data/libxlsxwriter/LICENSE.txt +66 -8
- data/libxlsxwriter/Makefile +151 -54
- data/libxlsxwriter/Package.swift +42 -0
- data/libxlsxwriter/Readme.md +4 -2
- data/libxlsxwriter/build.zig +324 -0
- data/libxlsxwriter/build.zig.zon +11 -0
- data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
- data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
- data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
- data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
- data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
- data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
- data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
- data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
- data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
- data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
- data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
- data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
- data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
- data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
- data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
- data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
- data/libxlsxwriter/include/xlsxwriter.h +4 -2
- data/libxlsxwriter/libxlsxwriter.podspec +8 -5
- data/libxlsxwriter/src/Makefile +58 -21
- data/libxlsxwriter/src/app.c +5 -2
- data/libxlsxwriter/src/chart.c +396 -81
- data/libxlsxwriter/src/chartsheet.c +22 -22
- data/libxlsxwriter/src/comment.c +443 -0
- data/libxlsxwriter/src/content_types.c +40 -1
- data/libxlsxwriter/src/core.c +2 -2
- data/libxlsxwriter/src/custom.c +1 -1
- data/libxlsxwriter/src/drawing.c +160 -40
- data/libxlsxwriter/src/format.c +109 -25
- data/libxlsxwriter/src/hash_table.c +1 -1
- data/libxlsxwriter/src/metadata.c +283 -0
- data/libxlsxwriter/src/packager.c +794 -94
- data/libxlsxwriter/src/relationships.c +1 -1
- data/libxlsxwriter/src/shared_strings.c +2 -4
- data/libxlsxwriter/src/styles.c +353 -58
- data/libxlsxwriter/src/table.c +304 -0
- data/libxlsxwriter/src/theme.c +1 -1
- data/libxlsxwriter/src/utility.c +143 -43
- data/libxlsxwriter/src/vml.c +1062 -0
- data/libxlsxwriter/src/workbook.c +567 -77
- data/libxlsxwriter/src/worksheet.c +6668 -1462
- data/libxlsxwriter/src/xmlwriter.c +95 -5
- data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
- data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
- data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
- data/libxlsxwriter/third_party/md5/Makefile +42 -0
- data/libxlsxwriter/third_party/md5/md5.c +291 -0
- data/libxlsxwriter/third_party/md5/md5.h +45 -0
- data/libxlsxwriter/third_party/minizip/Makefile +3 -8
- data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
- data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
- data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
- data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
- data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
- data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
- data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
- data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
- data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
- data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
- data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
- data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
- data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
- data/libxlsxwriter/third_party/minizip/zip.c +165 -218
- data/libxlsxwriter/third_party/minizip/zip.h +164 -154
- data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
- data/libxlsxwriter/version.txt +1 -1
- data/test/auto_width_test.rb +20 -0
- data/test/default_format_test.rb +1 -1
- data/test/validations_test.rb +3 -3
- data/test/worksheet_test.rb +6 -1
- metadata +33 -7
- data/libxlsxwriter/.travis.yml +0 -37
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used in conjunction with the libxlsxwriter library.
|
|
5
5
|
*
|
|
6
|
-
* Copyright 2014-
|
|
6
|
+
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -66,8 +66,8 @@ lxw_chartsheet_free(lxw_chartsheet *chartsheet)
|
|
|
66
66
|
return;
|
|
67
67
|
|
|
68
68
|
lxw_worksheet_free(chartsheet->worksheet);
|
|
69
|
-
free(chartsheet->name);
|
|
70
|
-
free(chartsheet->quoted_name);
|
|
69
|
+
free((void *) chartsheet->name);
|
|
70
|
+
free((void *) chartsheet->quoted_name);
|
|
71
71
|
free(chartsheet);
|
|
72
72
|
}
|
|
73
73
|
|
|
@@ -225,9 +225,9 @@ lxw_chartsheet_assemble_xml_file(lxw_chartsheet *self)
|
|
|
225
225
|
*/
|
|
226
226
|
lxw_error
|
|
227
227
|
chartsheet_set_chart_opt(lxw_chartsheet *self,
|
|
228
|
-
lxw_chart *chart,
|
|
228
|
+
lxw_chart *chart, lxw_chart_options *user_options)
|
|
229
229
|
{
|
|
230
|
-
|
|
230
|
+
lxw_object_properties *object_props;
|
|
231
231
|
lxw_chart_series *series;
|
|
232
232
|
|
|
233
233
|
if (!chart) {
|
|
@@ -260,32 +260,32 @@ chartsheet_set_chart_opt(lxw_chartsheet *self,
|
|
|
260
260
|
}
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
/* Create a new object to hold the chart image
|
|
264
|
-
|
|
265
|
-
RETURN_ON_MEM_ERROR(
|
|
263
|
+
/* Create a new object to hold the chart image properties. */
|
|
264
|
+
object_props = calloc(1, sizeof(lxw_object_properties));
|
|
265
|
+
RETURN_ON_MEM_ERROR(object_props, LXW_ERROR_MEMORY_MALLOC_FAILED);
|
|
266
266
|
|
|
267
267
|
if (user_options) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
268
|
+
object_props->x_offset = user_options->x_offset;
|
|
269
|
+
object_props->y_offset = user_options->y_offset;
|
|
270
|
+
object_props->x_scale = user_options->x_scale;
|
|
271
|
+
object_props->y_scale = user_options->y_scale;
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
options->height = 288;
|
|
274
|
+
object_props->width = 480;
|
|
275
|
+
object_props->height = 288;
|
|
277
276
|
|
|
278
|
-
if (
|
|
279
|
-
|
|
277
|
+
if (object_props->x_scale == 0.0)
|
|
278
|
+
object_props->x_scale = 1;
|
|
280
279
|
|
|
281
|
-
if (
|
|
282
|
-
|
|
280
|
+
if (object_props->y_scale == 0.0)
|
|
281
|
+
object_props->y_scale = 1;
|
|
283
282
|
|
|
284
283
|
/* Store chart references so they can be ordered in the workbook. */
|
|
285
|
-
|
|
284
|
+
object_props->chart = chart;
|
|
286
285
|
|
|
287
286
|
/* Store the chart data in the embedded worksheet. */
|
|
288
|
-
STAILQ_INSERT_TAIL(self->worksheet->chart_data,
|
|
287
|
+
STAILQ_INSERT_TAIL(self->worksheet->chart_data, object_props,
|
|
288
|
+
list_pointers);
|
|
289
289
|
|
|
290
290
|
chart->in_use = LXW_TRUE;
|
|
291
291
|
chart->is_chartsheet = LXW_TRUE;
|
|
@@ -385,7 +385,7 @@ void
|
|
|
385
385
|
chartsheet_protect(lxw_chartsheet *self, const char *password,
|
|
386
386
|
lxw_protection *options)
|
|
387
387
|
{
|
|
388
|
-
struct
|
|
388
|
+
struct lxw_protection_obj *protect = &self->protection;
|
|
389
389
|
|
|
390
390
|
/* Copy any user parameters to the internal structure. */
|
|
391
391
|
if (options) {
|
|
@@ -0,0 +1,443 @@
|
|
|
1
|
+
/*****************************************************************************
|
|
2
|
+
* comment - A library for creating Excel XLSX comment files.
|
|
3
|
+
*
|
|
4
|
+
* Used in conjunction with the libxlsxwriter library.
|
|
5
|
+
*
|
|
6
|
+
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
#include "xlsxwriter/xmlwriter.h"
|
|
11
|
+
#include "xlsxwriter/comment.h"
|
|
12
|
+
#include "xlsxwriter/utility.h"
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Forward declarations.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
STATIC int _author_id_cmp(lxw_author_id *tuple1, lxw_author_id *tuple2);
|
|
19
|
+
|
|
20
|
+
#ifndef __clang_analyzer__
|
|
21
|
+
LXW_RB_GENERATE_AUTHOR_IDS(lxw_author_ids, lxw_author_id,
|
|
22
|
+
tree_pointers, _author_id_cmp);
|
|
23
|
+
#endif
|
|
24
|
+
|
|
25
|
+
/*****************************************************************************
|
|
26
|
+
*
|
|
27
|
+
* Private functions.
|
|
28
|
+
*
|
|
29
|
+
****************************************************************************/
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* Comparator for the author ids.
|
|
33
|
+
*/
|
|
34
|
+
STATIC int
|
|
35
|
+
_author_id_cmp(lxw_author_id *author_id1, lxw_author_id *author_id2)
|
|
36
|
+
{
|
|
37
|
+
return strcmp(author_id1->author, author_id2->author);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/*
|
|
41
|
+
* Check if an author already existing in the author/id table.
|
|
42
|
+
*/
|
|
43
|
+
STATIC uint8_t
|
|
44
|
+
_check_author(lxw_comment *self, char *author)
|
|
45
|
+
{
|
|
46
|
+
lxw_author_id tmp_author_id;
|
|
47
|
+
lxw_author_id *existing_author = NULL;
|
|
48
|
+
|
|
49
|
+
if (!author)
|
|
50
|
+
return LXW_TRUE;
|
|
51
|
+
|
|
52
|
+
tmp_author_id.author = author;
|
|
53
|
+
existing_author = RB_FIND(lxw_author_ids,
|
|
54
|
+
self->author_ids, &tmp_author_id);
|
|
55
|
+
|
|
56
|
+
if (existing_author)
|
|
57
|
+
return LXW_TRUE;
|
|
58
|
+
else
|
|
59
|
+
return LXW_FALSE;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
* Get the index used for an author name.
|
|
64
|
+
*/
|
|
65
|
+
STATIC uint32_t
|
|
66
|
+
_get_author_index(lxw_comment *self, char *author)
|
|
67
|
+
{
|
|
68
|
+
lxw_author_id tmp_author_id;
|
|
69
|
+
lxw_author_id *existing_author = NULL;
|
|
70
|
+
lxw_author_id *new_author_id = NULL;
|
|
71
|
+
|
|
72
|
+
if (!author)
|
|
73
|
+
return 0;
|
|
74
|
+
|
|
75
|
+
tmp_author_id.author = author;
|
|
76
|
+
existing_author = RB_FIND(lxw_author_ids,
|
|
77
|
+
self->author_ids, &tmp_author_id);
|
|
78
|
+
|
|
79
|
+
if (existing_author) {
|
|
80
|
+
return existing_author->id;
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
new_author_id = calloc(1, sizeof(lxw_author_id));
|
|
84
|
+
|
|
85
|
+
if (new_author_id) {
|
|
86
|
+
new_author_id->id = self->author_id;
|
|
87
|
+
new_author_id->author = lxw_strdup(author);
|
|
88
|
+
self->author_id++;
|
|
89
|
+
|
|
90
|
+
RB_INSERT(lxw_author_ids, self->author_ids, new_author_id);
|
|
91
|
+
|
|
92
|
+
return new_author_id->id;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
return 0;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/*
|
|
101
|
+
* Create a new comment object.
|
|
102
|
+
*/
|
|
103
|
+
lxw_comment *
|
|
104
|
+
lxw_comment_new(void)
|
|
105
|
+
{
|
|
106
|
+
lxw_comment *comment = calloc(1, sizeof(lxw_comment));
|
|
107
|
+
GOTO_LABEL_ON_MEM_ERROR(comment, mem_error);
|
|
108
|
+
|
|
109
|
+
comment->author_ids = calloc(1, sizeof(struct lxw_author_ids));
|
|
110
|
+
GOTO_LABEL_ON_MEM_ERROR(comment->author_ids, mem_error);
|
|
111
|
+
RB_INIT(comment->author_ids);
|
|
112
|
+
|
|
113
|
+
return comment;
|
|
114
|
+
|
|
115
|
+
mem_error:
|
|
116
|
+
lxw_comment_free(comment);
|
|
117
|
+
return NULL;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
* Free a comment object.
|
|
122
|
+
*/
|
|
123
|
+
void
|
|
124
|
+
lxw_comment_free(lxw_comment *comment)
|
|
125
|
+
{
|
|
126
|
+
struct lxw_author_id *author_id;
|
|
127
|
+
struct lxw_author_id *next_author_id;
|
|
128
|
+
|
|
129
|
+
if (!comment)
|
|
130
|
+
return;
|
|
131
|
+
|
|
132
|
+
if (comment->author_ids) {
|
|
133
|
+
for (author_id =
|
|
134
|
+
RB_MIN(lxw_author_ids, comment->author_ids);
|
|
135
|
+
author_id; author_id = next_author_id) {
|
|
136
|
+
|
|
137
|
+
next_author_id =
|
|
138
|
+
RB_NEXT(lxw_author_ids, worksheet->author_id, author_id);
|
|
139
|
+
RB_REMOVE(lxw_author_ids, comment->author_ids, author_id);
|
|
140
|
+
free(author_id->author);
|
|
141
|
+
free(author_id);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
free(comment->author_ids);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
free(comment);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/*****************************************************************************
|
|
151
|
+
*
|
|
152
|
+
* XML functions.
|
|
153
|
+
*
|
|
154
|
+
****************************************************************************/
|
|
155
|
+
|
|
156
|
+
/*
|
|
157
|
+
* Write the XML declaration.
|
|
158
|
+
*/
|
|
159
|
+
STATIC void
|
|
160
|
+
_comment_xml_declaration(lxw_comment *self)
|
|
161
|
+
{
|
|
162
|
+
lxw_xml_declaration(self->file);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/*****************************************************************************
|
|
166
|
+
*
|
|
167
|
+
* XML file assembly functions.
|
|
168
|
+
*
|
|
169
|
+
****************************************************************************/
|
|
170
|
+
|
|
171
|
+
/*
|
|
172
|
+
* Write the <t> element.
|
|
173
|
+
*/
|
|
174
|
+
STATIC void
|
|
175
|
+
_comment_write_text_t(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
176
|
+
{
|
|
177
|
+
lxw_xml_data_element(self->file, "t", comment_obj->text, NULL);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
/*
|
|
181
|
+
* Write the <family> element.
|
|
182
|
+
*/
|
|
183
|
+
STATIC void
|
|
184
|
+
_comment_write_family(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
185
|
+
{
|
|
186
|
+
struct xml_attribute_list attributes;
|
|
187
|
+
struct xml_attribute *attribute;
|
|
188
|
+
|
|
189
|
+
LXW_INIT_ATTRIBUTES();
|
|
190
|
+
LXW_PUSH_ATTRIBUTES_INT("val", comment_obj->font_family);
|
|
191
|
+
|
|
192
|
+
lxw_xml_empty_tag(self->file, "family", &attributes);
|
|
193
|
+
|
|
194
|
+
LXW_FREE_ATTRIBUTES();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/*
|
|
198
|
+
* Write the <rFont> element.
|
|
199
|
+
*/
|
|
200
|
+
STATIC void
|
|
201
|
+
_comment_write_r_font(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
202
|
+
{
|
|
203
|
+
struct xml_attribute_list attributes;
|
|
204
|
+
struct xml_attribute *attribute;
|
|
205
|
+
char font_name[LXW_ATTR_32];
|
|
206
|
+
|
|
207
|
+
if (comment_obj->font_name)
|
|
208
|
+
lxw_snprintf(font_name, LXW_ATTR_32, "%s", comment_obj->font_name);
|
|
209
|
+
else
|
|
210
|
+
lxw_snprintf(font_name, LXW_ATTR_32, "Tahoma");
|
|
211
|
+
|
|
212
|
+
LXW_INIT_ATTRIBUTES();
|
|
213
|
+
LXW_PUSH_ATTRIBUTES_STR("val", font_name);
|
|
214
|
+
|
|
215
|
+
lxw_xml_empty_tag(self->file, "rFont", &attributes);
|
|
216
|
+
|
|
217
|
+
LXW_FREE_ATTRIBUTES();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/*
|
|
221
|
+
* Write the <color> element.
|
|
222
|
+
*/
|
|
223
|
+
STATIC void
|
|
224
|
+
_comment_write_color(lxw_comment *self)
|
|
225
|
+
{
|
|
226
|
+
struct xml_attribute_list attributes;
|
|
227
|
+
struct xml_attribute *attribute;
|
|
228
|
+
char indexed[] = "81";
|
|
229
|
+
|
|
230
|
+
LXW_INIT_ATTRIBUTES();
|
|
231
|
+
LXW_PUSH_ATTRIBUTES_STR("indexed", indexed);
|
|
232
|
+
|
|
233
|
+
lxw_xml_empty_tag(self->file, "color", &attributes);
|
|
234
|
+
|
|
235
|
+
LXW_FREE_ATTRIBUTES();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/*
|
|
239
|
+
* Write the <sz> element.
|
|
240
|
+
*/
|
|
241
|
+
STATIC void
|
|
242
|
+
_comment_write_sz(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
243
|
+
{
|
|
244
|
+
struct xml_attribute_list attributes;
|
|
245
|
+
struct xml_attribute *attribute;
|
|
246
|
+
|
|
247
|
+
LXW_INIT_ATTRIBUTES();
|
|
248
|
+
LXW_PUSH_ATTRIBUTES_DBL("val", comment_obj->font_size);
|
|
249
|
+
|
|
250
|
+
lxw_xml_empty_tag(self->file, "sz", &attributes);
|
|
251
|
+
|
|
252
|
+
LXW_FREE_ATTRIBUTES();
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/*
|
|
256
|
+
* Write the <rPr> element.
|
|
257
|
+
*/
|
|
258
|
+
STATIC void
|
|
259
|
+
_comment_write_r_pr(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
260
|
+
{
|
|
261
|
+
lxw_xml_start_tag(self->file, "rPr", NULL);
|
|
262
|
+
|
|
263
|
+
/* Write the sz element. */
|
|
264
|
+
_comment_write_sz(self, comment_obj);
|
|
265
|
+
|
|
266
|
+
/* Write the color element. */
|
|
267
|
+
_comment_write_color(self);
|
|
268
|
+
|
|
269
|
+
/* Write the rFont element. */
|
|
270
|
+
_comment_write_r_font(self, comment_obj);
|
|
271
|
+
|
|
272
|
+
/* Write the family element. */
|
|
273
|
+
_comment_write_family(self, comment_obj);
|
|
274
|
+
|
|
275
|
+
lxw_xml_end_tag(self->file, "rPr");
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/*
|
|
279
|
+
* Write the <r> element.
|
|
280
|
+
*/
|
|
281
|
+
STATIC void
|
|
282
|
+
_comment_write_r(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
283
|
+
{
|
|
284
|
+
lxw_xml_start_tag(self->file, "r", NULL);
|
|
285
|
+
|
|
286
|
+
/* Write the rPr element. */
|
|
287
|
+
_comment_write_r_pr(self, comment_obj);
|
|
288
|
+
|
|
289
|
+
/* Write the t element. */
|
|
290
|
+
_comment_write_text_t(self, comment_obj);
|
|
291
|
+
|
|
292
|
+
lxw_xml_end_tag(self->file, "r");
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/*
|
|
296
|
+
* Write the <text> element.
|
|
297
|
+
*/
|
|
298
|
+
STATIC void
|
|
299
|
+
_comment_write_text(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
300
|
+
{
|
|
301
|
+
lxw_xml_start_tag(self->file, "text", NULL);
|
|
302
|
+
|
|
303
|
+
/* Write the r element. */
|
|
304
|
+
_comment_write_r(self, comment_obj);
|
|
305
|
+
|
|
306
|
+
lxw_xml_end_tag(self->file, "text");
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/*
|
|
310
|
+
* Write the <comment> element.
|
|
311
|
+
*/
|
|
312
|
+
STATIC void
|
|
313
|
+
_comment_write_comment(lxw_comment *self, lxw_vml_obj *comment_obj)
|
|
314
|
+
{
|
|
315
|
+
struct xml_attribute_list attributes;
|
|
316
|
+
struct xml_attribute *attribute;
|
|
317
|
+
char ref[LXW_MAX_CELL_NAME_LENGTH];
|
|
318
|
+
|
|
319
|
+
lxw_rowcol_to_cell(ref, comment_obj->row, comment_obj->col);
|
|
320
|
+
|
|
321
|
+
LXW_INIT_ATTRIBUTES();
|
|
322
|
+
LXW_PUSH_ATTRIBUTES_STR("ref", ref);
|
|
323
|
+
LXW_PUSH_ATTRIBUTES_INT("authorId", comment_obj->author_id);
|
|
324
|
+
|
|
325
|
+
lxw_xml_start_tag(self->file, "comment", &attributes);
|
|
326
|
+
|
|
327
|
+
/* Write the text element. */
|
|
328
|
+
_comment_write_text(self, comment_obj);
|
|
329
|
+
|
|
330
|
+
lxw_xml_end_tag(self->file, "comment");
|
|
331
|
+
|
|
332
|
+
LXW_FREE_ATTRIBUTES();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/*
|
|
336
|
+
* Write the <commentList> element.
|
|
337
|
+
*/
|
|
338
|
+
STATIC void
|
|
339
|
+
_comment_write_comment_list(lxw_comment *self)
|
|
340
|
+
{
|
|
341
|
+
lxw_vml_obj *comment_obj;
|
|
342
|
+
|
|
343
|
+
lxw_xml_start_tag(self->file, "commentList", NULL);
|
|
344
|
+
|
|
345
|
+
STAILQ_FOREACH(comment_obj, self->comment_objs, list_pointers) {
|
|
346
|
+
/* Write the comment element. */
|
|
347
|
+
_comment_write_comment(self, comment_obj);
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
lxw_xml_end_tag(self->file, "commentList");
|
|
351
|
+
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
/*
|
|
355
|
+
* Write the <author> element.
|
|
356
|
+
*/
|
|
357
|
+
STATIC void
|
|
358
|
+
_comment_write_author(lxw_comment *self, char *author)
|
|
359
|
+
{
|
|
360
|
+
lxw_xml_data_element(self->file, "author", author, NULL);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/*
|
|
364
|
+
* Write the <authors> element.
|
|
365
|
+
*/
|
|
366
|
+
STATIC void
|
|
367
|
+
_comment_write_authors(lxw_comment *self)
|
|
368
|
+
{
|
|
369
|
+
lxw_vml_obj *comment_obj;
|
|
370
|
+
char *author;
|
|
371
|
+
|
|
372
|
+
lxw_xml_start_tag(self->file, "authors", NULL);
|
|
373
|
+
|
|
374
|
+
/* Set the default author (from worksheet_set_comments_author()). */
|
|
375
|
+
if (self->comment_author) {
|
|
376
|
+
_get_author_index(self, self->comment_author);
|
|
377
|
+
_comment_write_author(self, self->comment_author);
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
_get_author_index(self, "");
|
|
381
|
+
_comment_write_author(self, "");
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
STAILQ_FOREACH(comment_obj, self->comment_objs, list_pointers) {
|
|
385
|
+
author = comment_obj->author;
|
|
386
|
+
|
|
387
|
+
if (author) {
|
|
388
|
+
|
|
389
|
+
if (!_check_author(self, author))
|
|
390
|
+
_comment_write_author(self, author);
|
|
391
|
+
|
|
392
|
+
comment_obj->author_id = _get_author_index(self, author);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
lxw_xml_end_tag(self->file, "authors");
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/*
|
|
400
|
+
* Write the <comments> element.
|
|
401
|
+
*/
|
|
402
|
+
STATIC void
|
|
403
|
+
_comment_write_comments(lxw_comment *self)
|
|
404
|
+
{
|
|
405
|
+
struct xml_attribute_list attributes;
|
|
406
|
+
struct xml_attribute *attribute;
|
|
407
|
+
char xmlns[] =
|
|
408
|
+
"http://schemas.openxmlformats.org/spreadsheetml/2006/main";
|
|
409
|
+
|
|
410
|
+
LXW_INIT_ATTRIBUTES();
|
|
411
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
|
412
|
+
|
|
413
|
+
lxw_xml_start_tag(self->file, "comments", &attributes);
|
|
414
|
+
|
|
415
|
+
LXW_FREE_ATTRIBUTES();
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/*
|
|
419
|
+
* Assemble and write the XML file.
|
|
420
|
+
*/
|
|
421
|
+
void
|
|
422
|
+
lxw_comment_assemble_xml_file(lxw_comment *self)
|
|
423
|
+
{
|
|
424
|
+
/* Write the XML declaration. */
|
|
425
|
+
_comment_xml_declaration(self);
|
|
426
|
+
|
|
427
|
+
/* Write the comments element. */
|
|
428
|
+
_comment_write_comments(self);
|
|
429
|
+
|
|
430
|
+
/* Write the authors element. */
|
|
431
|
+
_comment_write_authors(self);
|
|
432
|
+
|
|
433
|
+
/* Write the commentList element. */
|
|
434
|
+
_comment_write_comment_list(self);
|
|
435
|
+
|
|
436
|
+
lxw_xml_end_tag(self->file, "comments");
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/*****************************************************************************
|
|
440
|
+
*
|
|
441
|
+
* Public functions.
|
|
442
|
+
*
|
|
443
|
+
****************************************************************************/
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used in conjunction with the libxlsxwriter library.
|
|
5
5
|
*
|
|
6
|
-
* Copyright 2014-
|
|
6
|
+
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -322,6 +322,35 @@ lxw_ct_add_drawing_name(lxw_content_types *self, const char *name)
|
|
|
322
322
|
lxw_ct_add_override(self, name, LXW_APP_DOCUMENT "drawing+xml");
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
/*
|
|
326
|
+
* Add the name of a table to the ContentTypes overrides.
|
|
327
|
+
*/
|
|
328
|
+
void
|
|
329
|
+
lxw_ct_add_table_name(lxw_content_types *self, const char *name)
|
|
330
|
+
{
|
|
331
|
+
lxw_ct_add_override(self, name,
|
|
332
|
+
LXW_APP_DOCUMENT "spreadsheetml.table+xml");
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/*
|
|
336
|
+
* Add the name of a VML drawing to the ContentTypes overrides.
|
|
337
|
+
*/
|
|
338
|
+
void
|
|
339
|
+
lxw_ct_add_vml_name(lxw_content_types *self)
|
|
340
|
+
{
|
|
341
|
+
lxw_ct_add_default(self, "vml", LXW_APP_DOCUMENT "vmlDrawing");
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/*
|
|
345
|
+
* Add the name of a comment to the ContentTypes overrides.
|
|
346
|
+
*/
|
|
347
|
+
void
|
|
348
|
+
lxw_ct_add_comment_name(lxw_content_types *self, const char *name)
|
|
349
|
+
{
|
|
350
|
+
lxw_ct_add_override(self, name,
|
|
351
|
+
LXW_APP_DOCUMENT "spreadsheetml.comments+xml");
|
|
352
|
+
}
|
|
353
|
+
|
|
325
354
|
/*
|
|
326
355
|
* Add the sharedStrings link to the ContentTypes overrides.
|
|
327
356
|
*/
|
|
@@ -351,3 +380,13 @@ lxw_ct_add_custom_properties(lxw_content_types *self)
|
|
|
351
380
|
lxw_ct_add_override(self, "/docProps/custom.xml",
|
|
352
381
|
LXW_APP_DOCUMENT "custom-properties+xml");
|
|
353
382
|
}
|
|
383
|
+
|
|
384
|
+
/*
|
|
385
|
+
* Add the metadata file to the ContentTypes overrides.
|
|
386
|
+
*/
|
|
387
|
+
void
|
|
388
|
+
lxw_ct_add_metadata(lxw_content_types *self)
|
|
389
|
+
{
|
|
390
|
+
lxw_ct_add_override(self, "/xl/metadata.xml",
|
|
391
|
+
LXW_APP_DOCUMENT "spreadsheetml.sheetMetadata+xml");
|
|
392
|
+
}
|
data/libxlsxwriter/src/core.c
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Used in conjunction with the libxlsxwriter library.
|
|
5
5
|
*
|
|
6
|
-
* Copyright 2014-
|
|
6
|
+
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
7
7
|
*
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -50,7 +50,7 @@ lxw_core_free(lxw_core *core)
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
/*
|
|
53
|
-
* Convert a time_t
|
|
53
|
+
* Convert a time_t to a ISO 8601 style "2010-01-01T00:00:00Z" date.
|
|
54
54
|
*/
|
|
55
55
|
static void
|
|
56
56
|
_datetime_to_iso8601_date(time_t *timer, char *str, size_t size)
|
data/libxlsxwriter/src/custom.c
CHANGED