Skip to content

Commit

Permalink
update libxlsx to v0.8.7
Browse files Browse the repository at this point in the history
  • Loading branch information
j2doll committed Jun 29, 2019
1 parent 3ed0856 commit 24b364d
Show file tree
Hide file tree
Showing 15 changed files with 472 additions and 112 deletions.
3 changes: 2 additions & 1 deletion libxlsxwriter/examples/constant_memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ int main() {

/* Set the worksheet options. */
lxw_workbook_options options = {.constant_memory = LXW_TRUE,
.tmpdir = NULL};
.tmpdir = NULL,
.use_zip64 = LXW_FALSE};

/* Create a new workbook with options. */
lxw_workbook *workbook = workbook_new_opt("constant_memory.xlsx", &options);
Expand Down
25 changes: 25 additions & 0 deletions libxlsxwriter/examples/macro.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*****************************************************************************
*
* An example of adding macros to a libxlsxwriter file using a VBA project
* file extracted from an existing Excel .xlsm file.
*
* The vba_extract.py utility from the libxlsxwriter examples directory can be
* used to extract the vbaProject.bin file.
*
* Copyright 2014-2018, John McNamara, jmcnamara@cpan.org
*/

#include "xlsxwriter.h"

int main() {

lxw_workbook *workbook = new_workbook("macro.xlsm");
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

/* Add a macro that will execute when the file is opened. */
workbook_add_vba_project(workbook, "vbaProject.bin");

worksheet_write_string(worksheet, 0, 0, "Overwrite this", NULL);

return workbook_close(workbook);
}
2 changes: 1 addition & 1 deletion libxlsxwriter/include/xlsxwriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#include "xlsxwriter/format.h"
#include "xlsxwriter/utility.h"

#define LXW_VERSION "0.8.6"
#define LXW_VERSION "0.8.7"

#endif /* __LXW_XLSXWRITER_H__ */
23 changes: 19 additions & 4 deletions libxlsxwriter/include/xlsxwriter/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,22 @@ typedef enum lxw_error {
/** Error reading a tmpfile. */
LXW_ERROR_READING_TMPFILE,

/** Zlib error with a file operation while creating xlsx file. */
/** Zip generic error ZIP_ERRNO while creating the xlsx file. */
LXW_ERROR_ZIP_FILE_OPERATION,

/** Zlib error when adding sub file to xlsx file. */
/** Zip error ZIP_PARAMERROR while creating the xlsx file. */
LXW_ERROR_ZIP_PARAMETER_ERROR,

/** Zip error ZIP_BADZIPFILE (use_zip64 option may be required). */
LXW_ERROR_ZIP_BAD_ZIP_FILE,

/** Zip error ZIP_INTERNALERROR while creating the xlsx file. */
LXW_ERROR_ZIP_INTERNAL_ERROR,

/** File error or unknown zip error when adding sub file to xlsx file. */
LXW_ERROR_ZIP_FILE_ADD,

/** Zlib error when closing xlsx file. */
/** Unknown zip error when closing xlsx file. */
LXW_ERROR_ZIP_CLOSE,

/** NULL function parameter ignored. */
Expand All @@ -86,12 +95,18 @@ typedef enum lxw_error {
/** Worksheet name exceeds Excel's limit of 31 characters. */
LXW_ERROR_SHEETNAME_LENGTH_EXCEEDED,

/** Worksheet name contains invalid Excel character: '[]:*?/\\' */
/** Worksheet name cannot contain invalid characters: '[ ] : * ? / \\' */
LXW_ERROR_INVALID_SHEETNAME_CHARACTER,

/** Worksheet name cannot start or end with an apostrophe. */
LXW_ERROR_SHEETNAME_START_END_APOSTROPHE,

/** Worksheet name is already in use. */
LXW_ERROR_SHEETNAME_ALREADY_USED,

/** Worksheet name 'History' is reserved by Excel. */
LXW_ERROR_SHEETNAME_RESERVED,

/** Parameter exceeds Excel's limit of 32 characters. */
LXW_ERROR_32_STRING_LENGTH_EXCEEDED,

Expand Down
1 change: 1 addition & 0 deletions libxlsxwriter/include/xlsxwriter/content_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#define LXW_APP_PACKAGE "application/vnd.openxmlformats-package."
#define LXW_APP_DOCUMENT "application/vnd.openxmlformats-officedocument."
#define LXW_APP_MSEXCEL "application/vnd.ms-excel."

/*
* Struct to represent a content_types.
Expand Down
16 changes: 12 additions & 4 deletions libxlsxwriter/include/xlsxwriter/packager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,17 @@

#define LXW_ZIP_BUFFER_SIZE (16384)

/* If zlib returns Z_ERRNO then errno is set and we can trap that. Otherwise
* return a default libxlsxwriter error. */
/* If zip returns a ZIP_XXX error then errno is set and we can trap that in
* workbook.c. Otherwise return a default libxlsxwriter error. */
#define RETURN_ON_ZIP_ERROR(err, default_err) \
if (err == Z_ERRNO) \
if (err == ZIP_ERRNO) \
return LXW_ERROR_ZIP_FILE_OPERATION; \
else if (err == ZIP_PARAMERROR) \
return LXW_ERROR_ZIP_PARAMETER_ERROR; \
else if (err == ZIP_BADZIPFILE) \
return LXW_ERROR_ZIP_BAD_ZIP_FILE; \
else if (err == ZIP_INTERNALERROR) \
return LXW_ERROR_ZIP_INTERNAL_ERROR; \
else \
return default_err;

Expand All @@ -54,6 +60,7 @@ typedef struct lxw_packager {
char *filename;
char *buffer;
char *tmpdir;
uint8_t use_zip64;

} lxw_packager;

Expand All @@ -64,7 +71,8 @@ extern "C" {
#endif
/* *INDENT-ON* */

lxw_packager *lxw_packager_new(const char *filename, char *tmpdir);
lxw_packager *lxw_packager_new(const char *filename, char *tmpdir,
uint8_t use_zip64);
void lxw_packager_free(lxw_packager *packager);
lxw_error lxw_create_package(lxw_packager *self);

Expand Down
8 changes: 8 additions & 0 deletions libxlsxwriter/include/xlsxwriter/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#define __LXW_UTILITY_H__

#include <stdint.h>
#include <strings.h>
#include "common.h"
#include "xmlwriter.h"

Expand Down Expand Up @@ -166,6 +167,13 @@ size_t lxw_utf8_strlen(const char *str);

void lxw_str_tolower(char *str);

/* Define a portable version of strcasecmp(). */
#ifdef _MSC_VER
#define lxw_strcasecmp _stricmp
#else
#define lxw_strcasecmp strcasecmp
#endif

FILE *lxw_tmpfile(char *tmpdir);

/* Use a user defined function to format doubles in sprintf or else a simple
Expand Down
Loading

0 comments on commit 24b364d

Please sign in to comment.