Skip to content

Commit

Permalink
Import libxlsxwriter
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroen committed Feb 9, 2024
1 parent aa95be1 commit 0b171db
Show file tree
Hide file tree
Showing 58 changed files with 5,662 additions and 1,437 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: writexl
Type: Package
Title: Export Data Frames to Excel 'xlsx' Format
Version: 1.4.2
Version: 1.5.0
Authors@R: c(
person("Jeroen", "Ooms", ,"[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0002-4035-0289")),
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
1.5.0
- Update libxlsxwriter from b0c76b33

1.4.2
- Bugfix for NA timestamps

Expand Down
5 changes: 3 additions & 2 deletions src/Makevars
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ LIBXLSXWRITER = \
libxlsxwriter/core.o libxlsxwriter/relationships.o libxlsxwriter/worksheet.o \
libxlsxwriter/custom.o libxlsxwriter/shared_strings.o libxlsxwriter/xmlwriter.o \
libxlsxwriter/drawing.o libxlsxwriter/styles.o tmpfileplus/tmpfileplus.o \
libxlsxwriter/chartsheet.o minizip/ioapi.o minizip/zip.o \
libxlsxwriter/comment.o libxlsxwriter/vml.o md5/md5.o
libxlsxwriter/chartsheet.o minizip/ioapi.o minizip/zip.o libxlsxwriter/metadata.o \
libxlsxwriter/comment.o libxlsxwriter/vml.o md5/md5.o libxlsxwriter/table.o \


STATICLIB=libxlsxwriter/libstatxlsxwriter.a

Expand Down
7 changes: 4 additions & 3 deletions src/include/xlsxwriter.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* libxlsxwriter
*
* Copyright 2014-2021, John McNamara, [email protected]. See LICENSE.txt.
* Copyright 2014-2022, John McNamara, [email protected]. See LICENSE.txt.
*/

