mirror of
https://github.com/jmcnamara/libxlsxwriter
synced 2025-03-28 21:13:14 +00:00
Converted return types to explicit lxw_error.
Converted return types to explicit lxw_error for better compatibility with C++ compilers. Issue #56.
This commit is contained in:
parent
a094313ac8
commit
50dba518e5
@ -13,10 +13,15 @@ use strict;
|
||||
|
||||
my $in_enum = 0;
|
||||
my @strings;
|
||||
while (<>) {
|
||||
|
||||
$in_enum = 1 if /enum lxw_error/;
|
||||
$in_enum = 0 if /};/;
|
||||
my $filename = shift || 'include/xlsxwriter/common.h';
|
||||
open my $fh, '<', $filename or die "Couldn't open $filename: $!\n";
|
||||
|
||||
|
||||
while (<$fh>) {
|
||||
|
||||
$in_enum = 1 if /typedef enum lxw_error/;
|
||||
$in_enum = 0 if /} lxw_error;/;
|
||||
|
||||
# Match doxygen strings in the enum.
|
||||
if ($in_enum && m{/\*\*}) {
|
||||
@ -31,6 +36,7 @@ while (<>) {
|
||||
|
||||
# Print out an array of strings based on the doxygen comments.
|
||||
print "\n";
|
||||
print "// Copy to src/utility.c\n\n";
|
||||
print "char *error_strings[LXW_MAX_ERRNO + 1] = {\n";
|
||||
for my $string (@strings) {
|
||||
print qq{ "$string",\n};
|
||||
|
@ -52,7 +52,7 @@ int main() {
|
||||
|
||||
|
||||
/* Close the workbook, save the file and free any memory. */
|
||||
uint8_t error = workbook_close(workbook);
|
||||
lxw_error error = workbook_close(workbook);
|
||||
|
||||
/* Check if there was any error creating the xlsx file. */
|
||||
if (error)
|
||||
|
@ -51,7 +51,7 @@ enum lxw_boolean {
|
||||
* See the `lxw_strerror()` function for an example of how to convert the
|
||||
* enum number to a descriptive error message string.
|
||||
*/
|
||||
enum lxw_error {
|
||||
typedef enum lxw_error {
|
||||
|
||||
/** No error. */
|
||||
LXW_NO_ERROR = 0,
|
||||
@ -77,9 +77,15 @@ enum lxw_error {
|
||||
/** NULL function parameter ignored. */
|
||||
LXW_ERROR_NULL_PARAMETER_IGNORED,
|
||||
|
||||
/** Function parameter validation error. */
|
||||
LXW_ERROR_PARAMETER_VALIDATION,
|
||||
|
||||
/** String exceeds Excel's limit of 32,767 characters. */
|
||||
LXW_ERROR_MAX_STRING_LENGTH_EXCEEDED,
|
||||
|
||||
/** Parameter exceeds Excel's limit of 128 characters. */
|
||||
LXW_ERROR_128_STRING_LENGTH_EXCEEDED,
|
||||
|
||||
/** Parameter exceeds Excel's limit of 255 characters. */
|
||||
LXW_ERROR_255_STRING_LENGTH_EXCEEDED,
|
||||
|
||||
@ -92,8 +98,11 @@ enum lxw_error {
|
||||
/** Maximum number of worksheet URLs (65530) exceeded. */
|
||||
LXW_ERROR_WORKSHEET_MAX_NUMBER_URLS_EXCEEDED,
|
||||
|
||||
/** Couldn't read image dimensions or DPI. */
|
||||
LXW_ERROR_IMAGE_DIMENSIONS,
|
||||
|
||||
LXW_MAX_ERRNO
|
||||
};
|
||||
} lxw_error;
|
||||
|
||||
/** @brief Struct to represent a date and time in Excel.
|
||||
*
|
||||
|
@ -428,7 +428,7 @@ lxw_chart *workbook_add_chart(lxw_workbook *workbook, uint8_t chart_type);
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
uint8_t workbook_close(lxw_workbook *workbook);
|
||||
lxw_error workbook_close(lxw_workbook *workbook);
|
||||
|
||||
/**
|
||||
* @brief Set the document properties such as Title, Author etc.
|
||||
@ -481,8 +481,8 @@ uint8_t workbook_close(lxw_workbook *workbook);
|
||||
* @image html doc_properties.png
|
||||
*
|
||||
*/
|
||||
uint8_t workbook_set_properties(lxw_workbook *workbook,
|
||||
lxw_doc_properties *properties);
|
||||
lxw_error workbook_set_properties(lxw_workbook *workbook,
|
||||
lxw_doc_properties *properties);
|
||||
|
||||
/**
|
||||
* @brief Set a custom document text property.
|
||||
@ -517,8 +517,8 @@ uint8_t workbook_set_properties(lxw_workbook *workbook,
|
||||
* by Excel.
|
||||
*
|
||||
*/
|
||||
uint8_t workbook_set_custom_property_string(lxw_workbook *workbook,
|
||||
char *name, char *value);
|
||||
lxw_error workbook_set_custom_property_string(lxw_workbook *workbook,
|
||||
char *name, char *value);
|
||||
/**
|
||||
* @brief Set a custom document number property.
|
||||
*
|
||||
@ -535,14 +535,14 @@ uint8_t workbook_set_custom_property_string(lxw_workbook *workbook,
|
||||
* workbook_set_custom_property_number(workbook, "Document number", 12345);
|
||||
* @endcode
|
||||
*/
|
||||
uint8_t workbook_set_custom_property_number(lxw_workbook *workbook,
|
||||
char *name, double value);
|
||||
lxw_error workbook_set_custom_property_number(lxw_workbook *workbook,
|
||||
char *name, double value);
|
||||
|
||||
/* Undocumented since the user can use workbook_set_custom_property_number().
|
||||
* Only implemented for file format completeness and testing.
|
||||
*/
|
||||
uint8_t workbook_set_custom_property_integer(lxw_workbook *workbook,
|
||||
char *name, int32_t value);
|
||||
lxw_error workbook_set_custom_property_integer(lxw_workbook *workbook,
|
||||
char *name, int32_t value);
|
||||
|
||||
/**
|
||||
* @brief Set a custom document boolean property.
|
||||
@ -560,8 +560,8 @@ uint8_t workbook_set_custom_property_integer(lxw_workbook *workbook,
|
||||
* workbook_set_custom_property_boolean(workbook, "Has Review", 1);
|
||||
* @endcode
|
||||
*/
|
||||
uint8_t workbook_set_custom_property_boolean(lxw_workbook *workbook,
|
||||
char *name, uint8_t value);
|
||||
lxw_error workbook_set_custom_property_boolean(lxw_workbook *workbook,
|
||||
char *name, uint8_t value);
|
||||
/**
|
||||
* @brief Set a custom document date or time property.
|
||||
*
|
||||
@ -580,9 +580,9 @@ uint8_t workbook_set_custom_property_boolean(lxw_workbook *workbook,
|
||||
* workbook_set_custom_property_datetime(workbook, "Date completed", &datetime);
|
||||
* @endcode
|
||||
*/
|
||||
uint8_t workbook_set_custom_property_datetime(lxw_workbook *workbook,
|
||||
char *name,
|
||||
lxw_datetime *datetime);
|
||||
lxw_error workbook_set_custom_property_datetime(lxw_workbook *workbook,
|
||||
char *name,
|
||||
lxw_datetime *datetime);
|
||||
|
||||
/**
|
||||
* @brief Create a defined name in the workbook to use as a variable.
|
||||
@ -633,8 +633,8 @@ uint8_t workbook_set_custom_property_datetime(lxw_workbook *workbook,
|
||||
documentation](http://office.microsoft.com/en-001/excel-help/define-and-use-names-in-formulas-HA010147120.aspx).
|
||||
*
|
||||
*/
|
||||
uint8_t workbook_define_name(lxw_workbook *workbook, const char *name,
|
||||
const char *formula);
|
||||
lxw_error workbook_define_name(lxw_workbook *workbook, const char *name,
|
||||
const char *formula);
|
||||
|
||||
lxw_worksheet *workbook_get_worksheet_by_name(lxw_workbook *workbook,
|
||||
char *name);
|
||||
@ -661,9 +661,10 @@ STATIC void _write_defined_name(lxw_workbook *self,
|
||||
lxw_defined_name *define_name);
|
||||
STATIC void _write_defined_names(lxw_workbook *self);
|
||||
|
||||
STATIC uint8_t _store_defined_name(lxw_workbook *self, const char *name,
|
||||
const char *app_name, const char *formula,
|
||||
int16_t index, uint8_t hidden);
|
||||
STATIC lxw_error _store_defined_name(lxw_workbook *self, const char *name,
|
||||
const char *app_name,
|
||||
const char *formula, int16_t index,
|
||||
uint8_t hidden);
|
||||
|
||||
#endif /* TESTING */
|
||||
|
||||
|
@ -558,10 +558,10 @@ extern "C" {
|
||||
* @image html write_number02.png
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_number(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, double number,
|
||||
lxw_format *format);
|
||||
lxw_error worksheet_write_number(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, double number,
|
||||
lxw_format *format);
|
||||
/**
|
||||
* @brief Write a string to a worksheet cell.
|
||||
*
|
||||
@ -606,10 +606,10 @@ int8_t worksheet_write_number(lxw_worksheet *worksheet,
|
||||
* @image html write_string03.png
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_string(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, const char *string,
|
||||
lxw_format *format);
|
||||
lxw_error worksheet_write_string(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, const char *string,
|
||||
lxw_format *format);
|
||||
/**
|
||||
* @brief Write a formula to a worksheet cell.
|
||||
*
|
||||
@ -658,10 +658,10 @@ int8_t worksheet_write_string(lxw_worksheet *worksheet,
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_formula(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, const char *formula,
|
||||
lxw_format *format);
|
||||
lxw_error worksheet_write_formula(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, const char *formula,
|
||||
lxw_format *format);
|
||||
/**
|
||||
* @brief Write an array formula to a worksheet cell.
|
||||
*
|
||||
@ -704,20 +704,22 @@ int8_t worksheet_write_formula(lxw_worksheet *worksheet,
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_array_formula(lxw_worksheet *worksheet,
|
||||
lxw_row_t first_row,
|
||||
lxw_col_t first_col,
|
||||
lxw_row_t last_row,
|
||||
lxw_col_t last_col,
|
||||
const char *formula, lxw_format *format);
|
||||
lxw_error worksheet_write_array_formula(lxw_worksheet *worksheet,
|
||||
lxw_row_t first_row,
|
||||
lxw_col_t first_col,
|
||||
lxw_row_t last_row,
|
||||
lxw_col_t last_col,
|
||||
const char *formula,
|
||||
lxw_format *format);
|
||||
|
||||
int8_t worksheet_write_array_formula_num(lxw_worksheet *worksheet,
|
||||
lxw_row_t first_row,
|
||||
lxw_col_t first_col,
|
||||
lxw_row_t last_row,
|
||||
lxw_col_t last_col,
|
||||
const char *formula,
|
||||
lxw_format *format, double result);
|
||||
lxw_error worksheet_write_array_formula_num(lxw_worksheet *worksheet,
|
||||
lxw_row_t first_row,
|
||||
lxw_col_t first_col,
|
||||
lxw_row_t last_row,
|
||||
lxw_col_t last_col,
|
||||
const char *formula,
|
||||
lxw_format *format,
|
||||
double result);
|
||||
|
||||
/**
|
||||
* @brief Write a date or time to a worksheet cell.
|
||||
@ -746,16 +748,16 @@ int8_t worksheet_write_array_formula_num(lxw_worksheet *worksheet,
|
||||
* See @ref working_with_dates for more information about handling dates and
|
||||
* times in libxlsxwriter.
|
||||
*/
|
||||
int8_t worksheet_write_datetime(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, lxw_datetime *datetime,
|
||||
lxw_format *format);
|
||||
lxw_error worksheet_write_datetime(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, lxw_datetime *datetime,
|
||||
lxw_format *format);
|
||||
|
||||
int8_t worksheet_write_url_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, const char *url,
|
||||
lxw_format *format, const char *string,
|
||||
const char *tooltip);
|
||||
lxw_error worksheet_write_url_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, const char *url,
|
||||
lxw_format *format, const char *string,
|
||||
const char *tooltip);
|
||||
/**
|
||||
*
|
||||
* @param worksheet pointer to a lxw_worksheet instance to be updated.
|
||||
@ -886,10 +888,10 @@ int8_t worksheet_write_url_opt(lxw_worksheet *worksheet,
|
||||
* correctly by the user and will by passed directly to Excel.
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_url(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, const char *url,
|
||||
lxw_format *format);
|
||||
lxw_error worksheet_write_url(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col, const char *url,
|
||||
lxw_format *format);
|
||||
|
||||
/**
|
||||
* @brief Write a formatted boolean worksheet cell.
|
||||
@ -909,9 +911,9 @@ int8_t worksheet_write_url(lxw_worksheet *worksheet,
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_boolean(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
int value, lxw_format *format);
|
||||
lxw_error worksheet_write_boolean(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
int value, lxw_format *format);
|
||||
|
||||
/**
|
||||
* @brief Write a formatted blank worksheet cell.
|
||||
@ -940,9 +942,9 @@ int8_t worksheet_write_boolean(lxw_worksheet *worksheet,
|
||||
* As such, if you write an empty cell without formatting it is ignored.
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_blank(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
lxw_format *format);
|
||||
lxw_error worksheet_write_blank(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
lxw_format *format);
|
||||
|
||||
/**
|
||||
* @brief Write a formula to a worksheet cell with a user defined result.
|
||||
@ -986,11 +988,11 @@ int8_t worksheet_write_blank(lxw_worksheet *worksheet,
|
||||
* formulas.
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col,
|
||||
const char *formula,
|
||||
lxw_format *format, double result);
|
||||
lxw_error worksheet_write_formula_num(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
lxw_col_t col,
|
||||
const char *formula,
|
||||
lxw_format *format, double result);
|
||||
|
||||
/**
|
||||
* @brief Set the properties for a row of cells.
|
||||
@ -1044,8 +1046,8 @@ int8_t worksheet_write_formula_num(lxw_worksheet *worksheet,
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_set_row(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, double height, lxw_format *format);
|
||||
lxw_error worksheet_set_row(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, double height, lxw_format *format);
|
||||
|
||||
/**
|
||||
* @brief Set the properties for a row of cells.
|
||||
@ -1077,11 +1079,11 @@ int8_t worksheet_set_row(lxw_worksheet *worksheet,
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_set_row_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
double height,
|
||||
lxw_format *format,
|
||||
lxw_row_col_options *options);
|
||||
lxw_error worksheet_set_row_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row,
|
||||
double height,
|
||||
lxw_format *format,
|
||||
lxw_row_col_options *options);
|
||||
|
||||
/**
|
||||
* @brief Set the properties for one or more columns of cells.
|
||||
@ -1172,10 +1174,10 @@ int8_t worksheet_set_row_opt(lxw_worksheet *worksheet,
|
||||
* worksheet_write_string(worksheet, 1, 0, "Hello", NULL);
|
||||
* @endcode
|
||||
*/
|
||||
int8_t worksheet_set_column(lxw_worksheet *worksheet,
|
||||
lxw_col_t first_col,
|
||||
lxw_col_t last_col,
|
||||
double width, lxw_format *format);
|
||||
lxw_error worksheet_set_column(lxw_worksheet *worksheet,
|
||||
lxw_col_t first_col,
|
||||
lxw_col_t last_col,
|
||||
double width, lxw_format *format);
|
||||
|
||||
/**
|
||||
* @brief Set the properties for one or more columns of cells with options.
|
||||
@ -1207,12 +1209,12 @@ int8_t worksheet_set_column(lxw_worksheet *worksheet,
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
int8_t worksheet_set_column_opt(lxw_worksheet *worksheet,
|
||||
lxw_col_t first_col,
|
||||
lxw_col_t last_col,
|
||||
double width,
|
||||
lxw_format *format,
|
||||
lxw_row_col_options *options);
|
||||
lxw_error worksheet_set_column_opt(lxw_worksheet *worksheet,
|
||||
lxw_col_t first_col,
|
||||
lxw_col_t last_col,
|
||||
double width,
|
||||
lxw_format *format,
|
||||
lxw_row_col_options *options);
|
||||
|
||||
/**
|
||||
* @brief Insert an image in a worksheet cell.
|
||||
@ -1247,9 +1249,9 @@ int8_t worksheet_set_column_opt(lxw_worksheet *worksheet,
|
||||
* best to avoid BMP images since they aren't compressed. If used, BMP images
|
||||
* must be 24 bit, true color, bitmaps.
|
||||
*/
|
||||
int worksheet_insert_image(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
const char *filename);
|
||||
lxw_error worksheet_insert_image(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
const char *filename);
|
||||
|
||||
/**
|
||||
* @brief Insert an image in a worksheet cell, with options.
|
||||
@ -1279,10 +1281,10 @@ int worksheet_insert_image(lxw_worksheet *worksheet,
|
||||
* @note See the notes about row scaling and BMP images in
|
||||
* `worksheet_insert_image()` above.
|
||||
*/
|
||||
int worksheet_insert_image_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
const char *filename,
|
||||
lxw_image_options *options);
|
||||
lxw_error worksheet_insert_image_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
const char *filename,
|
||||
lxw_image_options *options);
|
||||
/**
|
||||
* @brief Insert a chart object into a worksheet.
|
||||
*
|
||||
@ -1319,8 +1321,9 @@ int worksheet_insert_image_opt(lxw_worksheet *worksheet,
|
||||
* `%worksheet_insert_chart()`.
|
||||
*
|
||||
*/
|
||||
int worksheet_insert_chart(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col, lxw_chart *chart);
|
||||
lxw_error worksheet_insert_chart(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
lxw_chart *chart);
|
||||
|
||||
/**
|
||||
* @brief Insert a chart object into a worksheet, with options.
|
||||
@ -1351,10 +1354,10 @@ int worksheet_insert_chart(lxw_worksheet *worksheet,
|
||||
* `worksheet_insert_image_opt()` to position and scale images.
|
||||
*
|
||||
*/
|
||||
int worksheet_insert_chart_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
lxw_chart *chart,
|
||||
lxw_image_options *user_options);
|
||||
lxw_error worksheet_insert_chart_opt(lxw_worksheet *worksheet,
|
||||
lxw_row_t row, lxw_col_t col,
|
||||
lxw_chart *chart,
|
||||
lxw_image_options *user_options);
|
||||
|
||||
/**
|
||||
* @brief Merge a range of cells.
|
||||
@ -1413,10 +1416,10 @@ int worksheet_insert_chart_opt(lxw_worksheet *worksheet,
|
||||
* worksheet_write_number(worksheet, 1, 1, 123, format);
|
||||
* @endcode
|
||||
*/
|
||||
uint8_t worksheet_merge_range(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col, const char *string,
|
||||
lxw_format *format);
|
||||
lxw_error worksheet_merge_range(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col, const char *string,
|
||||
lxw_format *format);
|
||||
|
||||
/**
|
||||
* @brief Set the autofilter area in the worksheet.
|
||||
@ -1450,9 +1453,9 @@ uint8_t worksheet_merge_range(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
* Note: it isn't currently possible to apply filter conditions to the
|
||||
* autofilter.
|
||||
*/
|
||||
uint8_t worksheet_autofilter(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col);
|
||||
lxw_error worksheet_autofilter(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col);
|
||||
|
||||
/**
|
||||
* @brief Make a worksheet the active, i.e., visible worksheet.
|
||||
@ -1972,7 +1975,7 @@ void worksheet_set_margins(lxw_worksheet *worksheet, double left,
|
||||
* longer than this will not be written.
|
||||
*
|
||||
*/
|
||||
uint8_t worksheet_set_header(lxw_worksheet *worksheet, char *string);
|
||||
lxw_error worksheet_set_header(lxw_worksheet *worksheet, char *string);
|
||||
|
||||
/**
|
||||
* @brief Set the printed page footer caption.
|
||||
@ -1985,7 +1988,7 @@ uint8_t worksheet_set_header(lxw_worksheet *worksheet, char *string);
|
||||
* The syntax of this function is the same as worksheet_set_header().
|
||||
*
|
||||
*/
|
||||
uint8_t worksheet_set_footer(lxw_worksheet *worksheet, char *string);
|
||||
lxw_error worksheet_set_footer(lxw_worksheet *worksheet, char *string);
|
||||
|
||||
/**
|
||||
* @brief Set the printed page header caption with additional options.
|
||||
@ -2010,8 +2013,8 @@ uint8_t worksheet_set_footer(lxw_worksheet *worksheet, char *string);
|
||||
* @endcode
|
||||
*
|
||||
*/
|
||||
uint8_t worksheet_set_header_opt(lxw_worksheet *worksheet, char *string,
|
||||
lxw_header_footer_options *options);
|
||||
lxw_error worksheet_set_header_opt(lxw_worksheet *worksheet, char *string,
|
||||
lxw_header_footer_options *options);
|
||||
|
||||
/**
|
||||
* @brief Set the printed page footer caption with additional options.
|
||||
@ -2025,8 +2028,8 @@ uint8_t worksheet_set_header_opt(lxw_worksheet *worksheet, char *string,
|
||||
* The syntax of this function is the same as worksheet_set_header_opt().
|
||||
*
|
||||
*/
|
||||
uint8_t worksheet_set_footer_opt(lxw_worksheet *worksheet, char *string,
|
||||
lxw_header_footer_options *options);
|
||||
lxw_error worksheet_set_footer_opt(lxw_worksheet *worksheet, char *string,
|
||||
lxw_header_footer_options *options);
|
||||
|
||||
/**
|
||||
* @brief Set the horizontal page breaks on a worksheet.
|
||||
@ -2249,8 +2252,8 @@ void worksheet_print_row_col_headers(lxw_worksheet *worksheet);
|
||||
*
|
||||
* @return 0 for success, non-zero on error.
|
||||
*/
|
||||
uint8_t worksheet_repeat_rows(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_row_t last_row);
|
||||
lxw_error worksheet_repeat_rows(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_row_t last_row);
|
||||
|
||||
/**
|
||||
* @brief Set the number of columns to repeat at the top of each printed page.
|
||||
@ -2272,8 +2275,8 @@ uint8_t worksheet_repeat_rows(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
*
|
||||
* @return 0 for success, non-zero on error.
|
||||
*/
|
||||
uint8_t worksheet_repeat_columns(lxw_worksheet *worksheet,
|
||||
lxw_col_t first_col, lxw_col_t last_col);
|
||||
lxw_error worksheet_repeat_columns(lxw_worksheet *worksheet,
|
||||
lxw_col_t first_col, lxw_col_t last_col);
|
||||
|
||||
/**
|
||||
* @brief Set the print area for a worksheet.
|
||||
@ -2302,9 +2305,9 @@ uint8_t worksheet_repeat_columns(lxw_worksheet *worksheet,
|
||||
*
|
||||
* @return 0 for success, non-zero on error.
|
||||
*/
|
||||
uint8_t worksheet_print_area(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col);
|
||||
lxw_error worksheet_print_area(lxw_worksheet *worksheet, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col);
|
||||
/**
|
||||
* @brief Fit the printed area to a specific number of pages both vertically
|
||||
* and horizontally.
|
||||
|
@ -23,11 +23,14 @@ char *error_strings[LXW_MAX_ERRNO + 1] = {
|
||||
"Zlib error when adding sub file to xlsx file.",
|
||||
"Zlib error when closing xlsx file.",
|
||||
"NULL function parameter ignored.",
|
||||
"Function parameter validation error.",
|
||||
"String exceeds Excel's limit of 32,767 characters.",
|
||||
"Parameter exceeds Excel's limit of 128 characters.",
|
||||
"Parameter exceeds Excel's limit of 255 characters.",
|
||||
"Error finding internal string index.",
|
||||
"Worksheet row or column index out of range.",
|
||||
"Maximum number of worksheet URLs (65530) exceeded.",
|
||||
"Couldn't read image dimensions or DPI.",
|
||||
"Unknown error number."
|
||||
};
|
||||
|
||||
|
@ -472,7 +472,7 @@ _compare_defined_names(lxw_defined_name *a, lxw_defined_name *b)
|
||||
* order for consistency with Excel. The names need to be normalized before
|
||||
* sorting.
|
||||
*/
|
||||
STATIC uint8_t
|
||||
STATIC lxw_error
|
||||
_store_defined_name(lxw_workbook *self, const char *name,
|
||||
const char *app_name, const char *formula, int16_t index,
|
||||
uint8_t hidden)
|
||||
@ -486,11 +486,11 @@ _store_defined_name(lxw_workbook *self, const char *name,
|
||||
|
||||
/* Do some checks on the input data */
|
||||
if (!name || !formula)
|
||||
return 1;
|
||||
return LXW_ERROR_NULL_PARAMETER_IGNORED;
|
||||
|
||||
if (strlen(name) > LXW_DEFINED_NAME_LENGTH ||
|
||||
strlen(formula) > LXW_DEFINED_NAME_LENGTH) {
|
||||
return 1;
|
||||
return LXW_ERROR_128_STRING_LENGTH_EXCEEDED;
|
||||
}
|
||||
|
||||
/* Allocate a new defined_name to be added to the linked list of names. */
|
||||
@ -575,7 +575,7 @@ _store_defined_name(lxw_workbook *self, const char *name,
|
||||
_compare_defined_names(defined_name, list_defined_name) < 1) {
|
||||
/* List is empty or defined name goes to the head. */
|
||||
TAILQ_INSERT_HEAD(self->defined_names, defined_name, list_pointers);
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
TAILQ_FOREACH(list_defined_name, self->defined_names, list_pointers) {
|
||||
@ -589,18 +589,18 @@ _store_defined_name(lxw_workbook *self, const char *name,
|
||||
if (res < 0) {
|
||||
TAILQ_INSERT_BEFORE(list_defined_name, defined_name,
|
||||
list_pointers);
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
/* If the entry wasn't less than any of the entries in the list we add it
|
||||
* to the end. */
|
||||
TAILQ_INSERT_TAIL(self->defined_names, defined_name, list_pointers);
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
|
||||
mem_error:
|
||||
free(defined_name);
|
||||
return 1;
|
||||
return LXW_ERROR_MEMORY_MALLOC_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1486,7 +1486,7 @@ workbook_add_format(lxw_workbook *self)
|
||||
/*
|
||||
* Call finalization code and close file.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_close(lxw_workbook *self)
|
||||
{
|
||||
lxw_worksheet *worksheet = NULL;
|
||||
@ -1574,7 +1574,7 @@ mem_error:
|
||||
* Create a defined name in Excel. We handle global/workbook level names and
|
||||
* local/worksheet names.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_define_name(lxw_workbook *self, const char *name,
|
||||
const char *formula)
|
||||
{
|
||||
@ -1584,7 +1584,7 @@ workbook_define_name(lxw_workbook *self, const char *name,
|
||||
/*
|
||||
* Set the document properties such as Title, Author etc.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_set_properties(lxw_workbook *self, lxw_doc_properties *user_props)
|
||||
{
|
||||
lxw_doc_properties *doc_props;
|
||||
@ -1648,17 +1648,17 @@ workbook_set_properties(lxw_workbook *self, lxw_doc_properties *user_props)
|
||||
|
||||
self->properties = doc_props;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
|
||||
mem_error:
|
||||
_free_doc_properties(doc_props);
|
||||
return -1;
|
||||
return LXW_ERROR_MEMORY_MALLOC_FAILED;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a string custom document property.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_set_custom_property_string(lxw_workbook *self, char *name,
|
||||
char *value)
|
||||
{
|
||||
@ -1699,13 +1699,13 @@ workbook_set_custom_property_string(lxw_workbook *self, char *name,
|
||||
STAILQ_INSERT_TAIL(self->custom_properties, custom_property,
|
||||
list_pointers);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a double number custom document property.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_set_custom_property_number(lxw_workbook *self, char *name,
|
||||
double value)
|
||||
{
|
||||
@ -1734,13 +1734,13 @@ workbook_set_custom_property_number(lxw_workbook *self, char *name,
|
||||
STAILQ_INSERT_TAIL(self->custom_properties, custom_property,
|
||||
list_pointers);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a integer number custom document property.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_set_custom_property_integer(lxw_workbook *self, char *name,
|
||||
int32_t value)
|
||||
{
|
||||
@ -1769,13 +1769,13 @@ workbook_set_custom_property_integer(lxw_workbook *self, char *name,
|
||||
STAILQ_INSERT_TAIL(self->custom_properties, custom_property,
|
||||
list_pointers);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a boolean custom document property.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_set_custom_property_boolean(lxw_workbook *self, char *name,
|
||||
uint8_t value)
|
||||
{
|
||||
@ -1804,13 +1804,13 @@ workbook_set_custom_property_boolean(lxw_workbook *self, char *name,
|
||||
STAILQ_INSERT_TAIL(self->custom_properties, custom_property,
|
||||
list_pointers);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a datetime custom document property.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
workbook_set_custom_property_datetime(lxw_workbook *self, char *name,
|
||||
lxw_datetime *datetime)
|
||||
{
|
||||
@ -1846,7 +1846,7 @@ workbook_set_custom_property_datetime(lxw_workbook *self, char *name,
|
||||
STAILQ_INSERT_TAIL(self->custom_properties, custom_property,
|
||||
list_pointers);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
lxw_worksheet *
|
||||
|
220
src/worksheet.c
220
src/worksheet.c
@ -733,7 +733,7 @@ _next_power_of_two(uint16_t col)
|
||||
* The ignore_row/ignore_col flags are used to indicate that we wish to
|
||||
* perform the dimension check without storing the value.
|
||||
*/
|
||||
STATIC uint8_t
|
||||
STATIC lxw_error
|
||||
_check_dimensions(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, int8_t ignore_row, int8_t ignore_col)
|
||||
@ -765,7 +765,7 @@ _check_dimensions(lxw_worksheet *self,
|
||||
self->dim_colmax = col_num;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -2048,7 +2048,7 @@ mem_error:
|
||||
/*
|
||||
* Extract width and height information from a PNG file.
|
||||
*/
|
||||
STATIC int
|
||||
STATIC lxw_error
|
||||
_process_png(lxw_image_options *image_options)
|
||||
{
|
||||
uint32_t length;
|
||||
@ -2131,7 +2131,7 @@ _process_png(lxw_image_options *image_options)
|
||||
LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
|
||||
"no size data found in file: %s.",
|
||||
image_options->filename);
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
|
||||
/* Set the image metadata. */
|
||||
@ -2142,13 +2142,13 @@ _process_png(lxw_image_options *image_options)
|
||||
image_options->y_dpi = y_dpi ? x_dpi : 96;
|
||||
image_options->extension = lxw_strdup("png");
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract width and height information from a JPEG file.
|
||||
*/
|
||||
STATIC int
|
||||
STATIC lxw_error
|
||||
_process_jpeg(lxw_image_options *image_options)
|
||||
{
|
||||
uint16_t length;
|
||||
@ -2242,7 +2242,7 @@ _process_jpeg(lxw_image_options *image_options)
|
||||
LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
|
||||
"no size data found in file: %s.",
|
||||
image_options->filename);
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
|
||||
/* Set the image metadata. */
|
||||
@ -2253,13 +2253,13 @@ _process_jpeg(lxw_image_options *image_options)
|
||||
image_options->y_dpi = y_dpi ? x_dpi : 96;
|
||||
image_options->extension = lxw_strdup("jpeg");
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract width and height information from a BMP file.
|
||||
*/
|
||||
STATIC int
|
||||
STATIC lxw_error
|
||||
_process_bmp(lxw_image_options *image_options)
|
||||
{
|
||||
uint32_t width = 0;
|
||||
@ -2283,7 +2283,7 @@ _process_bmp(lxw_image_options *image_options)
|
||||
LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
|
||||
"no size data found in file: %s.",
|
||||
image_options->filename);
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
|
||||
/* Set the image metadata. */
|
||||
@ -2294,14 +2294,14 @@ _process_bmp(lxw_image_options *image_options)
|
||||
image_options->y_dpi = y_dpi;
|
||||
image_options->extension = lxw_strdup("bmp");
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extract information from the image file such as dimension, type, filename,
|
||||
* and extension.
|
||||
*/
|
||||
STATIC int
|
||||
STATIC lxw_error
|
||||
_get_image_properties(lxw_image_options *image_options)
|
||||
{
|
||||
unsigned char signature[4];
|
||||
@ -2311,29 +2311,29 @@ _get_image_properties(lxw_image_options *image_options)
|
||||
LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
|
||||
"couldn't read file type for file: %s.",
|
||||
image_options->filename);
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
|
||||
if (memcmp(&signature[1], "PNG", 3) == 0) {
|
||||
if (_process_png(image_options) != LXW_NO_ERROR)
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
else if (signature[0] == 0xFF && signature[1] == 0xD8) {
|
||||
if (_process_jpeg(image_options) != LXW_NO_ERROR)
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
else if (memcmp(signature, "BM", 2) == 0) {
|
||||
if (_process_bmp(image_options) != LXW_NO_ERROR)
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
else {
|
||||
LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
|
||||
"unsupported image format for file: %s.",
|
||||
image_options->filename);
|
||||
return -1;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*****************************************************************************
|
||||
@ -3368,16 +3368,15 @@ lxw_worksheet_assemble_xml_file(lxw_worksheet *self)
|
||||
/*
|
||||
* Write a number to a cell in Excel.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_number(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, double value, lxw_format *format)
|
||||
{
|
||||
lxw_cell *cell;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
err = _check_dimensions(self, row_num, col_num, LXW_FALSE, LXW_FALSE);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -3385,13 +3384,13 @@ worksheet_write_number(lxw_worksheet *self,
|
||||
|
||||
_insert_cell(self, row_num, col_num, cell);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a string to an Excel file.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_string(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, const char *string,
|
||||
@ -3401,7 +3400,7 @@ worksheet_write_string(lxw_worksheet *self,
|
||||
int32_t string_id;
|
||||
char *string_copy;
|
||||
struct sst_element *sst_element;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
if (!string || !*string) {
|
||||
/* Treat a NULL or empty string with formatting as a blank cell. */
|
||||
@ -3445,13 +3444,13 @@ worksheet_write_string(lxw_worksheet *self,
|
||||
|
||||
_insert_cell(self, row_num, col_num, cell);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a formula with a numerical result to a cell in Excel.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_formula_num(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num,
|
||||
@ -3460,7 +3459,7 @@ worksheet_write_formula_num(lxw_worksheet *self,
|
||||
{
|
||||
lxw_cell *cell;
|
||||
char *formula_copy;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
if (!formula)
|
||||
return LXW_ERROR_NULL_PARAMETER_IGNORED;
|
||||
@ -3480,13 +3479,13 @@ worksheet_write_formula_num(lxw_worksheet *self,
|
||||
|
||||
_insert_cell(self, row_num, col_num, cell);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a formula with a default result to a cell in Excel .
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_formula(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, const char *formula,
|
||||
@ -3499,7 +3498,7 @@ worksheet_write_formula(lxw_worksheet *self,
|
||||
/*
|
||||
* Write a formula with a numerical result to a cell in Excel.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_array_formula_num(lxw_worksheet *self,
|
||||
lxw_row_t first_row,
|
||||
lxw_col_t first_col,
|
||||
@ -3513,7 +3512,7 @@ worksheet_write_array_formula_num(lxw_worksheet *self,
|
||||
lxw_col_t tmp_col;
|
||||
char *formula_copy;
|
||||
char *range;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
/* Swap last row/col with first row/col as necessary */
|
||||
if (first_row > last_row) {
|
||||
@ -3577,13 +3576,13 @@ worksheet_write_array_formula_num(lxw_worksheet *self,
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write an array formula with a default result to a cell in Excel .
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_array_formula(lxw_worksheet *self,
|
||||
lxw_row_t first_row,
|
||||
lxw_col_t first_col,
|
||||
@ -3599,20 +3598,19 @@ worksheet_write_array_formula(lxw_worksheet *self,
|
||||
/*
|
||||
* Write a blank cell with a format to a cell in Excel.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_blank(lxw_worksheet *self,
|
||||
lxw_row_t row_num, lxw_col_t col_num,
|
||||
lxw_format *format)
|
||||
{
|
||||
lxw_cell *cell;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
/* Blank cells without formatting are ignored by Excel. */
|
||||
if (!format)
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
|
||||
err = _check_dimensions(self, row_num, col_num, LXW_FALSE, LXW_FALSE);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -3620,19 +3618,19 @@ worksheet_write_blank(lxw_worksheet *self,
|
||||
|
||||
_insert_cell(self, row_num, col_num, cell);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a boolean cell with a format to a cell in Excel.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_boolean(lxw_worksheet *self,
|
||||
lxw_row_t row_num, lxw_col_t col_num,
|
||||
int value, lxw_format *format)
|
||||
{
|
||||
lxw_cell *cell;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
err = _check_dimensions(self, row_num, col_num, LXW_FALSE, LXW_FALSE);
|
||||
|
||||
@ -3643,13 +3641,13 @@ worksheet_write_boolean(lxw_worksheet *self,
|
||||
|
||||
_insert_cell(self, row_num, col_num, cell);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a date and or time to a cell in Excel.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_datetime(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, lxw_datetime *datetime,
|
||||
@ -3657,10 +3655,9 @@ worksheet_write_datetime(lxw_worksheet *self,
|
||||
{
|
||||
lxw_cell *cell;
|
||||
double excel_date;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
err = _check_dimensions(self, row_num, col_num, LXW_FALSE, LXW_FALSE);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -3670,13 +3667,13 @@ worksheet_write_datetime(lxw_worksheet *self,
|
||||
|
||||
_insert_cell(self, row_num, col_num, cell);
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Write a hyperlink/url to an Excel file.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_url_opt(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, const char *url,
|
||||
@ -3690,7 +3687,7 @@ worksheet_write_url_opt(lxw_worksheet *self,
|
||||
char *url_string = NULL;
|
||||
char *tooltip_copy = NULL;
|
||||
char *found_string;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
size_t string_size;
|
||||
size_t i;
|
||||
enum cell_types link_type = HYPERLINK_URL;
|
||||
@ -3875,7 +3872,7 @@ worksheet_write_url_opt(lxw_worksheet *self,
|
||||
|
||||
free(string_copy);
|
||||
self->hlink_count++;
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
|
||||
mem_error:
|
||||
free(string_copy);
|
||||
@ -3889,7 +3886,7 @@ mem_error:
|
||||
/*
|
||||
* Write a hyperlink/url to an Excel file.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_write_url(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
lxw_col_t col_num, const char *url, lxw_format *format)
|
||||
@ -3901,7 +3898,7 @@ worksheet_write_url(lxw_worksheet *self,
|
||||
/*
|
||||
* Set the properties of a single column or a range of columns with options.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_set_column_opt(lxw_worksheet *self,
|
||||
lxw_col_t firstcol,
|
||||
lxw_col_t lastcol,
|
||||
@ -3916,7 +3913,7 @@ worksheet_set_column_opt(lxw_worksheet *self,
|
||||
uint8_t level = 0;
|
||||
uint8_t collapsed = LXW_FALSE;
|
||||
lxw_col_t col;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
if (user_options) {
|
||||
hidden = user_options->hidden;
|
||||
@ -4008,13 +4005,13 @@ worksheet_set_column_opt(lxw_worksheet *self,
|
||||
/* Store the column change to allow optimizations. */
|
||||
self->col_size_changed = LXW_TRUE;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the properties of a single column or a range of columns.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_set_column(lxw_worksheet *self,
|
||||
lxw_col_t firstcol,
|
||||
lxw_col_t lastcol, double width, lxw_format *format)
|
||||
@ -4026,7 +4023,7 @@ worksheet_set_column(lxw_worksheet *self,
|
||||
/*
|
||||
* Set the properties of a row with options.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_set_row_opt(lxw_worksheet *self,
|
||||
lxw_row_t row_num,
|
||||
double height,
|
||||
@ -4038,7 +4035,7 @@ worksheet_set_row_opt(lxw_worksheet *self,
|
||||
uint8_t level = 0;
|
||||
uint8_t collapsed = LXW_FALSE;
|
||||
lxw_row *row;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
if (user_options) {
|
||||
hidden = user_options->hidden;
|
||||
@ -4053,7 +4050,6 @@ worksheet_set_row_opt(lxw_worksheet *self,
|
||||
min_col = 0;
|
||||
|
||||
err = _check_dimensions(self, row_num, min_col, LXW_FALSE, LXW_FALSE);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -4075,13 +4071,13 @@ worksheet_set_row_opt(lxw_worksheet *self,
|
||||
if (height != self->default_row_height)
|
||||
row->height_changed = LXW_TRUE;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the properties of a row.
|
||||
*/
|
||||
int8_t
|
||||
lxw_error
|
||||
worksheet_set_row(lxw_worksheet *self,
|
||||
lxw_row_t row_num, double height, lxw_format *format)
|
||||
{
|
||||
@ -4092,7 +4088,7 @@ worksheet_set_row(lxw_worksheet *self,
|
||||
* Merge a range of cells. The first cell should contain the data and the others
|
||||
* should be blank. All cells should contain the same format.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_merge_range(lxw_worksheet *self, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col, const char *string,
|
||||
@ -4101,11 +4097,11 @@ worksheet_merge_range(lxw_worksheet *self, lxw_row_t first_row,
|
||||
lxw_merged_range *merged_range;
|
||||
lxw_row_t tmp_row;
|
||||
lxw_col_t tmp_col;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
/* Excel doesn't allow a single cell to be merged */
|
||||
if (first_row == last_row && first_col == last_col)
|
||||
return 1;
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
|
||||
/* Swap last row/col with first row/col as necessary */
|
||||
if (first_row > last_row) {
|
||||
@ -4121,7 +4117,6 @@ worksheet_merge_range(lxw_worksheet *self, lxw_row_t first_row,
|
||||
|
||||
/* Check that column number is valid and store the max value */
|
||||
err = _check_dimensions(self, last_row, last_col, LXW_FALSE, LXW_FALSE);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -4150,24 +4145,24 @@ worksheet_merge_range(lxw_worksheet *self, lxw_row_t first_row,
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the autofilter area in the worksheet.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_autofilter(lxw_worksheet *self, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col)
|
||||
{
|
||||
lxw_row_t tmp_row;
|
||||
lxw_col_t tmp_col;
|
||||
int8_t err;
|
||||
lxw_error err;
|
||||
|
||||
/* Excel doesn't allow a single cell to be merged */
|
||||
if (first_row == last_row && first_col == last_col)
|
||||
return 1;
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
|
||||
/* Swap last row/col with first row/col as necessary */
|
||||
if (first_row > last_row) {
|
||||
@ -4183,7 +4178,6 @@ worksheet_autofilter(lxw_worksheet *self, lxw_row_t first_row,
|
||||
|
||||
/* Check that column number is valid and store the max value */
|
||||
err = _check_dimensions(self, last_row, last_col, LXW_FALSE, LXW_FALSE);
|
||||
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
@ -4193,7 +4187,7 @@ worksheet_autofilter(lxw_worksheet *self, lxw_row_t first_row,
|
||||
self->autofilter.last_row = last_row;
|
||||
self->autofilter.last_col = last_col;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -4445,7 +4439,7 @@ worksheet_set_margins(lxw_worksheet *self, double left, double right,
|
||||
/*
|
||||
* Set the page header caption and options.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_set_header_opt(lxw_worksheet *self, char *string,
|
||||
lxw_header_footer_options *options)
|
||||
{
|
||||
@ -4455,21 +4449,21 @@ worksheet_set_header_opt(lxw_worksheet *self, char *string,
|
||||
}
|
||||
|
||||
if (!string)
|
||||
return 1;
|
||||
return LXW_ERROR_NULL_PARAMETER_IGNORED;
|
||||
|
||||
if (strlen(string) >= LXW_HEADER_FOOTER_MAX)
|
||||
return 1;
|
||||
return LXW_ERROR_255_STRING_LENGTH_EXCEEDED;
|
||||
|
||||
strcpy(self->header, string);
|
||||
self->header_footer_changed = 1;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page footer caption and options.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_set_footer_opt(lxw_worksheet *self, char *string,
|
||||
lxw_header_footer_options *options)
|
||||
{
|
||||
@ -4479,21 +4473,21 @@ worksheet_set_footer_opt(lxw_worksheet *self, char *string,
|
||||
}
|
||||
|
||||
if (!string)
|
||||
return 1;
|
||||
return LXW_ERROR_NULL_PARAMETER_IGNORED;
|
||||
|
||||
if (strlen(string) >= LXW_HEADER_FOOTER_MAX)
|
||||
return 1;
|
||||
return LXW_ERROR_255_STRING_LENGTH_EXCEEDED;
|
||||
|
||||
strcpy(self->footer, string);
|
||||
self->header_footer_changed = 1;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the page header caption.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_set_header(lxw_worksheet *self, char *string)
|
||||
{
|
||||
return worksheet_set_header_opt(self, string, NULL);
|
||||
@ -4502,7 +4496,7 @@ worksheet_set_header(lxw_worksheet *self, char *string)
|
||||
/*
|
||||
* Set the page footer caption.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_set_footer(lxw_worksheet *self, char *string)
|
||||
{
|
||||
return worksheet_set_footer_opt(self, string, NULL);
|
||||
@ -4562,11 +4556,12 @@ worksheet_print_row_col_headers(lxw_worksheet *self)
|
||||
/*
|
||||
* Set the rows to repeat at the top of each printed page.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_repeat_rows(lxw_worksheet *self, lxw_row_t first_row,
|
||||
lxw_row_t last_row)
|
||||
{
|
||||
lxw_row_t tmp_row;
|
||||
lxw_error err;
|
||||
|
||||
if (first_row > last_row) {
|
||||
tmp_row = last_row;
|
||||
@ -4574,24 +4569,26 @@ worksheet_repeat_rows(lxw_worksheet *self, lxw_row_t first_row,
|
||||
first_row = tmp_row;
|
||||
}
|
||||
|
||||
if (_check_dimensions(self, last_row, 0, LXW_IGNORE, LXW_IGNORE))
|
||||
return 1;
|
||||
err = _check_dimensions(self, last_row, 0, LXW_IGNORE, LXW_IGNORE);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
self->repeat_rows.in_use = LXW_TRUE;
|
||||
self->repeat_rows.first_row = first_row;
|
||||
self->repeat_rows.last_row = last_row;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the columns to repeat at the left hand side of each printed page.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_repeat_columns(lxw_worksheet *self, lxw_col_t first_col,
|
||||
lxw_col_t last_col)
|
||||
{
|
||||
lxw_col_t tmp_col;
|
||||
lxw_error err;
|
||||
|
||||
if (first_col > last_col) {
|
||||
tmp_col = last_col;
|
||||
@ -4599,26 +4596,28 @@ worksheet_repeat_columns(lxw_worksheet *self, lxw_col_t first_col,
|
||||
first_col = tmp_col;
|
||||
}
|
||||
|
||||
if (_check_dimensions(self, last_col, 0, LXW_IGNORE, LXW_IGNORE))
|
||||
return 1;
|
||||
err = _check_dimensions(self, last_col, 0, LXW_IGNORE, LXW_IGNORE);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
self->repeat_cols.in_use = LXW_TRUE;
|
||||
self->repeat_cols.first_col = first_col;
|
||||
self->repeat_cols.last_col = last_col;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the print area in the current worksheet.
|
||||
*/
|
||||
uint8_t
|
||||
lxw_error
|
||||
worksheet_print_area(lxw_worksheet *self, lxw_row_t first_row,
|
||||
lxw_col_t first_col, lxw_row_t last_row,
|
||||
lxw_col_t last_col)
|
||||
{
|
||||
lxw_row_t tmp_row;
|
||||
lxw_col_t tmp_col;
|
||||
lxw_error err;
|
||||
|
||||
if (first_row > last_row) {
|
||||
tmp_row = last_row;
|
||||
@ -4632,13 +4631,14 @@ worksheet_print_area(lxw_worksheet *self, lxw_row_t first_row,
|
||||
first_col = tmp_col;
|
||||
}
|
||||
|
||||
if (_check_dimensions(self, last_row, last_col, LXW_IGNORE, LXW_IGNORE))
|
||||
return 1;
|
||||
err = _check_dimensions(self, last_row, last_col, LXW_IGNORE, LXW_IGNORE);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
/* Ignore max area since it is the same as no print area in Excel. */
|
||||
if (first_row == 0 && first_col == 0 && last_row == LXW_ROW_MAX - 1
|
||||
&& last_col == LXW_COL_MAX - 1) {
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
self->print_area.in_use = LXW_TRUE;
|
||||
@ -4647,7 +4647,7 @@ worksheet_print_area(lxw_worksheet *self, lxw_row_t first_row,
|
||||
self->print_area.first_col = first_col;
|
||||
self->print_area.last_col = last_col;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/* Store the vertical and horizontal number of pages that will define the
|
||||
@ -4798,7 +4798,7 @@ worksheet_set_default_row(lxw_worksheet *self, double height,
|
||||
/*
|
||||
* Insert an image into the worksheet.
|
||||
*/
|
||||
int
|
||||
lxw_error
|
||||
worksheet_insert_image_opt(lxw_worksheet *self,
|
||||
lxw_row_t row_num, lxw_col_t col_num,
|
||||
const char *filename,
|
||||
@ -4811,7 +4811,7 @@ worksheet_insert_image_opt(lxw_worksheet *self,
|
||||
if (!filename) {
|
||||
LXW_WARN("worksheet_insert_image()/_opt(): "
|
||||
"filename must be specified.");
|
||||
return -1;
|
||||
return LXW_ERROR_NULL_PARAMETER_IGNORED;
|
||||
}
|
||||
|
||||
/* Check that the image file exists and can be opened. */
|
||||
@ -4820,7 +4820,7 @@ worksheet_insert_image_opt(lxw_worksheet *self,
|
||||
LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
|
||||
"file doesn't exist or can't be opened: %s.",
|
||||
filename);
|
||||
return -1;
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
|
||||
/* Get the filename from the full path to add to the Drawing object. */
|
||||
@ -4828,12 +4828,12 @@ worksheet_insert_image_opt(lxw_worksheet *self,
|
||||
if (!short_name) {
|
||||
LXW_WARN_FORMAT1("worksheet_insert_image()/_opt(): "
|
||||
"couldn't get basename for file: %s.", filename);
|
||||
return -1;
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
|
||||
/* Create a new object to hold the image options. */
|
||||
options = calloc(1, sizeof(lxw_image_options));
|
||||
RETURN_ON_MEM_ERROR(options, -1);
|
||||
RETURN_ON_MEM_ERROR(options, LXW_ERROR_MEMORY_MALLOC_FAILED);
|
||||
|
||||
if (user_options) {
|
||||
memcpy(options, user_options, sizeof(lxw_image_options));
|
||||
@ -4854,18 +4854,20 @@ worksheet_insert_image_opt(lxw_worksheet *self,
|
||||
if (!options->y_scale)
|
||||
options->y_scale = 1;
|
||||
|
||||
if (_get_image_properties(options) == LXW_NO_ERROR)
|
||||
if (_get_image_properties(options) == LXW_NO_ERROR) {
|
||||
STAILQ_INSERT_TAIL(self->image_data, options, list_pointers);
|
||||
else
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
else {
|
||||
free(options);
|
||||
|
||||
return 0;
|
||||
return LXW_ERROR_IMAGE_DIMENSIONS;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert an image into the worksheet.
|
||||
*/
|
||||
int
|
||||
lxw_error
|
||||
worksheet_insert_image(lxw_worksheet *self,
|
||||
lxw_row_t row_num, lxw_col_t col_num,
|
||||
const char *filename)
|
||||
@ -4876,7 +4878,7 @@ worksheet_insert_image(lxw_worksheet *self,
|
||||
/*
|
||||
* Insert an chart into the worksheet.
|
||||
*/
|
||||
int
|
||||
lxw_error
|
||||
worksheet_insert_chart_opt(lxw_worksheet *self,
|
||||
lxw_row_t row_num, lxw_col_t col_num,
|
||||
lxw_chart *chart, lxw_image_options *user_options)
|
||||
@ -4886,7 +4888,7 @@ worksheet_insert_chart_opt(lxw_worksheet *self,
|
||||
|
||||
if (!chart) {
|
||||
LXW_WARN("worksheet_insert_chart()/_opt(): chart must be non-NULL.");
|
||||
return -1;
|
||||
return LXW_ERROR_NULL_PARAMETER_IGNORED;
|
||||
}
|
||||
|
||||
/* Check that the chart isn't being used more than once. */
|
||||
@ -4894,7 +4896,7 @@ worksheet_insert_chart_opt(lxw_worksheet *self,
|
||||
LXW_WARN("worksheet_insert_chart()/_opt(): the same chart object "
|
||||
"cannot be inserted in a worksheet more than once.");
|
||||
|
||||
return -1;
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
|
||||
/* Check that the chart has a data series. */
|
||||
@ -4902,7 +4904,7 @@ worksheet_insert_chart_opt(lxw_worksheet *self,
|
||||
LXW_WARN
|
||||
("worksheet_insert_chart()/_opt(): chart must have a series.");
|
||||
|
||||
return -1;
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
|
||||
/* Check that the chart has a 'values' series. */
|
||||
@ -4911,13 +4913,13 @@ worksheet_insert_chart_opt(lxw_worksheet *self,
|
||||
LXW_WARN("worksheet_insert_chart()/_opt(): chart must have a "
|
||||
"'values' series.");
|
||||
|
||||
return -1;
|
||||
return LXW_ERROR_PARAMETER_VALIDATION;
|
||||
}
|
||||
}
|
||||
|
||||
/* Create a new object to hold the chart image options. */
|
||||
options = calloc(1, sizeof(lxw_image_options));
|
||||
RETURN_ON_MEM_ERROR(options, -1);
|
||||
RETURN_ON_MEM_ERROR(options, LXW_ERROR_MEMORY_MALLOC_FAILED);
|
||||
|
||||
if (user_options)
|
||||
memcpy(options, user_options, sizeof(lxw_image_options));
|
||||
@ -4943,13 +4945,13 @@ worksheet_insert_chart_opt(lxw_worksheet *self,
|
||||
|
||||
chart->in_use = LXW_TRUE;
|
||||
|
||||
return 0;
|
||||
return LXW_NO_ERROR;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert an image into the worksheet.
|
||||
*/
|
||||
int
|
||||
lxw_error
|
||||
worksheet_insert_chart(lxw_worksheet *self,
|
||||
lxw_row_t row_num, lxw_col_t col_num, lxw_chart *chart)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user