fast_excel 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -2
- data/Makefile +14 -0
- data/README.md +7 -2
- data/Rakefile +10 -0
- data/extconf.rb +0 -0
- data/fast_excel.gemspec +3 -1
- data/lib/fast_excel/binding.rb +3 -7
- data/lib/rubygems_plugin.rb +3 -0
- data/libxlsxwriter/.gitignore +49 -0
- data/libxlsxwriter/.indent.pro +125 -0
- data/libxlsxwriter/.travis.yml +25 -0
- data/libxlsxwriter/CONTRIBUTING.md +226 -0
- data/libxlsxwriter/Changes.txt +557 -0
- data/libxlsxwriter/LICENSE.txt +89 -0
- data/libxlsxwriter/Makefile +156 -0
- data/libxlsxwriter/Readme.md +78 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +30 -0
- data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +7 -0
- data/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/libxlsxwriter/include/xlsxwriter/chart.h +3476 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +372 -0
- data/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +214 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/libxlsxwriter/include/xlsxwriter/workbook.h +757 -0
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/libxlsxwriter/lib/.gitignore +0 -0
- data/libxlsxwriter/libxlsxwriter.podspec +47 -0
- data/libxlsxwriter/src/Makefile +130 -0
- data/libxlsxwriter/src/app.c +443 -0
- data/libxlsxwriter/src/chart.c +6346 -0
- data/libxlsxwriter/src/content_types.c +345 -0
- data/libxlsxwriter/src/core.c +293 -0
- data/libxlsxwriter/src/custom.c +224 -0
- data/libxlsxwriter/src/drawing.c +746 -0
- data/libxlsxwriter/src/format.c +729 -0
- data/libxlsxwriter/src/hash_table.c +223 -0
- data/libxlsxwriter/src/packager.c +948 -0
- data/libxlsxwriter/src/relationships.c +245 -0
- data/libxlsxwriter/src/shared_strings.c +266 -0
- data/libxlsxwriter/src/styles.c +1088 -0
- data/libxlsxwriter/src/theme.c +348 -0
- data/libxlsxwriter/src/utility.c +515 -0
- data/libxlsxwriter/src/workbook.c +1930 -0
- data/libxlsxwriter/src/worksheet.c +5022 -0
- data/libxlsxwriter/src/xmlwriter.c +355 -0
- data/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/libxlsxwriter/third_party/minizip/Makefile.am +45 -0
- data/libxlsxwriter/third_party/minizip/Makefile.orig +25 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +6 -0
- data/libxlsxwriter/third_party/minizip/MiniZip64_info.txt +74 -0
- data/libxlsxwriter/third_party/minizip/README.txt +5 -0
- data/libxlsxwriter/third_party/minizip/configure.ac +32 -0
- data/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/libxlsxwriter/third_party/minizip/ioapi.h +208 -0
- data/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/libxlsxwriter/third_party/minizip/make_vms.com +25 -0
- data/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/libxlsxwriter/third_party/minizip/miniunzip.1 +63 -0
- data/libxlsxwriter/third_party/minizip/minizip.1 +46 -0
- data/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/libxlsxwriter/third_party/minizip/minizip.pc.in +12 -0
- data/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/libxlsxwriter/version.txt +1 -0
- metadata +89 -6
- data/binaries/libxlsxwriter-alpine.so +0 -0
- data/binaries/libxlsxwriter-darwin.dylib +0 -0
- data/binaries/libxlsxwriter-glibc.so +0 -0
@@ -0,0 +1,224 @@
|
|
1
|
+
/*****************************************************************************
|
2
|
+
* custom - A library for creating Excel custom property files.
|
3
|
+
*
|
4
|
+
* Used in conjunction with the libxlsxwriter library.
|
5
|
+
*
|
6
|
+
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
|
10
|
+
#include "xlsxwriter/xmlwriter.h"
|
11
|
+
#include "xlsxwriter/custom.h"
|
12
|
+
#include "xlsxwriter/utility.h"
|
13
|
+
|
14
|
+
/*
|
15
|
+
* Forward declarations.
|
16
|
+
*/
|
17
|
+
|
18
|
+
/*****************************************************************************
|
19
|
+
*
|
20
|
+
* Private functions.
|
21
|
+
*
|
22
|
+
****************************************************************************/
|
23
|
+
|
24
|
+
/*
|
25
|
+
* Create a new custom object.
|
26
|
+
*/
|
27
|
+
lxw_custom *
|
28
|
+
lxw_custom_new()
|
29
|
+
{
|
30
|
+
lxw_custom *custom = calloc(1, sizeof(lxw_custom));
|
31
|
+
GOTO_LABEL_ON_MEM_ERROR(custom, mem_error);
|
32
|
+
|
33
|
+
return custom;
|
34
|
+
|
35
|
+
mem_error:
|
36
|
+
lxw_custom_free(custom);
|
37
|
+
return NULL;
|
38
|
+
}
|
39
|
+
|
40
|
+
/*
|
41
|
+
* Free a custom object.
|
42
|
+
*/
|
43
|
+
void
|
44
|
+
lxw_custom_free(lxw_custom *custom)
|
45
|
+
{
|
46
|
+
if (!custom)
|
47
|
+
return;
|
48
|
+
|
49
|
+
free(custom);
|
50
|
+
}
|
51
|
+
|
52
|
+
/*****************************************************************************
|
53
|
+
*
|
54
|
+
* XML functions.
|
55
|
+
*
|
56
|
+
****************************************************************************/
|
57
|
+
|
58
|
+
/*
|
59
|
+
* Write the XML declaration.
|
60
|
+
*/
|
61
|
+
STATIC void
|
62
|
+
_custom_xml_declaration(lxw_custom *self)
|
63
|
+
{
|
64
|
+
lxw_xml_declaration(self->file);
|
65
|
+
}
|
66
|
+
|
67
|
+
/*
|
68
|
+
* Write the <vt:lpwstr> element.
|
69
|
+
*/
|
70
|
+
STATIC void
|
71
|
+
_chart_write_vt_lpwstr(lxw_custom *self, char *value)
|
72
|
+
{
|
73
|
+
lxw_xml_data_element(self->file, "vt:lpwstr", value, NULL);
|
74
|
+
}
|
75
|
+
|
76
|
+
/*
|
77
|
+
* Write the <vt:r8> element.
|
78
|
+
*/
|
79
|
+
STATIC void
|
80
|
+
_chart_write_vt_r_8(lxw_custom *self, double value)
|
81
|
+
{
|
82
|
+
char data[LXW_ATTR_32];
|
83
|
+
|
84
|
+
lxw_snprintf(data, LXW_ATTR_32, "%.16g", value);
|
85
|
+
|
86
|
+
lxw_xml_data_element(self->file, "vt:r8", data, NULL);
|
87
|
+
}
|
88
|
+
|
89
|
+
/*
|
90
|
+
* Write the <vt:i4> element.
|
91
|
+
*/
|
92
|
+
STATIC void
|
93
|
+
_custom_write_vt_i_4(lxw_custom *self, int32_t value)
|
94
|
+
{
|
95
|
+
char data[LXW_ATTR_32];
|
96
|
+
|
97
|
+
lxw_snprintf(data, LXW_ATTR_32, "%d", value);
|
98
|
+
|
99
|
+
lxw_xml_data_element(self->file, "vt:i4", data, NULL);
|
100
|
+
}
|
101
|
+
|
102
|
+
/*
|
103
|
+
* Write the <vt:bool> element.
|
104
|
+
*/
|
105
|
+
STATIC void
|
106
|
+
_custom_write_vt_bool(lxw_custom *self, uint8_t value)
|
107
|
+
{
|
108
|
+
if (value)
|
109
|
+
lxw_xml_data_element(self->file, "vt:bool", "true", NULL);
|
110
|
+
else
|
111
|
+
lxw_xml_data_element(self->file, "vt:bool", "false", NULL);
|
112
|
+
}
|
113
|
+
|
114
|
+
/*
|
115
|
+
* Write the <vt:filetime> element.
|
116
|
+
*/
|
117
|
+
STATIC void
|
118
|
+
_custom_write_vt_filetime(lxw_custom *self, lxw_datetime *datetime)
|
119
|
+
{
|
120
|
+
char data[LXW_DATETIME_LENGTH];
|
121
|
+
|
122
|
+
lxw_snprintf(data, LXW_DATETIME_LENGTH, "%4d-%02d-%02dT%02d:%02d:%02dZ",
|
123
|
+
datetime->year, datetime->month, datetime->day,
|
124
|
+
datetime->hour, datetime->min, (int) datetime->sec);
|
125
|
+
|
126
|
+
lxw_xml_data_element(self->file, "vt:filetime", data, NULL);
|
127
|
+
}
|
128
|
+
|
129
|
+
/*
|
130
|
+
* Write the <property> element.
|
131
|
+
*/
|
132
|
+
STATIC void
|
133
|
+
_chart_write_custom_property(lxw_custom *self,
|
134
|
+
lxw_custom_property *custom_property)
|
135
|
+
{
|
136
|
+
struct xml_attribute_list attributes;
|
137
|
+
struct xml_attribute *attribute;
|
138
|
+
char fmtid[] = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}";
|
139
|
+
|
140
|
+
self->pid++;
|
141
|
+
|
142
|
+
LXW_INIT_ATTRIBUTES();
|
143
|
+
LXW_PUSH_ATTRIBUTES_STR("fmtid", fmtid);
|
144
|
+
LXW_PUSH_ATTRIBUTES_INT("pid", self->pid + 1);
|
145
|
+
LXW_PUSH_ATTRIBUTES_STR("name", custom_property->name);
|
146
|
+
|
147
|
+
lxw_xml_start_tag(self->file, "property", &attributes);
|
148
|
+
|
149
|
+
if (custom_property->type == LXW_CUSTOM_STRING) {
|
150
|
+
/* Write the vt:lpwstr element. */
|
151
|
+
_chart_write_vt_lpwstr(self, custom_property->u.string);
|
152
|
+
}
|
153
|
+
else if (custom_property->type == LXW_CUSTOM_DOUBLE) {
|
154
|
+
/* Write the vt:r8 element. */
|
155
|
+
_chart_write_vt_r_8(self, custom_property->u.number);
|
156
|
+
}
|
157
|
+
else if (custom_property->type == LXW_CUSTOM_INTEGER) {
|
158
|
+
/* Write the vt:i4 element. */
|
159
|
+
_custom_write_vt_i_4(self, custom_property->u.integer);
|
160
|
+
}
|
161
|
+
else if (custom_property->type == LXW_CUSTOM_BOOLEAN) {
|
162
|
+
/* Write the vt:bool element. */
|
163
|
+
_custom_write_vt_bool(self, custom_property->u.boolean);
|
164
|
+
}
|
165
|
+
else if (custom_property->type == LXW_CUSTOM_DATETIME) {
|
166
|
+
/* Write the vt:filetime element. */
|
167
|
+
_custom_write_vt_filetime(self, &custom_property->u.datetime);
|
168
|
+
}
|
169
|
+
|
170
|
+
lxw_xml_end_tag(self->file, "property");
|
171
|
+
|
172
|
+
LXW_FREE_ATTRIBUTES();
|
173
|
+
}
|
174
|
+
|
175
|
+
/*
|
176
|
+
* Write the <Properties> element.
|
177
|
+
*/
|
178
|
+
STATIC void
|
179
|
+
_write_custom_properties(lxw_custom *self)
|
180
|
+
{
|
181
|
+
struct xml_attribute_list attributes;
|
182
|
+
struct xml_attribute *attribute;
|
183
|
+
char xmlns[] = LXW_SCHEMA_OFFICEDOC "/custom-properties";
|
184
|
+
char xmlns_vt[] = LXW_SCHEMA_OFFICEDOC "/docPropsVTypes";
|
185
|
+
lxw_custom_property *custom_property;
|
186
|
+
|
187
|
+
LXW_INIT_ATTRIBUTES();
|
188
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns", xmlns);
|
189
|
+
LXW_PUSH_ATTRIBUTES_STR("xmlns:vt", xmlns_vt);
|
190
|
+
|
191
|
+
lxw_xml_start_tag(self->file, "Properties", &attributes);
|
192
|
+
|
193
|
+
STAILQ_FOREACH(custom_property, self->custom_properties, list_pointers) {
|
194
|
+
_chart_write_custom_property(self, custom_property);
|
195
|
+
}
|
196
|
+
|
197
|
+
LXW_FREE_ATTRIBUTES();
|
198
|
+
}
|
199
|
+
|
200
|
+
/*****************************************************************************
|
201
|
+
*
|
202
|
+
* XML file assembly functions.
|
203
|
+
*
|
204
|
+
****************************************************************************/
|
205
|
+
|
206
|
+
/*
|
207
|
+
* Assemble and write the XML file.
|
208
|
+
*/
|
209
|
+
void
|
210
|
+
lxw_custom_assemble_xml_file(lxw_custom *self)
|
211
|
+
{
|
212
|
+
/* Write the XML declaration. */
|
213
|
+
_custom_xml_declaration(self);
|
214
|
+
|
215
|
+
_write_custom_properties(self);
|
216
|
+
|
217
|
+
lxw_xml_end_tag(self->file, "Properties");
|
218
|
+
}
|
219
|
+
|
220
|
+
/*****************************************************************************
|
221
|
+
*
|
222
|
+
* Public functions.
|
223
|
+
*
|
224
|
+
****************************************************************************/
|