libxlsxwriter/include/xlsxwriter/format.h in fast_excel-0.4.1 vs libxlsxwriter/include/xlsxwriter/format.h in fast_excel-0.5.0
- old
+ new
@@ -1,9 +1,9 @@
/*
* libxlsxwriter
*
- * Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
+ * Copyright 2014-2022, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
*/
/**
* @page format_page The Format object
*
@@ -70,18 +70,18 @@
* @brief The type for RGB colors in libxlsxwriter.
*
* The type for RGB colors in libxlsxwriter. The valid range is `0x000000`
* (black) to `0xFFFFFF` (white). See @ref working_with_colors.
*/
-typedef int32_t lxw_color_t;
+typedef uint32_t lxw_color_t;
#define LXW_FORMAT_FIELD_LEN 128
#define LXW_DEFAULT_FONT_NAME "Calibri"
#define LXW_DEFAULT_FONT_FAMILY 2
#define LXW_DEFAULT_FONT_THEME 1
#define LXW_PROPERTY_UNSET -1
-#define LXW_COLOR_UNSET -1
+#define LXW_COLOR_UNSET 0x000000
#define LXW_COLOR_MASK 0xFFFFFF
#define LXW_MIN_FONT_SIZE 1.0
#define LXW_MAX_FONT_SIZE 409.0
#define LXW_FORMAT_FIELD_COPY(dst, src) \
@@ -90,12 +90,14 @@
dst[LXW_FORMAT_FIELD_LEN - 1] = '\0'; \
} while (0)
/** Format underline values for format_set_underline(). */
enum lxw_format_underlines {
+ LXW_UNDERLINE_NONE = 0,
+
/** Single underline */
- LXW_UNDERLINE_SINGLE = 1,
+ LXW_UNDERLINE_SINGLE,
/** Double underline */
LXW_UNDERLINE_DOUBLE,
/** Single accounting underline */
@@ -155,13 +157,23 @@
/** Distributed vertical alignment */
LXW_ALIGN_VERTICAL_DISTRIBUTED
};
+/**
+ * Diagonal border types.
+ *
+ */
enum lxw_format_diagonal_types {
+
+ /** Cell diagonal border from bottom left to top right. */
LXW_DIAGONAL_BORDER_UP = 1,
+
+ /** Cell diagonal border from top left to bottom right. */
LXW_DIAGONAL_BORDER_DOWN,
+
+ /** Cell diagonal border in both directions. */
LXW_DIAGONAL_BORDER_UP_DOWN
};
/** Predefined values for common colors. */
enum lxw_defined_colors {
@@ -346,14 +358,17 @@
typedef struct lxw_format {
FILE *file;
lxw_hash_table *xf_format_indices;
+ lxw_hash_table *dxf_format_indices;
uint16_t *num_xf_formats;
+ uint16_t *num_dxf_formats;
int32_t xf_index;
int32_t dxf_index;
+ int32_t xf_id;
char num_format[LXW_FORMAT_FIELD_LEN];
char font_name[LXW_FORMAT_FIELD_LEN];
char font_scheme[LXW_FORMAT_FIELD_LEN];
uint16_t num_format_index;
@@ -385,10 +400,12 @@
uint8_t text_justlast;
int16_t rotation;
lxw_color_t fg_color;
lxw_color_t bg_color;
+ lxw_color_t dxf_fg_color;
+ lxw_color_t dxf_bg_color;
uint8_t pattern;
uint8_t has_fill;
uint8_t has_dxf_fill;
int32_t fill_index;
int32_t fill_count;
@@ -416,10 +433,12 @@
uint8_t reading_order;
uint8_t just_distrib;
uint8_t color_indexed;
uint8_t font_only;
+ uint8_t quote_prefix;
+
STAILQ_ENTRY (lxw_format) list_pointers;
} lxw_format;
/*
* Struct to represent the font component of a format.
@@ -429,10 +448,11 @@
char font_name[LXW_FORMAT_FIELD_LEN];
double font_size;
uint8_t bold;
uint8_t italic;
uint8_t underline;
+ uint8_t theme;
uint8_t font_strikeout;
uint8_t font_outline;
uint8_t font_shadow;
uint8_t font_script;
uint8_t font_family;
@@ -481,16 +501,15 @@
/* *INDENT-ON* */
lxw_format *lxw_format_new(void);
void lxw_format_free(lxw_format *format);
int32_t lxw_format_get_xf_index(lxw_format *format);
+int32_t lxw_format_get_dxf_index(lxw_format *format);
lxw_font *lxw_format_get_font_key(lxw_format *format);
lxw_border *lxw_format_get_border_key(lxw_format *format);
lxw_fill *lxw_format_get_fill_key(lxw_format *format);
-lxw_color_t lxw_format_check_color(lxw_color_t color);
-
/**
* @brief Set the font used in the cell.
*
* @param format Pointer to a Format instance.
* @param font_name Cell font name.
@@ -670,10 +689,13 @@
* @skipline set_num_format
* @until 1209
*
* @image html format_set_num_format.png
*
+ * To set a number format that matches an Excel format category such as "Date"
+ * or "Currency" see @ref ww_formats_categories.
+ *
* The number system used for dates is described in @ref working_with_dates.
*
* For more information on number formats in Excel refer to the
* [Microsoft documentation on cell formats](http://office.microsoft.com/en-gb/assistance/HP051995001033.aspx).
*/
@@ -747,10 +769,11 @@
* in international versions. The listed date and currency formats may also
* vary depending on system settings.
* - The dollar sign in the above format appears as the defined local currency
* symbol.
* - These formats can also be set via format_set_num_format().
+ * - See also @ref ww_formats_categories.
*/
void format_set_num_format_index(lxw_format *format, uint8_t index);
/**
* @brief Set the cell unlocked state.
@@ -1185,21 +1208,111 @@
*
* See format_set_border_color() for details on the border colors.
*/
void format_set_right_color(lxw_format *format, lxw_color_t color);
-void format_set_diag_type(lxw_format *format, uint8_t value);
+/**
+ * @brief Set the diagonal cell border type.
+ *
+ * @param format Pointer to a Format instance.
+ * @param type The #lxw_format_diagonal_types diagonal border type.
+ *
+ * Set the diagonal cell border type:
+ *
+ * @code
+ * lxw_format *format1 = workbook_add_format(workbook);
+ * format_set_diag_type( format1, LXW_DIAGONAL_BORDER_UP);
+ *
+ * lxw_format *format2 = workbook_add_format(workbook);
+ * format_set_diag_type( format2, LXW_DIAGONAL_BORDER_DOWN);
+ *
+ * lxw_format *format3 = workbook_add_format(workbook);
+ * format_set_diag_type( format3, LXW_DIAGONAL_BORDER_UP_DOWN);
+ *
+ * lxw_format *format4 = workbook_add_format(workbook);
+ * format_set_diag_type( format4, LXW_DIAGONAL_BORDER_UP_DOWN);
+ * format_set_diag_border(format4, LXW_BORDER_HAIR);
+ * format_set_diag_color( format4, LXW_COLOR_RED);
+ *
+ * worksheet_write_string(worksheet, CELL("B3"), "Text", format1);
+ * worksheet_write_string(worksheet, CELL("B6"), "Text", format2);
+ * worksheet_write_string(worksheet, CELL("B9"), "Text", format3);
+ * worksheet_write_string(worksheet, CELL("B12"), "Text", format4);
+ * @endcode
+ *
+ * @image html diagonal_border.png
+ *
+ * The allowable border types are defined in #lxw_format_diagonal_types:
+ *
+ * - #LXW_DIAGONAL_BORDER_UP: Cell diagonal border from bottom left to top
+ * right.
+ *
+ * - #LXW_DIAGONAL_BORDER_DOWN: Cell diagonal border from top left to bottom
+ * right.
+ *
+ * - #LXW_DIAGONAL_BORDER_UP_DOWN: Cell diagonal border from top left to
+ * bottom right. A combination of the 2 previous types.
+ *
+ * If the border style isn't specified with `format_set_diag_border()` then it
+ * will default to #LXW_BORDER_THIN.
+ */
+void format_set_diag_type(lxw_format *format, uint8_t type);
+
+/**
+ * @brief Set the diagonal cell border style.
+ *
+ * @param format Pointer to a Format instance.
+ * @param style The #lxw_format_borders style.
+ *
+ * Set the diagonal border style. This should be a #lxw_format_borders value.
+ * See the example above.
+ *
+ */
+void format_set_diag_border(lxw_format *format, uint8_t style);
+
+/**
+ * @brief Set the diagonal cell border color.
+ *
+ * @param format Pointer to a Format instance.
+ * @param color The cell diagonal border color.
+ *
+ * Set the diagonal border color. The color should be an RGB integer value,
+ * see @ref working_with_colors and the above example.
+ */
void format_set_diag_color(lxw_format *format, lxw_color_t color);
-void format_set_diag_border(lxw_format *format, uint8_t value);
+
+/**
+ * @brief Turn on quote prefix for the format.
+ *
+ * @param format Pointer to a Format instance.
+ *
+ * Set the quote prefix property of a format to ensure a string is treated
+ * as a string after editing. This is the same as prefixing the string with
+ * a single quote in Excel. You don't need to add the quote to the
+ * string but you do need to add the format.
+ *
+ * @code
+ * format = workbook_add_format(workbook);
+ * format_set_quote_prefix(format);
+ *
+ * worksheet_write_string(worksheet, 0, 0, "=Foo", format);
+ * @endcode
+ *
+ */
+void format_set_quote_prefix(lxw_format *format);
+
void format_set_font_outline(lxw_format *format);
void format_set_font_shadow(lxw_format *format);
void format_set_font_family(lxw_format *format, uint8_t value);
void format_set_font_charset(lxw_format *format, uint8_t value);
void format_set_font_scheme(lxw_format *format, const char *font_scheme);
void format_set_font_condense(lxw_format *format);
void format_set_font_extend(lxw_format *format);
void format_set_reading_order(lxw_format *format, uint8_t value);
void format_set_theme(lxw_format *format, uint8_t value);
+void format_set_hyperlink(lxw_format *format);
+void format_set_color_indexed(lxw_format *format, uint8_t value);
+void format_set_font_only(lxw_format *format);
/* Declarations required for unit testing. */
#ifdef TESTING
#endif /* TESTING */