xlsxwriter 0.2.0 → 0.2.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/xlsxwriter/chart.c +171 -45
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +19 -4
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +1 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +12 -4
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +8 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +132 -37
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +30 -4
- data/ext/xlsxwriter/libxlsxwriter/src/Makefile +2 -2
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +0 -2
- data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +12 -12
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +73 -23
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +9 -4
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +117 -14
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +31 -6
- data/ext/xlsxwriter/workbook.c +52 -8
- data/ext/xlsxwriter/worksheet.c +68 -0
- data/lib/xlsxwriter/version.rb +1 -1
- data/test/support/chart_test.rb +17 -0
- data/test/test-chart-area.rb +41 -7
- data/test/test-chart-axis.rb +427 -55
- data/test/test-chart-bar.rb +48 -10
- data/test/test-image.rb +15 -0
- data/test/test-macro.rb +20 -0
- data/test/xlsx-func-testcase.rb +2 -1
- metadata +9 -5
@@ -741,10 +741,10 @@ typedef struct lxw_worksheet {
|
|
741
741
|
uint8_t right_to_left;
|
742
742
|
uint8_t screen_gridlines;
|
743
743
|
uint8_t show_zeros;
|
744
|
-
uint8_t vba_codename;
|
745
744
|
uint8_t vcenter;
|
746
745
|
uint8_t zoom_scale_normal;
|
747
746
|
uint8_t num_validations;
|
747
|
+
char *vba_codename;
|
748
748
|
|
749
749
|
lxw_color_t tab_color;
|
750
750
|
|
@@ -1592,7 +1592,7 @@ lxw_error worksheet_set_row_opt(lxw_worksheet *worksheet,
|
|
1592
1592
|
* format_set_bold(bold);
|
1593
1593
|
*
|
1594
1594
|
* // Set the first column to bold.
|
1595
|
-
* worksheet_set_column(worksheet, 0, 0,
|
1595
|
+
* worksheet_set_column(worksheet, 0, 0, LXW_DEF_COL_WIDTH, bold);
|
1596
1596
|
* @endcode
|
1597
1597
|
*
|
1598
1598
|
* The `format` parameter will be applied to any cells in the column that
|
@@ -3235,17 +3235,43 @@ void worksheet_outline_settings(lxw_worksheet *worksheet, uint8_t visible,
|
|
3235
3235
|
void worksheet_set_default_row(lxw_worksheet *worksheet, double height,
|
3236
3236
|
uint8_t hide_unused_rows);
|
3237
3237
|
|
3238
|
+
/**
|
3239
|
+
* @brief Set the VBA name for the worksheet.
|
3240
|
+
*
|
3241
|
+
* @param worksheet Pointer to a lxw_worksheet instance.
|
3242
|
+
* @param name Name of the worksheet used by VBA.
|
3243
|
+
*
|
3244
|
+
* The `worksheet_set_vba_name()` function can be used to set the VBA name for
|
3245
|
+
* the worksheet. This is sometimes required when a vbaProject macro included
|
3246
|
+
* via `workbook_add_vba_project()` refers to the worksheet by a name other
|
3247
|
+
* than the worksheet name:
|
3248
|
+
*
|
3249
|
+
* @code
|
3250
|
+
* workbook_set_vba_name (workbook, "MyWorkbook");
|
3251
|
+
* worksheet_set_vba_name(worksheet, "MySheet1");
|
3252
|
+
* @endcode
|
3253
|
+
*
|
3254
|
+
* In general Excel uses the worksheet name such as "Sheet1" as the VBA name.
|
3255
|
+
* However, this can be changed in the VBA environment or if the the macro was
|
3256
|
+
* extracted from a foreign language version of Excel.
|
3257
|
+
*
|
3258
|
+
* See also @ref working_with_macros
|
3259
|
+
*
|
3260
|
+
* @return A #lxw_error.
|
3261
|
+
*/
|
3262
|
+
lxw_error worksheet_set_vba_name(lxw_worksheet *worksheet, const char *name);
|
3263
|
+
|
3238
3264
|
lxw_worksheet *lxw_worksheet_new(lxw_worksheet_init_data *init_data);
|
3239
3265
|
void lxw_worksheet_free(lxw_worksheet *worksheet);
|
3240
3266
|
void lxw_worksheet_assemble_xml_file(lxw_worksheet *worksheet);
|
3241
3267
|
void lxw_worksheet_write_single_row(lxw_worksheet *worksheet);
|
3242
3268
|
|
3243
3269
|
void lxw_worksheet_prepare_image(lxw_worksheet *worksheet,
|
3244
|
-
|
3270
|
+
uint32_t image_ref_id, uint32_t drawing_id,
|
3245
3271
|
lxw_image_options *image_data);
|
3246
3272
|
|
3247
3273
|
void lxw_worksheet_prepare_chart(lxw_worksheet *worksheet,
|
3248
|
-
|
3274
|
+
uint32_t chart_ref_id, uint32_t drawing_id,
|
3249
3275
|
lxw_image_options *image_data,
|
3250
3276
|
uint8_t is_chartsheet);
|
3251
3277
|
|
@@ -125,7 +125,7 @@ ARCH = -m32
|
|
125
125
|
endif
|
126
126
|
|
127
127
|
$(LIBXLSXWRITER_SO) : $(SOBJS)
|
128
|
-
$(Q)$(CC) $(SOFLAGS) $(ARCH) -o $@ $(MINIZIP_SO) $(TMPFILEPLUS_SO) $^ $(LIBS)
|
128
|
+
$(Q)$(CC) $(LDFLAGS) $(SOFLAGS) $(ARCH) -o $@ $(MINIZIP_SO) $(TMPFILEPLUS_SO) $^ $(LIBS)
|
129
129
|
|
130
130
|
# The test library.
|
131
131
|
$(LIBXLSXWRITER_TO) : $(TOBJS)
|
@@ -139,7 +139,7 @@ test_compile : $(OBJS)
|
|
139
139
|
$(Q)$(CC) -I$(INC_DIR) $(CFLAGS) $(CXXFLAGS) -c $<
|
140
140
|
|
141
141
|
%.so : %.c $(HDRS)
|
142
|
-
$(Q)$(CC) $(FPIC) -I$(INC_DIR) $(CFLAGS) $(CXXFLAGS) -c $< -o $@
|
142
|
+
$(Q)$(CC) $(FPIC) -I$(INC_DIR) $(LDFLAGS) $(CFLAGS) $(CXXFLAGS) -c $< -o $@
|
143
143
|
|
144
144
|
%.to : %.c $(HDRS)
|
145
145
|
$(Q)$(CC) -g -O3 -DTESTING -I$(INC_DIR) $(CFLAGS) $(CXXFLAGS) -c $< -o $@
|
@@ -50,8 +50,6 @@ lxw_content_types_new(void)
|
|
50
50
|
LXW_APP_DOCUMENT "spreadsheetml.styles+xml");
|
51
51
|
lxw_ct_add_override(content_types, "/xl/theme/theme1.xml",
|
52
52
|
LXW_APP_DOCUMENT "theme+xml");
|
53
|
-
lxw_ct_add_override(content_types, "/xl/workbook.xml",
|
54
|
-
LXW_APP_DOCUMENT "spreadsheetml.sheet.main+xml");
|
55
53
|
|
56
54
|
return content_types;
|
57
55
|
|
@@ -225,7 +225,7 @@ _drawing_write_to(lxw_drawing *self, lxw_drawing_coords *coords)
|
|
225
225
|
* Write the <xdr:cNvPr> element.
|
226
226
|
*/
|
227
227
|
STATIC void
|
228
|
-
_drawing_write_c_nv_pr(lxw_drawing *self, char *object_name,
|
228
|
+
_drawing_write_c_nv_pr(lxw_drawing *self, char *object_name, uint32_t index,
|
229
229
|
lxw_drawing_object *drawing_object)
|
230
230
|
{
|
231
231
|
struct xml_attribute_list attributes;
|
@@ -282,7 +282,7 @@ _drawing_write_c_nv_pic_pr(lxw_drawing *self)
|
|
282
282
|
* Write the <xdr:nvPicPr> element.
|
283
283
|
*/
|
284
284
|
STATIC void
|
285
|
-
_drawing_write_nv_pic_pr(lxw_drawing *self,
|
285
|
+
_drawing_write_nv_pic_pr(lxw_drawing *self, uint32_t index,
|
286
286
|
lxw_drawing_object *drawing_object)
|
287
287
|
{
|
288
288
|
lxw_xml_start_tag(self->file, "xdr:nvPicPr", NULL);
|
@@ -300,7 +300,7 @@ _drawing_write_nv_pic_pr(lxw_drawing *self, uint16_t index,
|
|
300
300
|
* Write the <a:blip> element.
|
301
301
|
*/
|
302
302
|
STATIC void
|
303
|
-
_drawing_write_a_blip(lxw_drawing *self,
|
303
|
+
_drawing_write_a_blip(lxw_drawing *self, uint32_t index)
|
304
304
|
{
|
305
305
|
struct xml_attribute_list attributes;
|
306
306
|
struct xml_attribute *attribute;
|
@@ -345,7 +345,7 @@ _drawing_write_a_stretch(lxw_drawing *self)
|
|
345
345
|
* Write the <xdr:blipFill> element.
|
346
346
|
*/
|
347
347
|
STATIC void
|
348
|
-
_drawing_write_blip_fill(lxw_drawing *self,
|
348
|
+
_drawing_write_blip_fill(lxw_drawing *self, uint32_t index)
|
349
349
|
{
|
350
350
|
lxw_xml_start_tag(self->file, "xdr:blipFill", NULL);
|
351
351
|
|
@@ -463,7 +463,7 @@ _drawing_write_sp_pr(lxw_drawing *self, lxw_drawing_object *drawing_object)
|
|
463
463
|
* Write the <xdr:pic> element.
|
464
464
|
*/
|
465
465
|
STATIC void
|
466
|
-
_drawing_write_pic(lxw_drawing *self,
|
466
|
+
_drawing_write_pic(lxw_drawing *self, uint32_t index,
|
467
467
|
lxw_drawing_object *drawing_object)
|
468
468
|
{
|
469
469
|
lxw_xml_start_tag(self->file, "xdr:pic", NULL);
|
@@ -529,7 +529,7 @@ _drawing_write_c_nv_graphic_frame_pr(lxw_drawing *self)
|
|
529
529
|
* Write the <xdr:nvGraphicFramePr> element.
|
530
530
|
*/
|
531
531
|
STATIC void
|
532
|
-
_drawing_write_nv_graphic_frame_pr(lxw_drawing *self,
|
532
|
+
_drawing_write_nv_graphic_frame_pr(lxw_drawing *self, uint32_t index)
|
533
533
|
{
|
534
534
|
lxw_xml_start_tag(self->file, "xdr:nvGraphicFramePr", NULL);
|
535
535
|
|
@@ -599,7 +599,7 @@ _drawing_write_xfrm(lxw_drawing *self)
|
|
599
599
|
* Write the <c:chart> element.
|
600
600
|
*/
|
601
601
|
STATIC void
|
602
|
-
_drawing_write_chart(lxw_drawing *self,
|
602
|
+
_drawing_write_chart(lxw_drawing *self, uint32_t index)
|
603
603
|
{
|
604
604
|
struct xml_attribute_list attributes;
|
605
605
|
struct xml_attribute *attribute;
|
@@ -623,7 +623,7 @@ _drawing_write_chart(lxw_drawing *self, uint16_t index)
|
|
623
623
|
* Write the <a:graphicData> element.
|
624
624
|
*/
|
625
625
|
STATIC void
|
626
|
-
_drawing_write_a_graphic_data(lxw_drawing *self,
|
626
|
+
_drawing_write_a_graphic_data(lxw_drawing *self, uint32_t index)
|
627
627
|
{
|
628
628
|
struct xml_attribute_list attributes;
|
629
629
|
struct xml_attribute *attribute;
|
@@ -646,7 +646,7 @@ _drawing_write_a_graphic_data(lxw_drawing *self, uint16_t index)
|
|
646
646
|
* Write the <a:graphic> element.
|
647
647
|
*/
|
648
648
|
STATIC void
|
649
|
-
_drawing_write_a_graphic(lxw_drawing *self,
|
649
|
+
_drawing_write_a_graphic(lxw_drawing *self, uint32_t index)
|
650
650
|
{
|
651
651
|
|
652
652
|
lxw_xml_start_tag(self->file, "a:graphic", NULL);
|
@@ -661,7 +661,7 @@ _drawing_write_a_graphic(lxw_drawing *self, uint16_t index)
|
|
661
661
|
* Write the <xdr:graphicFrame> element.
|
662
662
|
*/
|
663
663
|
STATIC void
|
664
|
-
_drawing_write_graphic_frame(lxw_drawing *self,
|
664
|
+
_drawing_write_graphic_frame(lxw_drawing *self, uint32_t index)
|
665
665
|
{
|
666
666
|
struct xml_attribute_list attributes;
|
667
667
|
struct xml_attribute *attribute;
|
@@ -689,7 +689,7 @@ _drawing_write_graphic_frame(lxw_drawing *self, uint16_t index)
|
|
689
689
|
* Write the <xdr:twoCellAnchor> element.
|
690
690
|
*/
|
691
691
|
STATIC void
|
692
|
-
_drawing_write_two_cell_anchor(lxw_drawing *self,
|
692
|
+
_drawing_write_two_cell_anchor(lxw_drawing *self, uint32_t index,
|
693
693
|
lxw_drawing_object *drawing_object)
|
694
694
|
{
|
695
695
|
struct xml_attribute_list attributes;
|
@@ -811,7 +811,7 @@ _drawing_write_absolute_anchor(lxw_drawing *self)
|
|
811
811
|
void
|
812
812
|
lxw_drawing_assemble_xml_file(lxw_drawing *self)
|
813
813
|
{
|
814
|
-
|
814
|
+
uint32_t index;
|
815
815
|
lxw_drawing_object *drawing_object;
|
816
816
|
|
817
817
|
/* Write the XML declaration. */
|
@@ -76,7 +76,7 @@ _open_zipfile_win32(const char *filename)
|
|
76
76
|
* Create a new packager object.
|
77
77
|
*/
|
78
78
|
lxw_packager *
|
79
|
-
lxw_packager_new(const char *filename, char *tmpdir)
|
79
|
+
lxw_packager_new(const char *filename, char *tmpdir, uint8_t use_zip64)
|
80
80
|
{
|
81
81
|
lxw_packager *packager = calloc(1, sizeof(lxw_packager));
|
82
82
|
GOTO_LABEL_ON_MEM_ERROR(packager, mem_error);
|
@@ -89,6 +89,7 @@ lxw_packager_new(const char *filename, char *tmpdir)
|
|
89
89
|
GOTO_LABEL_ON_MEM_ERROR(packager->filename, mem_error);
|
90
90
|
|
91
91
|
packager->buffer_size = LXW_ZIP_BUFFER_SIZE;
|
92
|
+
packager->use_zip64 = use_zip64;
|
92
93
|
|
93
94
|
/* Initialize the zip_fileinfo struct to Jan 1 1980 like Excel. */
|
94
95
|
packager->zipfile_info.tmz_date.tm_sec = 0;
|
@@ -170,7 +171,7 @@ _write_worksheet_files(lxw_packager *self)
|
|
170
171
|
lxw_sheet *sheet;
|
171
172
|
lxw_worksheet *worksheet;
|
172
173
|
char sheetname[LXW_FILENAME_LENGTH] = { 0 };
|
173
|
-
|
174
|
+
uint32_t index = 1;
|
174
175
|
lxw_error err;
|
175
176
|
|
176
177
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
@@ -210,7 +211,7 @@ _write_chartsheet_files(lxw_packager *self)
|
|
210
211
|
lxw_sheet *sheet;
|
211
212
|
lxw_chartsheet *chartsheet;
|
212
213
|
char sheetname[LXW_FILENAME_LENGTH] = { 0 };
|
213
|
-
|
214
|
+
uint32_t index = 1;
|
214
215
|
lxw_error err;
|
215
216
|
|
216
217
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
@@ -251,7 +252,7 @@ _write_image_files(lxw_packager *self)
|
|
251
252
|
FILE *image_stream;
|
252
253
|
|
253
254
|
char filename[LXW_FILENAME_LENGTH] = { 0 };
|
254
|
-
|
255
|
+
uint32_t index = 1;
|
255
256
|
|
256
257
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
257
258
|
if (sheet->is_chartsheet)
|
@@ -293,6 +294,35 @@ _write_image_files(lxw_packager *self)
|
|
293
294
|
return LXW_NO_ERROR;
|
294
295
|
}
|
295
296
|
|
297
|
+
/*
|
298
|
+
* Write the xl/vbaProject.bin file.
|
299
|
+
*/
|
300
|
+
STATIC lxw_error
|
301
|
+
_add_vba_project(lxw_packager *self)
|
302
|
+
{
|
303
|
+
lxw_workbook *workbook = self->workbook;
|
304
|
+
lxw_error err;
|
305
|
+
FILE *image_stream;
|
306
|
+
|
307
|
+
if (!workbook->vba_project)
|
308
|
+
return LXW_NO_ERROR;
|
309
|
+
|
310
|
+
/* Check that the image file exists and can be opened. */
|
311
|
+
image_stream = fopen(workbook->vba_project, "rb");
|
312
|
+
if (!image_stream) {
|
313
|
+
LXW_WARN_FORMAT1("Error adding vbaProject.bin to xlsx file: "
|
314
|
+
"file doesn't exist or can't be opened: %s.",
|
315
|
+
workbook->vba_project);
|
316
|
+
return LXW_ERROR_CREATING_TMPFILE;
|
317
|
+
}
|
318
|
+
|
319
|
+
err = _add_file_to_zip(self, image_stream, "xl/vbaProject.bin");
|
320
|
+
fclose(image_stream);
|
321
|
+
RETURN_ON_ERROR(err);
|
322
|
+
|
323
|
+
return LXW_NO_ERROR;
|
324
|
+
}
|
325
|
+
|
296
326
|
/*
|
297
327
|
* Write the chart files.
|
298
328
|
*/
|
@@ -302,7 +332,7 @@ _write_chart_files(lxw_packager *self)
|
|
302
332
|
lxw_workbook *workbook = self->workbook;
|
303
333
|
lxw_chart *chart;
|
304
334
|
char sheetname[LXW_FILENAME_LENGTH] = { 0 };
|
305
|
-
|
335
|
+
uint32_t index = 1;
|
306
336
|
lxw_error err;
|
307
337
|
|
308
338
|
STAILQ_FOREACH(chart, workbook->ordered_charts, ordered_list_pointers) {
|
@@ -328,12 +358,12 @@ _write_chart_files(lxw_packager *self)
|
|
328
358
|
/*
|
329
359
|
* Count the chart files.
|
330
360
|
*/
|
331
|
-
|
361
|
+
uint32_t
|
332
362
|
_get_chart_count(lxw_packager *self)
|
333
363
|
{
|
334
364
|
lxw_workbook *workbook = self->workbook;
|
335
365
|
lxw_chart *chart;
|
336
|
-
|
366
|
+
uint32_t chart_count = 0;
|
337
367
|
|
338
368
|
STAILQ_FOREACH(chart, workbook->ordered_charts, ordered_list_pointers) {
|
339
369
|
chart_count++;
|
@@ -353,7 +383,7 @@ _write_drawing_files(lxw_packager *self)
|
|
353
383
|
lxw_worksheet *worksheet;
|
354
384
|
lxw_drawing *drawing;
|
355
385
|
char filename[LXW_FILENAME_LENGTH] = { 0 };
|
356
|
-
|
386
|
+
uint32_t index = 1;
|
357
387
|
lxw_error err;
|
358
388
|
|
359
389
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
@@ -386,14 +416,14 @@ _write_drawing_files(lxw_packager *self)
|
|
386
416
|
/*
|
387
417
|
* Count the drawing files.
|
388
418
|
*/
|
389
|
-
|
419
|
+
uint32_t
|
390
420
|
_get_drawing_count(lxw_packager *self)
|
391
421
|
{
|
392
422
|
lxw_workbook *workbook = self->workbook;
|
393
423
|
lxw_sheet *sheet;
|
394
424
|
lxw_worksheet *worksheet;
|
395
425
|
lxw_drawing *drawing;
|
396
|
-
|
426
|
+
uint32_t drawing_count = 0;
|
397
427
|
|
398
428
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
399
429
|
if (sheet->is_chartsheet)
|
@@ -449,7 +479,7 @@ _write_app_file(lxw_packager *self)
|
|
449
479
|
lxw_chartsheet *chartsheet;
|
450
480
|
lxw_defined_name *defined_name;
|
451
481
|
lxw_app *app;
|
452
|
-
|
482
|
+
uint32_t named_range_count = 0;
|
453
483
|
char *autofilter;
|
454
484
|
char *has_range;
|
455
485
|
char number[LXW_ATTR_32] = { 0 };
|
@@ -694,11 +724,11 @@ _write_content_types_file(lxw_packager *self)
|
|
694
724
|
lxw_workbook *workbook = self->workbook;
|
695
725
|
lxw_sheet *sheet;
|
696
726
|
char filename[LXW_MAX_ATTRIBUTE_LENGTH] = { 0 };
|
697
|
-
|
698
|
-
|
699
|
-
|
700
|
-
|
701
|
-
|
727
|
+
uint32_t index = 1;
|
728
|
+
uint32_t worksheet_index = 1;
|
729
|
+
uint32_t chartsheet_index = 1;
|
730
|
+
uint32_t drawing_count = _get_drawing_count(self);
|
731
|
+
uint32_t chart_count = _get_chart_count(self);
|
702
732
|
lxw_error err = LXW_NO_ERROR;
|
703
733
|
|
704
734
|
if (!content_types) {
|
@@ -721,6 +751,17 @@ _write_content_types_file(lxw_packager *self)
|
|
721
751
|
if (workbook->has_bmp)
|
722
752
|
lxw_ct_add_default(content_types, "bmp", "image/bmp");
|
723
753
|
|
754
|
+
if (workbook->vba_project)
|
755
|
+
lxw_ct_add_default(content_types, "bin",
|
756
|
+
"application/vnd.ms-office.vbaProject");
|
757
|
+
|
758
|
+
if (workbook->vba_project)
|
759
|
+
lxw_ct_add_override(content_types, "/xl/workbook.xml",
|
760
|
+
LXW_APP_MSEXCEL "sheet.macroEnabled.main+xml");
|
761
|
+
else
|
762
|
+
lxw_ct_add_override(content_types, "/xl/workbook.xml",
|
763
|
+
LXW_APP_DOCUMENT "spreadsheetml.sheet.main+xml");
|
764
|
+
|
724
765
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
725
766
|
if (sheet->is_chartsheet) {
|
726
767
|
lxw_snprintf(filename, LXW_FILENAME_LENGTH,
|
@@ -774,8 +815,8 @@ _write_workbook_rels_file(lxw_packager *self)
|
|
774
815
|
lxw_workbook *workbook = self->workbook;
|
775
816
|
lxw_sheet *sheet;
|
776
817
|
char sheetname[LXW_FILENAME_LENGTH] = { 0 };
|
777
|
-
|
778
|
-
|
818
|
+
uint32_t worksheet_index = 1;
|
819
|
+
uint32_t chartsheet_index = 1;
|
779
820
|
lxw_error err = LXW_NO_ERROR;
|
780
821
|
|
781
822
|
if (!rels) {
|
@@ -811,6 +852,10 @@ _write_workbook_rels_file(lxw_packager *self)
|
|
811
852
|
lxw_add_document_relationship(rels, "/sharedStrings",
|
812
853
|
"sharedStrings.xml");
|
813
854
|
|
855
|
+
if (workbook->vba_project)
|
856
|
+
lxw_add_ms_package_relationship(rels, "/vbaProject",
|
857
|
+
"vbaProject.bin");
|
858
|
+
|
814
859
|
lxw_relationships_assemble_xml_file(rels);
|
815
860
|
|
816
861
|
err = _add_file_to_zip(self, rels->file, "xl/_rels/workbook.xml.rels");
|
@@ -836,7 +881,7 @@ _write_worksheet_rels_file(lxw_packager *self)
|
|
836
881
|
lxw_sheet *sheet;
|
837
882
|
lxw_worksheet *worksheet;
|
838
883
|
char sheetname[LXW_FILENAME_LENGTH] = { 0 };
|
839
|
-
|
884
|
+
uint32_t index = 0;
|
840
885
|
lxw_error err;
|
841
886
|
|
842
887
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
@@ -898,7 +943,7 @@ _write_chartsheet_rels_file(lxw_packager *self)
|
|
898
943
|
lxw_sheet *sheet;
|
899
944
|
lxw_worksheet *worksheet;
|
900
945
|
char sheetname[LXW_FILENAME_LENGTH] = { 0 };
|
901
|
-
|
946
|
+
uint32_t index = 0;
|
902
947
|
lxw_error err;
|
903
948
|
|
904
949
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
@@ -960,7 +1005,7 @@ _write_drawing_rels_file(lxw_packager *self)
|
|
960
1005
|
lxw_sheet *sheet;
|
961
1006
|
lxw_worksheet *worksheet;
|
962
1007
|
char sheetname[LXW_FILENAME_LENGTH] = { 0 };
|
963
|
-
|
1008
|
+
uint32_t index = 1;
|
964
1009
|
lxw_error err;
|
965
1010
|
|
966
1011
|
STAILQ_FOREACH(sheet, workbook->sheets, list_pointers) {
|
@@ -1066,7 +1111,8 @@ _add_file_to_zip(lxw_packager *self, FILE * file, const char *filename)
|
|
1066
1111
|
NULL, 0, NULL, 0, NULL,
|
1067
1112
|
Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0,
|
1068
1113
|
-MAX_WBITS, DEF_MEM_LEVEL,
|
1069
|
-
Z_DEFAULT_STRATEGY, NULL, 0, 0, 0,
|
1114
|
+
Z_DEFAULT_STRATEGY, NULL, 0, 0, 0,
|
1115
|
+
self->use_zip64);
|
1070
1116
|
|
1071
1117
|
if (error != ZIP_OK) {
|
1072
1118
|
LXW_ERROR("Error adding member to zipfile");
|
@@ -1119,7 +1165,8 @@ _add_buffer_to_zip(lxw_packager *self, unsigned char *buffer,
|
|
1119
1165
|
NULL, 0, NULL, 0, NULL,
|
1120
1166
|
Z_DEFLATED, Z_DEFAULT_COMPRESSION, 0,
|
1121
1167
|
-MAX_WBITS, DEF_MEM_LEVEL,
|
1122
|
-
Z_DEFAULT_STRATEGY, NULL, 0, 0, 0,
|
1168
|
+
Z_DEFAULT_STRATEGY, NULL, 0, 0, 0,
|
1169
|
+
self->use_zip64);
|
1123
1170
|
|
1124
1171
|
if (error != ZIP_OK) {
|
1125
1172
|
LXW_ERROR("Error adding member to zipfile");
|
@@ -1200,6 +1247,9 @@ lxw_create_package(lxw_packager *self)
|
|
1200
1247
|
error = _write_image_files(self);
|
1201
1248
|
RETURN_ON_ERROR(error);
|
1202
1249
|
|
1250
|
+
error = _add_vba_project(self);
|
1251
|
+
RETURN_ON_ERROR(error);
|
1252
|
+
|
1203
1253
|
error = _write_core_file(self);
|
1204
1254
|
RETURN_ON_ERROR(error);
|
1205
1255
|
|
@@ -21,14 +21,19 @@ char *error_strings[LXW_MAX_ERRNO + 1] = {
|
|
21
21
|
"Error creating output xlsx file. Usually a permissions error.",
|
22
22
|
"Error encountered when creating a tmpfile during file assembly.",
|
23
23
|
"Error reading a tmpfile.",
|
24
|
-
"
|
25
|
-
"
|
26
|
-
"
|
24
|
+
"Zip generic error ZIP_ERRNO while creating the xlsx file.",
|
25
|
+
"Zip error ZIP_PARAMERROR while creating the xlsx file.",
|
26
|
+
"Zip error ZIP_BADZIPFILE (use_zip64 option may be required).",
|
27
|
+
"Zip error ZIP_INTERNALERROR while creating the xlsx file.",
|
28
|
+
"File error or unknown zip error when adding sub file to xlsx file.",
|
29
|
+
"Unknown zip error when closing xlsx file.",
|
27
30
|
"NULL function parameter ignored.",
|
28
31
|
"Function parameter validation error.",
|
29
32
|
"Worksheet name exceeds Excel's limit of 31 characters.",
|
30
|
-
"Worksheet name
|
33
|
+
"Worksheet name cannot contain invalid characters: '[ ] : * ? / \\'",
|
34
|
+
"Worksheet name cannot start or end with an apostrophe.",
|
31
35
|
"Worksheet name is already in use.",
|
36
|
+
"Worksheet name 'History' is reserved by Excel.",
|
32
37
|
"Parameter exceeds Excel's limit of 32 characters.",
|
33
38
|
"Parameter exceeds Excel's limit of 128 characters.",
|
34
39
|
"Parameter exceeds Excel's limit of 255 characters.",
|