/**
Expand All @@ -18,7 +18,8 @@
#include "xlsxwriter/format.h"
#include "xlsxwriter/utility.h"

#define LXW_VERSION "1.0.3"
#define LXW_VERSION_ID 103
#define LXW_VERSION "1.1.5"
#define LXW_VERSION_ID 115
#define LXW_SOVERSION "5"

#endif /* __LXW_XLSXWRITER_H__ */
2 changes: 1 addition & 1 deletion src/include/xlsxwriter/app.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* libxlsxwriter
*
* Copyright 2014-2021, John McNamara, [email protected]. See LICENSE.txt.
* Copyright 2014-2022, John McNamara, [email protected]. See LICENSE.txt.
*
* app - A libxlsxwriter library for creating Excel XLSX app files.
*
Expand Down
31 changes: 24 additions & 7 deletions src/include/xlsxwriter/chart.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* libxlsxwriter
*
* Copyright 2014-2021, John McNamara, [email protected]. See LICENSE.txt.
* Copyright 2014-2022, John McNamara, [email protected]. See LICENSE.txt.
*
* chart - A libxlsxwriter library for creating Excel XLSX chart files.
*
Expand Down Expand Up @@ -699,7 +699,7 @@ typedef struct lxw_chart_pattern {
typedef struct lxw_chart_font {

/** The chart font name, such as "Arial" or "Calibri". */
char *name;
const char *name;

/** The chart font size. The default is 11. */
double size;
Expand All @@ -713,9 +713,12 @@ typedef struct lxw_chart_font {
/** The chart font underline property. Set to 0 or 1. */
uint8_t underline;

/** The chart font rotation property. Range: -90 to 90, and 270-271.
* The angle 270 gives a stacked (top to bottom) alignment.
* The angle 271 gives a stacked alignment for East Asian fonts.
/** The chart font rotation property. Range: -90 to 90, and 270, 271 and 360:
*
* - The angles -90 to 90 are the normal range shown in the Excel user interface.
* - The angle 270 gives a stacked (top to bottom) alignment.
* - The angle 271 gives a stacked alignment for East Asian fonts.
* - The angle 360 gives an explicit angle of 0 to override the y axis default.
* */
int32_t rotation;

Expand Down Expand Up @@ -797,7 +800,7 @@ typedef struct lxw_chart_data_label {

/** The string or formula value for the data label. See
* @ref chart_custom_labels. */
char *value;
const char *value;

/** Option to hide/delete the data label from the chart series.
* See @ref chart_custom_labels. */
Expand Down Expand Up @@ -3232,14 +3235,28 @@ void chart_title_set_name_range(lxw_chart *chart, const char *sheetname,
* chart title:
*
* @code
* lxw_chart_font font = {.bold = LXW_TRUE, .color = LXW_COLOR_BLUE};
* lxw_chart_font font = {.color = LXW_COLOR_BLUE};
*
* chart_title_set_name(chart, "Year End Results");
* chart_title_set_name_font(chart, &font);
* @endcode
*
* @image html chart_title_set_name_font.png
*
* In Excel a chart title font is bold by default (as shown in the image
* above). To turn off bold in the font you cannot use #LXW_FALSE (0) since
* that is indistinguishable from an uninitialized value. Instead you should
* use #LXW_EXPLICIT_FALSE:
*
* @code
* lxw_chart_font font = {.bold = LXW_EXPLICIT_FALSE, .color = LXW_COLOR_BLUE};
*
* chart_title_set_name(chart, "Year End Results");
* chart_title_set_name_font(chart, &font);
* @endcode
*
* @image html chart_title_set_name_font2.png
*
* For more information see @ref chart_fonts.
*/
void chart_title_set_name_font(lxw_chart *chart, lxw_chart_font *font);
Expand Down
10 changes: 5 additions & 5 deletions src/include/xlsxwriter/chartsheet.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* libxlsxwriter
*
* Copyright 2014-2021, John McNamara, [email protected]. See LICENSE.txt.
* Copyright 2014-2022, John McNamara, [email protected]. See LICENSE.txt.
*
* chartsheet - A libxlsxwriter library for creating Excel XLSX chartsheet files.
*
Expand Down Expand Up @@ -80,10 +80,10 @@ typedef struct lxw_chartsheet {
struct lxw_protection_obj protection;
uint8_t is_protected;

char *name;
char *quoted_name;
char *tmpdir;
uint32_t index;
const char *name;
const char *quoted_name;
const char *tmpdir;
uint16_t index;
uint8_t active;
uint8_t selected;
uint8_t hidden;
Expand Down
2 changes: 1 addition & 1 deletion src/include/xlsxwriter/comment.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* libxlsxwriter
*
* Copyright 2014-2021, John McNamara, [email protected]. See LICENSE.txt.
* Copyright 2014-2022, John McNamara, [email protected]. See LICENSE.txt.
*
* comment - A libxlsxwriter library for creating Excel XLSX comment files.
*
Expand Down
131 changes: 80 additions & 51 deletions src/include/xlsxwriter/common.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
/*
* libxlsxwriter
*
* Copyright 2014-2021, John McNamara, [email protected]. See LICENSE.txt.
* Copyright 2014-2022, John McNamara, [email protected]. See LICENSE.txt.
*/

/**
* @file common.h
*
* @brief Common functions and defines for the libxlsxwriter library.
*
* <!-- Copyright 2014-2021, John McNamara, [email protected] -->
* <!-- Copyright 2014-2022, John McNamara, [email protected] -->
*
*/
#ifndef __LXW_COMMON_H__
Expand Down Expand Up @@ -50,7 +50,10 @@ enum lxw_boolean {
/** False value. */
LXW_FALSE,
/** True value. */
LXW_TRUE
LXW_TRUE,
/** False value. Used to turn off a property that is default on, in order
* to distinguish it from an uninitialized value. */
LXW_EXPLICIT_FALSE
};

/**
Expand Down Expand Up @@ -203,7 +206,7 @@ enum lxw_custom_property_types {
#define LXW_DATETIME_LENGTH sizeof("2016-12-12T23:00:00Z")

/* GUID string length. */
#define LXW_GUID_LENGTH sizeof("{12345678-1234-1234-1234-1234567890AB}")
#define LXW_GUID_LENGTH sizeof("{12345678-1234-1234-1234-1234567890AB}\0")

#define LXW_EPOCH_1900 0
#define LXW_EPOCH_1904 1
Expand All @@ -223,13 +226,14 @@ enum lxw_custom_property_types {
#define LXW_SCHEMA_DOCUMENT LXW_SCHEMA_ROOT "/officeDocument/2006/relationships"
#define LXW_SCHEMA_CONTENT LXW_SCHEMA_ROOT "/package/2006/content-types"

/* Use REprintf() for error handling when compiled as an R library. */
#ifdef USE_R_LANG
#include <R.h>
#define LXW_PRINTF REprintf
#define LXW_STDERR
#define LXW_PRINTF REprintf
#define LXW_STDERR
#else
#define LXW_PRINTF fprintf
#define LXW_STDERR stderr,
#define LXW_PRINTF fprintf
#define LXW_STDERR stderr,
#endif

#define LXW_ERROR(message) \
Expand All @@ -239,32 +243,42 @@ enum lxw_custom_property_types {
LXW_ERROR("Memory allocation failed.")

#define GOTO_LABEL_ON_MEM_ERROR(pointer, label) \
if (!pointer) { \
LXW_MEM_ERROR(); \
goto label; \
}
do { \
if (!pointer) { \
LXW_MEM_ERROR(); \
goto label; \
} \
} while (0)

#define RETURN_ON_MEM_ERROR(pointer, error) \
if (!pointer) { \
LXW_MEM_ERROR(); \
return error; \
}
do { \
if (!pointer) { \
LXW_MEM_ERROR(); \
return error; \
} \
} while (0)

#define RETURN_VOID_ON_MEM_ERROR(pointer) \
if (!pointer) { \
LXW_MEM_ERROR(); \
return; \
}
do { \
if (!pointer) { \
LXW_MEM_ERROR(); \
return; \
} \
} while (0)

#define RETURN_ON_ERROR(error) \
if (error) \
return error;
do { \
if (error) \
return error; \
} while (0)

#define RETURN_AND_ZIPCLOSE_ON_ERROR(error) \
if (error) { \
zipClose(self->zipfile, NULL); \
return error; \
}
do { \
if (error) { \
zipClose(self->zipfile, NULL); \
return error; \
} \
} while (0)

#define LXW_WARN(message) \
LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n")
Expand All @@ -279,52 +293,67 @@ enum lxw_custom_property_types {
#define LXW_WARN_FORMAT2(message, var1, var2) \
LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n", var1, var2)

#define LXW_WARN_FORMAT3(message, var1, var2, var3) \
LXW_PRINTF(LXW_STDERR "[WARNING]: " message "\n", var1, var2, var3)

/* Chart axis type checks. */
#define LXW_WARN_CAT_AXIS_ONLY(function) \
if (!axis->is_category) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
function "() is only valid for category axes\n"); \
return; \
}
do { \
if (!axis->is_category) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
function "() is only valid for category axes\n"); \
return; \
} \
} while (0)

#define LXW_WARN_VALUE_AXIS_ONLY(function) \
if (!axis->is_value) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
do { \
if (!axis->is_value) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
function "() is only valid for value axes\n"); \
return; \
}
return; \
} \
} while (0)

#define LXW_WARN_DATE_AXIS_ONLY(function) \
if (!axis->is_date) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
function "() is only valid for date axes\n"); \
return; \
}
do { \
if (!axis->is_date) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
function "() is only valid for date axes\n"); \
return; \
} \
} while (0)

