kmadej_fast_excel_fork 0.2.2
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 +7 -0
- data/.gitignore +13 -0
- data/.travis.yml +28 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +70 -0
- data/Makefile +14 -0
- data/README.md +95 -0
- data/Rakefile +24 -0
- data/appveyor.yml +25 -0
- data/benchmarks/1k_rows.rb +59 -0
- data/benchmarks/20k_rows.rb +26 -0
- data/benchmarks/init.rb +59 -0
- data/benchmarks/memory.rb +49 -0
- data/examples/example.rb +42 -0
- data/examples/example_align.rb +23 -0
- data/examples/example_chart.rb +21 -0
- data/examples/example_colors.rb +37 -0
- data/examples/example_formula.rb +18 -0
- data/examples/example_image.rb +13 -0
- data/examples/example_styles.rb +27 -0
- data/examples/logo.png +0 -0
- data/extconf.rb +0 -0
- data/fast_excel.gemspec +20 -0
- data/lib/fast_excel.rb +600 -0
- data/lib/fast_excel/binding.rb +2819 -0
- data/lib/fast_excel/binding/chart.rb +2666 -0
- data/lib/fast_excel/binding/format.rb +1177 -0
- data/lib/fast_excel/binding/workbook.rb +338 -0
- data/lib/fast_excel/binding/worksheet.rb +1555 -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.h +23 -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/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
- data/test/date_test.rb +22 -0
- data/test/default_format_test.rb +19 -0
- data/test/format_test.rb +171 -0
- data/test/test_helper.rb +52 -0
- data/test/tmpfile_test.rb +23 -0
- data/test/worksheet_test.rb +86 -0
- metadata +182 -0
@@ -0,0 +1,372 @@
|
|
1
|
+
/*
|
2
|
+
* libxlsxwriter
|
3
|
+
*
|
4
|
+
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
|
+
*/
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @file common.h
|
9
|
+
*
|
10
|
+
* @brief Common functions and defines for the libxlsxwriter library.
|
11
|
+
*
|
12
|
+
* <!-- Copyright 2014-2017, John McNamara, jmcnamara@cpan.org -->
|
13
|
+
*
|
14
|
+
*/
|
15
|
+
#ifndef __LXW_COMMON_H__
|
16
|
+
#define __LXW_COMMON_H__
|
17
|
+
|
18
|
+
#include <time.h>
|
19
|
+
#include "third_party/queue.h"
|
20
|
+
#include "third_party/tree.h"
|
21
|
+
|
22
|
+
#ifndef TESTING
|
23
|
+
#define STATIC static
|
24
|
+
#else
|
25
|
+
#define STATIC
|
26
|
+
#endif
|
27
|
+
|
28
|
+
/** Integer data type to represent a row value. Equivalent to `uint32_t`.
|
29
|
+
*
|
30
|
+
* The maximum row in Excel is 1,048,576.
|
31
|
+
*/
|
32
|
+
typedef uint32_t lxw_row_t;
|
33
|
+
|
34
|
+
/** Integer data type to represent a column value. Equivalent to `uint16_t`.
|
35
|
+
*
|
36
|
+
* The maximum column in Excel is 16,384.
|
37
|
+
*/
|
38
|
+
typedef uint16_t lxw_col_t;
|
39
|
+
|
40
|
+
/** Boolean values used in libxlsxwriter. */
|
41
|
+
enum lxw_boolean {
|
42
|
+
/** False value. */
|
43
|
+
LXW_FALSE,
|
44
|
+
/** True value. */
|
45
|
+
LXW_TRUE
|
46
|
+
};
|
47
|
+
|
48
|
+
/**
|
49
|
+
* @brief Error codes from libxlsxwriter functions.
|
50
|
+
*
|
51
|
+
* See the `lxw_strerror()` function for an example of how to convert the
|
52
|
+
* enum number to a descriptive error message string.
|
53
|
+
*/
|
54
|
+
typedef enum lxw_error {
|
55
|
+
|
56
|
+
/** No error. */
|
57
|
+
LXW_NO_ERROR = 0,
|
58
|
+
|
59
|
+
/** Memory error, failed to malloc() required memory. */
|
60
|
+
LXW_ERROR_MEMORY_MALLOC_FAILED,
|
61
|
+
|
62
|
+
/** Error creating output xlsx file. Usually a permissions error. */
|
63
|
+
LXW_ERROR_CREATING_XLSX_FILE,
|
64
|
+
|
65
|
+
/** Error encountered when creating a tmpfile during file assembly. */
|
66
|
+
LXW_ERROR_CREATING_TMPFILE,
|
67
|
+
|
68
|
+
/** Zlib error with a file operation while creating xlsx file. */
|
69
|
+
LXW_ERROR_ZIP_FILE_OPERATION,
|
70
|
+
|
71
|
+
/** Zlib error when adding sub file to xlsx file. */
|
72
|
+
LXW_ERROR_ZIP_FILE_ADD,
|
73
|
+
|
74
|
+
/** Zlib error when closing xlsx file. */
|
75
|
+
LXW_ERROR_ZIP_CLOSE,
|
76
|
+
|
77
|
+
/** NULL function parameter ignored. */
|
78
|
+
LXW_ERROR_NULL_PARAMETER_IGNORED,
|
79
|
+
|
80
|
+
/** Function parameter validation error. */
|
81
|
+
LXW_ERROR_PARAMETER_VALIDATION,
|
82
|
+
|
83
|
+
/** Worksheet name exceeds Excel's limit of 31 characters. */
|
84
|
+
LXW_ERROR_SHEETNAME_LENGTH_EXCEEDED,
|
85
|
+
|
86
|
+
/** Worksheet name contains invalid Excel character: '[]:*?/\\' */
|
87
|
+
LXW_ERROR_INVALID_SHEETNAME_CHARACTER,
|
88
|
+
|
89
|
+
/** Worksheet name is already in use. */
|
90
|
+
LXW_ERROR_SHEETNAME_ALREADY_USED,
|
91
|
+
|
92
|
+
/** Parameter exceeds Excel's limit of 128 characters. */
|
93
|
+
LXW_ERROR_128_STRING_LENGTH_EXCEEDED,
|
94
|
+
|
95
|
+
/** Parameter exceeds Excel's limit of 255 characters. */
|
96
|
+
LXW_ERROR_255_STRING_LENGTH_EXCEEDED,
|
97
|
+
|
98
|
+
/** String exceeds Excel's limit of 32,767 characters. */
|
99
|
+
LXW_ERROR_MAX_STRING_LENGTH_EXCEEDED,
|
100
|
+
|
101
|
+
/** Error finding internal string index. */
|
102
|
+
LXW_ERROR_SHARED_STRING_INDEX_NOT_FOUND,
|
103
|
+
|
104
|
+
/** Worksheet row or column index out of range. */
|
105
|
+
LXW_ERROR_WORKSHEET_INDEX_OUT_OF_RANGE,
|
106
|
+
|
107
|
+
/** Maximum number of worksheet URLs (65530) exceeded. */
|
108
|
+
LXW_ERROR_WORKSHEET_MAX_NUMBER_URLS_EXCEEDED,
|
109
|
+
|
110
|
+
/** Couldn't read image dimensions or DPI. */
|
111
|
+
LXW_ERROR_IMAGE_DIMENSIONS,
|
112
|
+
|
113
|
+
LXW_MAX_ERRNO
|
114
|
+
} lxw_error;
|
115
|
+
|
116
|
+
/** @brief Struct to represent a date and time in Excel.
|
117
|
+
*
|
118
|
+
* Struct to represent a date and time in Excel. See @ref working_with_dates.
|
119
|
+
*/
|
120
|
+
typedef struct lxw_datetime {
|
121
|
+
|
122
|
+
/** Year : 1900 - 9999 */
|
123
|
+
int year;
|
124
|
+
/** Month : 1 - 12 */
|
125
|
+
int month;
|
126
|
+
/** Day : 1 - 31 */
|
127
|
+
int day;
|
128
|
+
/** Hour : 0 - 23 */
|
129
|
+
int hour;
|
130
|
+
/** Minute : 0 - 59 */
|
131
|
+
int min;
|
132
|
+
/** Seconds : 0 - 59.999 */
|
133
|
+
double sec;
|
134
|
+
|
135
|
+
} lxw_datetime;
|
136
|
+
|
137
|
+
enum lxw_custom_property_types {
|
138
|
+
LXW_CUSTOM_NONE,
|
139
|
+
LXW_CUSTOM_STRING,
|
140
|
+
LXW_CUSTOM_DOUBLE,
|
141
|
+
LXW_CUSTOM_INTEGER,
|
142
|
+
LXW_CUSTOM_BOOLEAN,
|
143
|
+
LXW_CUSTOM_DATETIME
|
144
|
+
};
|
145
|
+
|
146
|
+
/* Excel sheetname max of 31 chars. */
|
147
|
+
#define LXW_SHEETNAME_MAX 31
|
148
|
+
|
149
|
+
/* Max with all worksheet chars 4xUTF-8 bytes + start and end quotes + \0. */
|
150
|
+
#define LXW_MAX_SHEETNAME_LENGTH ((LXW_SHEETNAME_MAX * 4) + 2 + 1)
|
151
|
+
|
152
|
+
/* Max col string length. */
|
153
|
+
#define LXW_MAX_COL_NAME_LENGTH sizeof("$XFD")
|
154
|
+
|
155
|
+
/* Max row string length. */
|
156
|
+
#define LXW_MAX_ROW_NAME_LENGTH sizeof("$1048576")
|
157
|
+
|
158
|
+
/* Max cell string length. */
|
159
|
+
#define LXW_MAX_CELL_NAME_LENGTH sizeof("$XFWD$1048576")
|
160
|
+
|
161
|
+
/* Max range: $XFWD$1048576:$XFWD$1048576\0 */
|
162
|
+
#define LXW_MAX_CELL_RANGE_LENGTH (LXW_MAX_CELL_NAME_LENGTH * 2)
|
163
|
+
|
164
|
+
/* Max range formula Sheet1!$A$1:$C$5$ style. */
|
165
|
+
#define LXW_MAX_FORMULA_RANGE_LENGTH (LXW_MAX_SHEETNAME_LENGTH + LXW_MAX_CELL_RANGE_LENGTH)
|
166
|
+
|
167
|
+
/* Datetime string length. */
|
168
|
+
#define LXW_DATETIME_LENGTH sizeof("2016-12-12T23:00:00Z")
|
169
|
+
|
170
|
+
#define LXW_EPOCH_1900 0
|
171
|
+
#define LXW_EPOCH_1904 1
|
172
|
+
|
173
|
+
#define LXW_UINT32_T_LENGTH sizeof("4294967296")
|
174
|
+
#define LXW_FILENAME_LENGTH 128
|
175
|
+
#define LXW_IGNORE 1
|
176
|
+
|
177
|
+
#define LXW_SCHEMA_MS "http://schemas.microsoft.com/office/2006/relationships"
|
178
|
+
#define LXW_SCHEMA_ROOT "http://schemas.openxmlformats.org"
|
179
|
+
#define LXW_SCHEMA_DRAWING LXW_SCHEMA_ROOT "/drawingml/2006"
|
180
|
+
#define LXW_SCHEMA_OFFICEDOC LXW_SCHEMA_ROOT "/officeDocument/2006"
|
181
|
+
#define LXW_SCHEMA_PACKAGE LXW_SCHEMA_ROOT "/package/2006/relationships"
|
182
|
+
#define LXW_SCHEMA_DOCUMENT LXW_SCHEMA_ROOT "/officeDocument/2006/relationships"
|
183
|
+
#define LXW_SCHEMA_CONTENT LXW_SCHEMA_ROOT "/package/2006/content-types"
|
184
|
+
|
185
|
+
#define LXW_ERROR(message) \
|
186
|
+
fprintf(stderr, "[ERROR][%s:%d]: " message "\n", __FILE__, __LINE__)
|
187
|
+
|
188
|
+
#define LXW_MEM_ERROR() \
|
189
|
+
LXW_ERROR("Memory allocation failed.")
|
190
|
+
|
191
|
+
#define GOTO_LABEL_ON_MEM_ERROR(pointer, label) \
|
192
|
+
if (!pointer) { \
|
193
|
+
LXW_MEM_ERROR(); \
|
194
|
+
goto label; \
|
195
|
+
}
|
196
|
+
|
197
|
+
#define RETURN_ON_MEM_ERROR(pointer, error) \
|
198
|
+
if (!pointer) { \
|
199
|
+
LXW_MEM_ERROR(); \
|
200
|
+
return error; \
|
201
|
+
}
|
202
|
+
|
203
|
+
#define RETURN_VOID_ON_MEM_ERROR(pointer) \
|
204
|
+
if (!pointer) { \
|
205
|
+
LXW_MEM_ERROR(); \
|
206
|
+
return; \
|
207
|
+
}
|
208
|
+
|
209
|
+
#define RETURN_ON_ERROR(error) \
|
210
|
+
if (error) \
|
211
|
+
return error;
|
212
|
+
|
213
|
+
#define LXW_WARN(message) \
|
214
|
+
fprintf(stderr, "[WARNING]: " message "\n")
|
215
|
+
|
216
|
+
/* We can't use variadic macros here since we support ANSI C. */
|
217
|
+
#define LXW_WARN_FORMAT(message) \
|
218
|
+
fprintf(stderr, "[WARNING]: " message "\n")
|
219
|
+
|
220
|
+
#define LXW_WARN_FORMAT1(message, var) \
|
221
|
+
fprintf(stderr, "[WARNING]: " message "\n", var)
|
222
|
+
|
223
|
+
#define LXW_WARN_FORMAT2(message, var1, var2) \
|
224
|
+
fprintf(stderr, "[WARNING]: " message "\n", var1, var2)
|
225
|
+
|
226
|
+
/* Chart axis type checks. */
|
227
|
+
#define LXW_WARN_CAT_AXIS_ONLY(function) \
|
228
|
+
if (!axis->is_category) { \
|
229
|
+
fprintf(stderr, "[WARNING]: " \
|
230
|
+
function "() is only valid for category axes\n"); \
|
231
|
+
return; \
|
232
|
+
}
|
233
|
+
|
234
|
+
#define LXW_WARN_VALUE_AXIS_ONLY(function) \
|
235
|
+
if (!axis->is_value) { \
|
236
|
+
fprintf(stderr, "[WARNING]: " \
|
237
|
+
function "() is only valid for value axes\n"); \
|
238
|
+
return; \
|
239
|
+
}
|
240
|
+
|
241
|
+
#define LXW_WARN_DATE_AXIS_ONLY(function) \
|
242
|
+
if (!axis->is_date) { \
|
243
|
+
fprintf(stderr, "[WARNING]: " \
|
244
|
+
function "() is only valid for date axes\n"); \
|
245
|
+
return; \
|
246
|
+
}
|
247
|
+
|
248
|
+
#define LXW_WARN_CAT_AND_DATE_AXIS_ONLY(function) \
|
249
|
+
if (!axis->is_category && !axis->is_date) { \
|
250
|
+
fprintf(stderr, "[WARNING]: " \
|
251
|
+
function "() is only valid for category and date axes\n"); \
|
252
|
+
return; \
|
253
|
+
}
|
254
|
+
|
255
|
+
#define LXW_WARN_VALUE_AND_DATE_AXIS_ONLY(function) \
|
256
|
+
if (!axis->is_value && !axis->is_date) { \
|
257
|
+
fprintf(stderr, "[WARNING]: " \
|
258
|
+
function "() is only valid for value and date axes\n"); \
|
259
|
+
return; \
|
260
|
+
}
|
261
|
+
|
262
|
+
#ifndef LXW_BIG_ENDIAN
|
263
|
+
#define LXW_UINT32_NETWORK(n) ((((n) & 0xFF) << 24) | \
|
264
|
+
(((n) & 0xFF00) << 8) | \
|
265
|
+
(((n) & 0xFF0000) >> 8) | \
|
266
|
+
(((n) & 0xFF000000) >> 24))
|
267
|
+
#define LXW_UINT16_NETWORK(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
|
268
|
+
#else
|
269
|
+
#define LXW_UINT32_NETWORK(n) (n)
|
270
|
+
#define LXW_UINT16_NETWORK(n) (n)
|
271
|
+
#endif
|
272
|
+
|
273
|
+
/* *INDENT-OFF* */
|
274
|
+
#ifdef __cplusplus
|
275
|
+
extern "C" {
|
276
|
+
#endif
|
277
|
+
/* *INDENT-ON* */
|
278
|
+
|
279
|
+
/* Compilers that have a native snprintf() can use it directly. */
|
280
|
+
#ifdef _MSC_VER
|
281
|
+
#define LXW_HAS_SNPRINTF
|
282
|
+
#endif
|
283
|
+
|
284
|
+
#ifdef LXW_HAS_SNPRINTF
|
285
|
+
#define lxw_snprintf snprintf
|
286
|
+
#else
|
287
|
+
#define lxw_snprintf __builtin_snprintf
|
288
|
+
#endif
|
289
|
+
|
290
|
+
/* Define a snprintf for MSVC 2010. */
|
291
|
+
#if defined(_MSC_VER) && _MSC_VER < 1900
|
292
|
+
|
293
|
+
#include <stdarg.h>
|
294
|
+
#define snprintf msvc2010_snprintf
|
295
|
+
#define vsnprintf msvc2010_vsnprintf
|
296
|
+
|
297
|
+
__inline int
|
298
|
+
msvc2010_vsnprintf(char *str, size_t size, const char *format, va_list ap)
|
299
|
+
{
|
300
|
+
int count = -1;
|
301
|
+
|
302
|
+
if (size != 0)
|
303
|
+
count = _vsnprintf_s(str, size, _TRUNCATE, format, ap);
|
304
|
+
if (count == -1)
|
305
|
+
count = _vscprintf(format, ap);
|
306
|
+
|
307
|
+
return count;
|
308
|
+
}
|
309
|
+
|
310
|
+
__inline int
|
311
|
+
msvc2010_snprintf(char *str, size_t size, const char *format, ...)
|
312
|
+
{
|
313
|
+
int count;
|
314
|
+
va_list ap;
|
315
|
+
|
316
|
+
va_start(ap, format);
|
317
|
+
count = msvc2010_vsnprintf(str, size, format, ap);
|
318
|
+
va_end(ap);
|
319
|
+
|
320
|
+
return count;
|
321
|
+
}
|
322
|
+
|
323
|
+
#endif
|
324
|
+
|
325
|
+
/* Safer strcpy for fixed width char arrays. */
|
326
|
+
#define lxw_strcpy(dest, src) \
|
327
|
+
lxw_snprintf(dest, sizeof(dest), "%s", src)
|
328
|
+
|
329
|
+
/* Define the queue.h structs for the formats list. */
|
330
|
+
STAILQ_HEAD(lxw_formats, lxw_format);
|
331
|
+
|
332
|
+
/* Define the queue.h structs for the generic data structs. */
|
333
|
+
STAILQ_HEAD(lxw_tuples, lxw_tuple);
|
334
|
+
STAILQ_HEAD(lxw_custom_properties, lxw_custom_property);
|
335
|
+
|
336
|
+
typedef struct lxw_tuple {
|
337
|
+
char *key;
|
338
|
+
char *value;
|
339
|
+
|
340
|
+
STAILQ_ENTRY (lxw_tuple) list_pointers;
|
341
|
+
} lxw_tuple;
|
342
|
+
|
343
|
+
/* Define custom property used in workbook.c and custom.c. */
|
344
|
+
typedef struct lxw_custom_property {
|
345
|
+
|
346
|
+
enum lxw_custom_property_types type;
|
347
|
+
char *name;
|
348
|
+
|
349
|
+
union {
|
350
|
+
char *string;
|
351
|
+
double number;
|
352
|
+
int32_t integer;
|
353
|
+
uint8_t boolean;
|
354
|
+
lxw_datetime datetime;
|
355
|
+
} u;
|
356
|
+
|
357
|
+
STAILQ_ENTRY (lxw_custom_property) list_pointers;
|
358
|
+
|
359
|
+
} lxw_custom_property;
|
360
|
+
|
361
|
+
/* Declarations required for unit testing. */
|
362
|
+
#ifdef TESTING
|
363
|
+
|
364
|
+
#endif /* TESTING */
|
365
|
+
|
366
|
+
/* *INDENT-OFF* */
|
367
|
+
#ifdef __cplusplus
|
368
|
+
}
|
369
|
+
#endif
|
370
|
+
/* *INDENT-ON* */
|
371
|
+
|
372
|
+
#endif /* __LXW_COMMON_H__ */
|
@@ -0,0 +1,74 @@
|
|
1
|
+
/*
|
2
|
+
* libxlsxwriter
|
3
|
+
*
|
4
|
+
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
|
+
*
|
6
|
+
* content_types - A libxlsxwriter library for creating Excel XLSX
|
7
|
+
* content_types files.
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
#ifndef __LXW_CONTENT_TYPES_H__
|
11
|
+
#define __LXW_CONTENT_TYPES_H__
|
12
|
+
|
13
|
+
#include <stdint.h>
|
14
|
+
#include <string.h>
|
15
|
+
|
16
|
+
#include "common.h"
|
17
|
+
|
18
|
+
#define LXW_APP_PACKAGE "application/vnd.openxmlformats-package."
|
19
|
+
#define LXW_APP_DOCUMENT "application/vnd.openxmlformats-officedocument."
|
20
|
+
|
21
|
+
/*
|
22
|
+
* Struct to represent a content_types.
|
23
|
+
*/
|
24
|
+
typedef struct lxw_content_types {
|
25
|
+
|
26
|
+
FILE *file;
|
27
|
+
|
28
|
+
struct lxw_tuples *default_types;
|
29
|
+
struct lxw_tuples *overrides;
|
30
|
+
|
31
|
+
} lxw_content_types;
|
32
|
+
|
33
|
+
|
34
|
+
/* *INDENT-OFF* */
|
35
|
+
#ifdef __cplusplus
|
36
|
+
extern "C" {
|
37
|
+
#endif
|
38
|
+
/* *INDENT-ON* */
|
39
|
+
|
40
|
+
lxw_content_types *lxw_content_types_new();
|
41
|
+
void lxw_content_types_free(lxw_content_types *content_types);
|
42
|
+
void lxw_content_types_assemble_xml_file(lxw_content_types *content_types);
|
43
|
+
void lxw_ct_add_default(lxw_content_types *content_types, const char *key,
|
44
|
+
const char *value);
|
45
|
+
void lxw_ct_add_override(lxw_content_types *content_types, const char *key,
|
46
|
+
const char *value);
|
47
|
+
void lxw_ct_add_worksheet_name(lxw_content_types *content_types,
|
48
|
+
const char *name);
|
49
|
+
void lxw_ct_add_chart_name(lxw_content_types *content_types,
|
50
|
+
const char *name);
|
51
|
+
void lxw_ct_add_drawing_name(lxw_content_types *content_types,
|
52
|
+
const char *name);
|
53
|
+
void lxw_ct_add_shared_strings(lxw_content_types *content_types);
|
54
|
+
void lxw_ct_add_calc_chain(lxw_content_types *content_types);
|
55
|
+
void lxw_ct_add_custom_properties(lxw_content_types *content_types);
|
56
|
+
|
57
|
+
/* Declarations required for unit testing. */
|
58
|
+
#ifdef TESTING
|
59
|
+
|
60
|
+
STATIC void _content_types_xml_declaration(lxw_content_types *self);
|
61
|
+
STATIC void _write_default(lxw_content_types *self, const char *ext,
|
62
|
+
const char *type);
|
63
|
+
STATIC void _write_override(lxw_content_types *self, const char *part_name,
|
64
|
+
const char *type);
|
65
|
+
|
66
|
+
#endif /* TESTING */
|
67
|
+
|
68
|
+
/* *INDENT-OFF* */
|
69
|
+
#ifdef __cplusplus
|
70
|
+
}
|
71
|
+
#endif
|
72
|
+
/* *INDENT-ON* */
|
73
|
+
|
74
|
+
#endif /* __LXW_CONTENT_TYPES_H__ */
|
@@ -0,0 +1,51 @@
|
|
1
|
+
/*
|
2
|
+
* libxlsxwriter
|
3
|
+
*
|
4
|
+
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
5
|
+
*
|
6
|
+
* core - A libxlsxwriter library for creating Excel XLSX core files.
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
#ifndef __LXW_CORE_H__
|
10
|
+
#define __LXW_CORE_H__
|
11
|
+
|
12
|
+
#include <stdint.h>
|
13
|
+
|
14
|
+
#include "workbook.h"
|
15
|
+
#include "common.h"
|
16
|
+
|
17
|
+
/*
|
18
|
+
* Struct to represent a core.
|
19
|
+
*/
|
20
|
+
typedef struct lxw_core {
|
21
|
+
|
22
|
+
FILE *file;
|
23
|
+
lxw_doc_properties *properties;
|
24
|
+
|
25
|
+
} lxw_core;
|
26
|
+
|
27
|
+
|
28
|
+
/* *INDENT-OFF* */
|
29
|
+
#ifdef __cplusplus
|
30
|
+
extern "C" {
|
31
|
+
#endif
|
32
|
+
/* *INDENT-ON* */
|
33
|
+
|
34
|
+
lxw_core *lxw_core_new();
|
35
|
+
void lxw_core_free(lxw_core *core);
|
36
|
+
void lxw_core_assemble_xml_file(lxw_core *self);
|
37
|
+
|
38
|
+
/* Declarations required for unit testing. */
|
39
|
+
#ifdef TESTING
|
40
|
+
|
41
|
+
STATIC void _core_xml_declaration(lxw_core *self);
|
42
|
+
|
43
|
+
#endif /* TESTING */
|
44
|
+
|
45
|
+
/* *INDENT-OFF* */
|
46
|
+
#ifdef __cplusplus
|
47
|
+
}
|
48
|
+
#endif
|
49
|
+
/* *INDENT-ON* */
|
50
|
+
|
51
|
+
#endif /* __LXW_CORE_H__ */
|