#define LXW_WARN_CAT_AND_DATE_AXIS_ONLY(function) \
if (!axis->is_category && !axis->is_date) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
do { \
if (!axis->is_category && !axis->is_date) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
function "() is only valid for category and date axes\n"); \
return; \
}
return; \
} \
} while (0)

#define LXW_WARN_VALUE_AND_DATE_AXIS_ONLY(function) \
if (!axis->is_value && !axis->is_date) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
do { \
if (!axis->is_value && !axis->is_date) { \
LXW_PRINTF(LXW_STDERR "[WARNING]: " \
function "() is only valid for value and date axes\n"); \
return; \
}
return; \
} \
} while (0)

#ifndef LXW_BIG_ENDIAN
#define LXW_UINT16_HOST(n) (n)
#define LXW_UINT32_HOST(n) (n)
#define LXW_UINT16_NETWORK(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
#define LXW_UINT32_NETWORK(n) ((((n) & 0xFF) << 24) | \
(((n) & 0xFF00) << 8) | \
(((n) & 0xFF0000) >> 8) | \
(((n) & 0xFF000000) >> 24))
#define LXW_UINT16_NETWORK(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
#define LXW_UINT32_HOST(n) (n)
#else
#define LXW_UINT32_NETWORK(n) (n)
#define LXW_UINT16_NETWORK(n) (n)
#define LXW_UINT32_NETWORK(n) (n)
#define LXW_UINT16_HOST(n) ((((n) & 0x00FF) << 8) | (((n) & 0xFF00) >> 8))
#define LXW_UINT32_HOST(n) ((((n) & 0xFF) << 24) | \
(((n) & 0xFF00) << 8) | \
(((n) & 0xFF0000) >> 8) | \
Expand Down
Loading

0 comments on commit 0b171db

Please sign in to comment.