fast_excel 0.2.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.dockerignore +2 -0
- data/.gitignore +7 -0
- data/.travis.yml +32 -9
- data/CHANGELOG.md +36 -1
- data/Dockerfile.test +17 -0
- data/Gemfile +2 -1
- data/Gemfile.lock +33 -24
- data/LICENSE +21 -0
- data/Makefile +13 -0
- data/README.md +177 -40
- data/Rakefile +11 -1
- data/benchmarks/1k_rows.rb +17 -4
- data/benchmarks/20k_rows.rb +4 -0
- data/benchmarks/auto_width.rb +37 -0
- data/benchmarks/init.rb +14 -2
- data/benchmarks/memory.rb +8 -0
- data/benchmarks/profiler.rb +27 -0
- data/benchmarks/write_value.rb +62 -0
- data/examples/example.rb +3 -3
- data/examples/example_auto_width.rb +26 -0
- data/examples/example_filters.rb +36 -0
- data/examples/example_formula.rb +1 -3
- data/examples/example_hyperlink.rb +20 -0
- data/ext/fast_excel/extconf.rb +3 -0
- data/ext/fast_excel/text_width_ext.c +460 -0
- data/fast_excel.gemspec +3 -4
- data/letters.html +114 -0
- data/lib/fast_excel.rb +131 -25
- data/lib/fast_excel/binding.rb +33 -21
- data/lib/fast_excel/binding/chart.rb +20 -1
- data/lib/fast_excel/binding/format.rb +11 -4
- data/lib/fast_excel/binding/workbook.rb +10 -2
- data/lib/fast_excel/binding/worksheet.rb +44 -27
- data/libxlsxwriter/.gitignore +1 -0
- data/libxlsxwriter/.indent.pro +8 -0
- data/libxlsxwriter/.travis.yml +12 -0
- data/libxlsxwriter/CMakeLists.txt +338 -0
- data/libxlsxwriter/CONTRIBUTING.md +1 -1
- data/libxlsxwriter/Changes.txt +162 -0
- data/libxlsxwriter/LICENSE.txt +65 -4
- data/libxlsxwriter/Makefile +33 -11
- data/libxlsxwriter/Readme.md +3 -1
- data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +2 -1
- data/libxlsxwriter/cocoapods/libxlsxwriter.modulemap +2 -2
- data/libxlsxwriter/include/xlsxwriter.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/app.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/chart.h +164 -13
- data/libxlsxwriter/include/xlsxwriter/chartsheet.h +544 -0
- data/libxlsxwriter/include/xlsxwriter/common.h +35 -6
- data/libxlsxwriter/include/xlsxwriter/content_types.h +5 -2
- data/libxlsxwriter/include/xlsxwriter/core.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/custom.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/drawing.h +3 -2
- data/libxlsxwriter/include/xlsxwriter/format.h +8 -8
- data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
- data/libxlsxwriter/include/xlsxwriter/packager.h +18 -8
- data/libxlsxwriter/include/xlsxwriter/relationships.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/shared_strings.h +5 -3
- data/libxlsxwriter/include/xlsxwriter/styles.h +10 -5
- data/libxlsxwriter/include/xlsxwriter/theme.h +2 -2
- data/libxlsxwriter/include/xlsxwriter/utility.h +35 -5
- data/libxlsxwriter/include/xlsxwriter/workbook.h +234 -57
- data/libxlsxwriter/include/xlsxwriter/worksheet.h +780 -91
- data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +4 -2
- data/libxlsxwriter/libxlsxwriter.podspec +4 -2
- data/libxlsxwriter/src/Makefile +31 -6
- data/libxlsxwriter/src/app.c +2 -2
- data/libxlsxwriter/src/chart.c +116 -23
- data/libxlsxwriter/src/chartsheet.c +508 -0
- data/libxlsxwriter/src/content_types.c +12 -4
- data/libxlsxwriter/src/core.c +11 -11
- data/libxlsxwriter/src/custom.c +3 -3
- data/libxlsxwriter/src/drawing.c +114 -17
- data/libxlsxwriter/src/format.c +5 -5
- data/libxlsxwriter/src/hash_table.c +1 -1
- data/libxlsxwriter/src/packager.c +378 -61
- data/libxlsxwriter/src/relationships.c +2 -2
- data/libxlsxwriter/src/shared_strings.c +18 -4
- data/libxlsxwriter/src/styles.c +59 -12
- data/libxlsxwriter/src/theme.c +2 -2
- data/libxlsxwriter/src/utility.c +93 -6
- data/libxlsxwriter/src/workbook.c +379 -61
- data/libxlsxwriter/src/worksheet.c +1240 -174
- data/libxlsxwriter/src/xmlwriter.c +18 -9
- data/libxlsxwriter/third_party/minizip/Makefile +6 -1
- data/libxlsxwriter/third_party/minizip/ioapi.c +10 -0
- data/libxlsxwriter/third_party/minizip/zip.c +2 -0
- data/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +2 -2
- data/libxlsxwriter/version.txt +1 -1
- data/test/auto_width_test.rb +19 -0
- data/test/date_test.rb +34 -0
- data/test/format_test.rb +8 -0
- data/test/reopen_test.rb +22 -0
- data/test/test_helper.rb +8 -5
- data/test/text_width_test.rb +80 -0
- data/test/tmpfile_test.rb +1 -0
- data/test/validations_test.rb +47 -0
- data/test/worksheet_test.rb +44 -1
- metadata +33 -9
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* libxlsxwriter
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2014-
|
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
5
5
|
*
|
|
6
6
|
* app - A libxlsxwriter library for creating Excel XLSX app files.
|
|
7
7
|
*
|
|
@@ -56,7 +56,7 @@ extern "C" {
|
|
|
56
56
|
#endif
|
|
57
57
|
/* *INDENT-ON* */
|
|
58
58
|
|
|
59
|
-
lxw_app *lxw_app_new();
|
|
59
|
+
lxw_app *lxw_app_new(void);
|
|
60
60
|
void lxw_app_free(lxw_app *app);
|
|
61
61
|
void lxw_app_assemble_xml_file(lxw_app *self);
|
|
62
62
|
void lxw_app_add_part_name(lxw_app *self, const char *name);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*
|
|
2
2
|
* libxlsxwriter
|
|
3
3
|
*
|
|
4
|
-
* Copyright 2014-
|
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
5
5
|
*
|
|
6
6
|
* chart - A libxlsxwriter library for creating Excel XLSX chart files.
|
|
7
7
|
*
|
|
@@ -172,11 +172,17 @@ typedef enum lxw_chart_legend_position {
|
|
|
172
172
|
/** Chart legend positioned at bottom. */
|
|
173
173
|
LXW_CHART_LEGEND_BOTTOM,
|
|
174
174
|
|
|
175
|
+
/** Chart legend positioned at top right. */
|
|
176
|
+
LXW_CHART_LEGEND_TOP_RIGHT,
|
|
177
|
+
|
|
175
178
|
/** Chart legend overlaid at right side. */
|
|
176
179
|
LXW_CHART_LEGEND_OVERLAY_RIGHT,
|
|
177
180
|
|
|
178
181
|
/** Chart legend overlaid at left side. */
|
|
179
|
-
LXW_CHART_LEGEND_OVERLAY_LEFT
|
|
182
|
+
LXW_CHART_LEGEND_OVERLAY_LEFT,
|
|
183
|
+
|
|
184
|
+
/** Chart legend overlaid at top right. */
|
|
185
|
+
LXW_CHART_LEGEND_OVERLAY_TOP_RIGHT
|
|
180
186
|
} lxw_chart_legend_position;
|
|
181
187
|
|
|
182
188
|
/**
|
|
@@ -464,6 +470,17 @@ typedef enum lxw_chart_label_separator {
|
|
|
464
470
|
LXW_CHART_LABEL_SEPARATOR_SPACE
|
|
465
471
|
} lxw_chart_label_separator;
|
|
466
472
|
|
|
473
|
+
/**
|
|
474
|
+
* @brief Chart axis types.
|
|
475
|
+
*/
|
|
476
|
+
typedef enum lxw_chart_axis_type {
|
|
477
|
+
/** Chart X axis. */
|
|
478
|
+
LXW_CHART_AXIS_TYPE_X,
|
|
479
|
+
|
|
480
|
+
/** Chart Y axis. */
|
|
481
|
+
LXW_CHART_AXIS_TYPE_Y
|
|
482
|
+
} lxw_chart_axis_type;
|
|
483
|
+
|
|
467
484
|
enum lxw_chart_subtype {
|
|
468
485
|
|
|
469
486
|
LXW_CHART_SUBTYPE_NONE = 0,
|
|
@@ -512,6 +529,20 @@ typedef enum lxw_chart_axis_label_position {
|
|
|
512
529
|
LXW_CHART_AXIS_LABEL_POSITION_NONE
|
|
513
530
|
} lxw_chart_axis_label_position;
|
|
514
531
|
|
|
532
|
+
/**
|
|
533
|
+
* @brief Axis label alignments.
|
|
534
|
+
*/
|
|
535
|
+
typedef enum lxw_chart_axis_label_alignment {
|
|
536
|
+
/** Chart axis label alignment: center. */
|
|
537
|
+
LXW_CHART_AXIS_LABEL_ALIGN_CENTER,
|
|
538
|
+
|
|
539
|
+
/** Chart axis label alignment: left. */
|
|
540
|
+
LXW_CHART_AXIS_LABEL_ALIGN_LEFT,
|
|
541
|
+
|
|
542
|
+
/** Chart axis label alignment: right. */
|
|
543
|
+
LXW_CHART_AXIS_LABEL_ALIGN_RIGHT
|
|
544
|
+
} lxw_chart_axis_label_alignment;
|
|
545
|
+
|
|
515
546
|
/**
|
|
516
547
|
* @brief Display units for chart value axis.
|
|
517
548
|
*/
|
|
@@ -613,7 +644,7 @@ typedef struct lxw_chart_line {
|
|
|
613
644
|
/** The line dash type. See #lxw_chart_line_dash_type. */
|
|
614
645
|
uint8_t dash_type;
|
|
615
646
|
|
|
616
|
-
|
|
647
|
+
/** Set the transparency of the line. 0 - 100. Default 0. */
|
|
617
648
|
uint8_t transparency;
|
|
618
649
|
|
|
619
650
|
/* Members for internal use only. */
|
|
@@ -675,7 +706,7 @@ typedef struct lxw_chart_font {
|
|
|
675
706
|
char *name;
|
|
676
707
|
|
|
677
708
|
/** The chart font size. The default is 11. */
|
|
678
|
-
|
|
709
|
+
double size;
|
|
679
710
|
|
|
680
711
|
/** The chart font bold property. Set to 0 or 1. */
|
|
681
712
|
uint8_t bold;
|
|
@@ -692,10 +723,17 @@ typedef struct lxw_chart_font {
|
|
|
692
723
|
/** The chart font color. See @ref working_with_colors. */
|
|
693
724
|
lxw_color_t color;
|
|
694
725
|
|
|
695
|
-
|
|
726
|
+
/** The chart font pitch family property. Rarely required. set to 0. */
|
|
696
727
|
uint8_t pitch_family;
|
|
728
|
+
|
|
729
|
+
/** The chart font character set property. Rarely required. set to 0. */
|
|
697
730
|
uint8_t charset;
|
|
731
|
+
|
|
732
|
+
/** The chart font baseline property. Rarely required. set to 0. */
|
|
698
733
|
int8_t baseline;
|
|
734
|
+
|
|
735
|
+
/* Members for internal use only. */
|
|
736
|
+
|
|
699
737
|
uint8_t has_color;
|
|
700
738
|
|
|
701
739
|
} lxw_chart_font;
|
|
@@ -808,6 +846,17 @@ typedef enum lxw_chart_error_bar_direction {
|
|
|
808
846
|
LXW_CHART_ERROR_BAR_DIR_MINUS
|
|
809
847
|
} lxw_chart_error_bar_direction;
|
|
810
848
|
|
|
849
|
+
/**
|
|
850
|
+
* @brief Direction for a data series error bar.
|
|
851
|
+
*/
|
|
852
|
+
typedef enum lxw_chart_error_bar_axis {
|
|
853
|
+
/** X axis error bar. */
|
|
854
|
+
LXW_CHART_ERROR_BAR_AXIS_X,
|
|
855
|
+
|
|
856
|
+
/** Y axis error bar. */
|
|
857
|
+
LXW_CHART_ERROR_BAR_AXIS_Y
|
|
858
|
+
} lxw_chart_error_bar_axis;
|
|
859
|
+
|
|
811
860
|
/**
|
|
812
861
|
* @brief End cap styles for a data series error bar.
|
|
813
862
|
*/
|
|
@@ -952,6 +1001,7 @@ typedef struct lxw_chart_axis {
|
|
|
952
1001
|
uint8_t axis_position;
|
|
953
1002
|
uint8_t position_axis;
|
|
954
1003
|
uint8_t label_position;
|
|
1004
|
+
uint8_t label_align;
|
|
955
1005
|
uint8_t hidden;
|
|
956
1006
|
uint8_t reverse;
|
|
957
1007
|
|
|
@@ -1019,6 +1069,7 @@ typedef struct lxw_chart {
|
|
|
1019
1069
|
uint8_t in_use;
|
|
1020
1070
|
uint8_t chart_group;
|
|
1021
1071
|
uint8_t cat_has_num_fmt;
|
|
1072
|
+
uint8_t is_chartsheet;
|
|
1022
1073
|
|
|
1023
1074
|
uint8_t has_horiz_cat_axis;
|
|
1024
1075
|
uint8_t has_horiz_val_axis;
|
|
@@ -1074,6 +1125,7 @@ typedef struct lxw_chart {
|
|
|
1074
1125
|
lxw_chart_fill *down_bar_fill;
|
|
1075
1126
|
|
|
1076
1127
|
uint8_t default_label_position;
|
|
1128
|
+
uint8_t is_protected;
|
|
1077
1129
|
|
|
1078
1130
|
STAILQ_ENTRY (lxw_chart) ordered_list_pointers;
|
|
1079
1131
|
STAILQ_ENTRY (lxw_chart) list_pointers;
|
|
@@ -1255,7 +1307,7 @@ void chart_series_set_values(lxw_chart_series *series, const char *sheetname,
|
|
|
1255
1307
|
* @code
|
|
1256
1308
|
* lxw_chart_series *series = chart_add_series(chart, NULL, "=Sheet1!$B$2:$B$7");
|
|
1257
1309
|
*
|
|
1258
|
-
* chart_series_set_name(series, "=Sheet1!$
|
|
1310
|
+
* chart_series_set_name(series, "=Sheet1!$B$1");
|
|
1259
1311
|
* @endcode
|
|
1260
1312
|
*
|
|
1261
1313
|
* See also the `chart_series_set_name_range()` function to see how to set the
|
|
@@ -1768,7 +1820,7 @@ void chart_series_set_labels_percentage(lxw_chart_series *series);
|
|
|
1768
1820
|
* For more information see @ref chart_labels.
|
|
1769
1821
|
*/
|
|
1770
1822
|
void chart_series_set_labels_num_format(lxw_chart_series *series,
|
|
1771
|
-
char *num_format);
|
|
1823
|
+
const char *num_format);
|
|
1772
1824
|
|
|
1773
1825
|
/**
|
|
1774
1826
|
* @brief Set the font properties for chart data labels in a series
|
|
@@ -1983,7 +2035,8 @@ void chart_series_set_trendline_intercept(lxw_chart_series *series,
|
|
|
1983
2035
|
*
|
|
1984
2036
|
* For more information see @ref chart_trendlines.
|
|
1985
2037
|
*/
|
|
1986
|
-
void chart_series_set_trendline_name(lxw_chart_series *series,
|
|
2038
|
+
void chart_series_set_trendline_name(lxw_chart_series *series,
|
|
2039
|
+
const char *name);
|
|
1987
2040
|
|
|
1988
2041
|
/**
|
|
1989
2042
|
* @brief Set the trendline line properties for a chart data series.
|
|
@@ -2008,6 +2061,46 @@ void chart_series_set_trendline_name(lxw_chart_series *series, char *name);
|
|
|
2008
2061
|
*/
|
|
2009
2062
|
void chart_series_set_trendline_line(lxw_chart_series *series,
|
|
2010
2063
|
lxw_chart_line *line);
|
|
2064
|
+
/**
|
|
2065
|
+
* @brief Get a pointer to X or Y error bars from a chart series.
|
|
2066
|
+
*
|
|
2067
|
+
* @param series A series object created via `chart_add_series()`.
|
|
2068
|
+
* @param axis_type The axis type (X or Y): #lxw_chart_error_bar_axis.
|
|
2069
|
+
*
|
|
2070
|
+
* The `%chart_series_get_error_bars()` function returns a pointer to the
|
|
2071
|
+
* error bars of a series based on the type of #lxw_chart_error_bar_axis:
|
|
2072
|
+
*
|
|
2073
|
+
* @code
|
|
2074
|
+
* lxw_series_error_bars *x_error_bars;
|
|
2075
|
+
* lxw_series_error_bars *y_error_bars;
|
|
2076
|
+
*
|
|
2077
|
+
* x_error_bars = chart_series_get_error_bars(series, LXW_CHART_ERROR_BAR_AXIS_X);
|
|
2078
|
+
* y_error_bars = chart_series_get_error_bars(series, LXW_CHART_ERROR_BAR_AXIS_Y);
|
|
2079
|
+
*
|
|
2080
|
+
* // Use the error bar pointers.
|
|
2081
|
+
* chart_series_set_error_bars(x_error_bars,
|
|
2082
|
+
* LXW_CHART_ERROR_BAR_TYPE_STD_DEV, 1);
|
|
2083
|
+
*
|
|
2084
|
+
* chart_series_set_error_bars(y_error_bars,
|
|
2085
|
+
* LXW_CHART_ERROR_BAR_TYPE_STD_ERROR, 0);
|
|
2086
|
+
* @endcode
|
|
2087
|
+
*
|
|
2088
|
+
* Note, the series error bars can also be accessed directly:
|
|
2089
|
+
*
|
|
2090
|
+
* @code
|
|
2091
|
+
* // Equivalent to the above example, without function calls.
|
|
2092
|
+
* chart_series_set_error_bars(series->x_error_bars,
|
|
2093
|
+
* LXW_CHART_ERROR_BAR_TYPE_STD_DEV, 1);
|
|
2094
|
+
*
|
|
2095
|
+
* chart_series_set_error_bars(series->y_error_bars,
|
|
2096
|
+
* LXW_CHART_ERROR_BAR_TYPE_STD_ERROR, 0);
|
|
2097
|
+
* @endcode
|
|
2098
|
+
*
|
|
2099
|
+
* @return Pointer to the series error bars, or NULL if not found.
|
|
2100
|
+
*/
|
|
2101
|
+
|
|
2102
|
+
lxw_series_error_bars *chart_series_get_error_bars(lxw_chart_series *series, lxw_chart_error_bar_axis
|
|
2103
|
+
axis_type);
|
|
2011
2104
|
|
|
2012
2105
|
/**
|
|
2013
2106
|
* Set the X or Y error bars for a chart series.
|
|
@@ -2071,7 +2164,7 @@ void chart_series_set_error_bars(lxw_series_error_bars *error_bars,
|
|
|
2071
2164
|
* series.
|
|
2072
2165
|
*
|
|
2073
2166
|
* @param error_bars A pointer to the series X or Y error bars.
|
|
2074
|
-
* @param direction The bar direction: #lxw_chart_error_bar_direction
|
|
2167
|
+
* @param direction The bar direction: #lxw_chart_error_bar_direction.
|
|
2075
2168
|
*
|
|
2076
2169
|
* The `%chart_series_set_error_bars_direction()` function sets the
|
|
2077
2170
|
* direction of the error bars:
|
|
@@ -2153,6 +2246,37 @@ void chart_series_set_error_bars_endcap(lxw_series_error_bars *error_bars,
|
|
|
2153
2246
|
void chart_series_set_error_bars_line(lxw_series_error_bars *error_bars,
|
|
2154
2247
|
lxw_chart_line *line);
|
|
2155
2248
|
|
|
2249
|
+
/**
|
|
2250
|
+
* @brief Get an axis pointer from a chart.
|
|
2251
|
+
*
|
|
2252
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
2253
|
+
* @param axis_type The axis type (X or Y): #lxw_chart_axis_type.
|
|
2254
|
+
*
|
|
2255
|
+
* The `%chart_axis_get()` function returns a pointer to a chart axis based
|
|
2256
|
+
* on the #lxw_chart_axis_type:
|
|
2257
|
+
*
|
|
2258
|
+
* @code
|
|
2259
|
+
* lxw_chart_axis *x_axis = chart_axis_get(chart, LXW_CHART_AXIS_TYPE_X);
|
|
2260
|
+
* lxw_chart_axis *y_axis = chart_axis_get(chart, LXW_CHART_AXIS_TYPE_Y);
|
|
2261
|
+
*
|
|
2262
|
+
* // Use the axis pointer in other functions.
|
|
2263
|
+
* chart_axis_major_gridlines_set_visible(x_axis, LXW_TRUE);
|
|
2264
|
+
* chart_axis_major_gridlines_set_visible(y_axis, LXW_TRUE);
|
|
2265
|
+
* @endcode
|
|
2266
|
+
*
|
|
2267
|
+
* Note, the axis pointer can also be accessed directly:
|
|
2268
|
+
*
|
|
2269
|
+
* @code
|
|
2270
|
+
* // Equivalent to the above example, without function calls.
|
|
2271
|
+
* chart_axis_major_gridlines_set_visible(chart->x_axis, LXW_TRUE);
|
|
2272
|
+
* chart_axis_major_gridlines_set_visible(chart->y_axis, LXW_TRUE);
|
|
2273
|
+
* @endcode
|
|
2274
|
+
*
|
|
2275
|
+
* @return Pointer to the chart axis, or NULL if not found.
|
|
2276
|
+
*/
|
|
2277
|
+
lxw_chart_axis *chart_axis_get(lxw_chart *chart,
|
|
2278
|
+
lxw_chart_axis_type axis_type);
|
|
2279
|
+
|
|
2156
2280
|
/**
|
|
2157
2281
|
* @brief Set the name caption of the an axis.
|
|
2158
2282
|
*
|
|
@@ -2174,7 +2298,7 @@ void chart_series_set_error_bars_line(lxw_series_error_bars *error_bars,
|
|
|
2174
2298
|
* a cell in the workbook that contains the name:
|
|
2175
2299
|
*
|
|
2176
2300
|
* @code
|
|
2177
|
-
* chart_axis_set_name(chart->x_axis, "=Sheet1!$
|
|
2301
|
+
* chart_axis_set_name(chart->x_axis, "=Sheet1!$B$1");
|
|
2178
2302
|
* @endcode
|
|
2179
2303
|
*
|
|
2180
2304
|
* See also the `chart_axis_set_name_range()` function to see how to set the
|
|
@@ -2279,7 +2403,7 @@ void chart_axis_set_num_font(lxw_chart_axis *axis, lxw_chart_font *font);
|
|
|
2279
2403
|
* **Axis types**: This function is applicable to to all axes types.
|
|
2280
2404
|
* See @ref ww_charts_axes.
|
|
2281
2405
|
*/
|
|
2282
|
-
void chart_axis_set_num_format(lxw_chart_axis *axis, char *num_format);
|
|
2406
|
+
void chart_axis_set_num_format(lxw_chart_axis *axis, const char *num_format);
|
|
2283
2407
|
|
|
2284
2408
|
/**
|
|
2285
2409
|
* @brief Set the line properties for a chart axis.
|
|
@@ -2466,7 +2590,7 @@ void chart_axis_set_position(lxw_chart_axis *axis, uint8_t position);
|
|
|
2466
2590
|
*
|
|
2467
2591
|
* @code
|
|
2468
2592
|
* chart_axis_set_label_position(chart->x_axis, LXW_CHART_AXIS_LABEL_POSITION_HIGH);
|
|
2469
|
-
|
|
2593
|
+
* chart_axis_set_label_position(chart->y_axis, LXW_CHART_AXIS_LABEL_POSITION_HIGH);
|
|
2470
2594
|
* @endcode
|
|
2471
2595
|
*
|
|
2472
2596
|
* @image html chart_label_position2.png
|
|
@@ -2489,6 +2613,31 @@ void chart_axis_set_position(lxw_chart_axis *axis, uint8_t position);
|
|
|
2489
2613
|
*/
|
|
2490
2614
|
void chart_axis_set_label_position(lxw_chart_axis *axis, uint8_t position);
|
|
2491
2615
|
|
|
2616
|
+
/**
|
|
2617
|
+
* @brief Set the alignment of the axis labels.
|
|
2618
|
+
*
|
|
2619
|
+
* @param axis A pointer to a chart #lxw_chart_axis object.
|
|
2620
|
+
* @param align A #lxw_chart_axis_label_alignment value.
|
|
2621
|
+
*
|
|
2622
|
+
* Position the category axis labels for the chart. The labels are the
|
|
2623
|
+
* numbers, or strings or dates, on the axis that indicate the categories
|
|
2624
|
+
* of the axis.
|
|
2625
|
+
*
|
|
2626
|
+
* The allowable values:
|
|
2627
|
+
*
|
|
2628
|
+
* - #LXW_CHART_AXIS_LABEL_ALIGN_CENTER - Align label center (default).
|
|
2629
|
+
* - #LXW_CHART_AXIS_LABEL_ALIGN_LEFT - Align label left.
|
|
2630
|
+
* - #LXW_CHART_AXIS_LABEL_ALIGN_RIGHT - Align label right.
|
|
2631
|
+
*
|
|
2632
|
+
* @code
|
|
2633
|
+
* chart_axis_set_label_align(chart->x_axis, LXW_CHART_AXIS_LABEL_ALIGN_RIGHT);
|
|
2634
|
+
* @endcode
|
|
2635
|
+
*
|
|
2636
|
+
* **Axis types**: This function is applicable to category axes only.
|
|
2637
|
+
* See @ref ww_charts_axes.
|
|
2638
|
+
*/
|
|
2639
|
+
void chart_axis_set_label_align(lxw_chart_axis *axis, uint8_t align);
|
|
2640
|
+
|
|
2492
2641
|
/**
|
|
2493
2642
|
* @brief Set the minimum value for a chart axis.
|
|
2494
2643
|
*
|
|
@@ -2857,7 +3006,7 @@ void chart_axis_minor_gridlines_set_line(lxw_chart_axis *axis,
|
|
|
2857
3006
|
* a cell in the workbook that contains the name:
|
|
2858
3007
|
*
|
|
2859
3008
|
* @code
|
|
2860
|
-
* chart_title_set_name(chart, "=Sheet1!$
|
|
3009
|
+
* chart_title_set_name(chart, "=Sheet1!$B$1");
|
|
2861
3010
|
* @endcode
|
|
2862
3011
|
*
|
|
2863
3012
|
* See also the `chart_title_set_name_range()` function to see how to set the
|
|
@@ -2939,8 +3088,10 @@ void chart_title_off(lxw_chart *chart);
|
|
|
2939
3088
|
* LXW_CHART_LEGEND_LEFT
|
|
2940
3089
|
* LXW_CHART_LEGEND_TOP
|
|
2941
3090
|
* LXW_CHART_LEGEND_BOTTOM
|
|
3091
|
+
* LXW_CHART_LEGEND_TOP_RIGHT
|
|
2942
3092
|
* LXW_CHART_LEGEND_OVERLAY_RIGHT
|
|
2943
3093
|
* LXW_CHART_LEGEND_OVERLAY_LEFT
|
|
3094
|
+
* LXW_CHART_LEGEND_OVERLAY_TOP_RIGHT
|
|
2944
3095
|
*
|
|
2945
3096
|
* For example:
|
|
2946
3097
|
*
|
|
@@ -0,0 +1,544 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* libxlsxwriter
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2014-2019, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
5
|
+
*
|
|
6
|
+
* chartsheet - A libxlsxwriter library for creating Excel XLSX chartsheet files.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @page chartsheet_page The Chartsheet object
|
|
12
|
+
*
|
|
13
|
+
* The Chartsheet object represents an Excel chartsheet, which is a type of
|
|
14
|
+
* worksheet that only contains a chart. The Chartsheet object handles
|
|
15
|
+
* operations such as adding a chart and setting the page layout.
|
|
16
|
+
*
|
|
17
|
+
* See @ref chartsheet.h for full details of the functionality.
|
|
18
|
+
*
|
|
19
|
+
* @file chartsheet.h
|
|
20
|
+
*
|
|
21
|
+
* @brief Functions related to adding data and formatting to a chartsheet.
|
|
22
|
+
*
|
|
23
|
+
* The Chartsheet object represents an Excel chartsheet. It handles operations
|
|
24
|
+
* such as adding a chart and setting the page layout.
|
|
25
|
+
*
|
|
26
|
+
* A Chartsheet object isn't created directly. Instead a chartsheet is created
|
|
27
|
+
* by calling the workbook_add_chartsheet() function from a Workbook object. A
|
|
28
|
+
* chartsheet object functions as a worksheet and not as a chart. In order to
|
|
29
|
+
* have it display data a #lxw_chart object must be created and added to the
|
|
30
|
+
* chartsheet:
|
|
31
|
+
*
|
|
32
|
+
* @code
|
|
33
|
+
* #include "xlsxwriter.h"
|
|
34
|
+
*
|
|
35
|
+
* int main() {
|
|
36
|
+
*
|
|
37
|
+
* lxw_workbook *workbook = new_workbook("chartsheet.xlsx");
|
|
38
|
+
* lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
|
39
|
+
* lxw_chartsheet *chartsheet = workbook_add_chartsheet(workbook, NULL);
|
|
40
|
+
* lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_BAR);
|
|
41
|
+
*
|
|
42
|
+
* //... Set up the chart.
|
|
43
|
+
*
|
|
44
|
+
* // Add the chart to the chartsheet.
|
|
45
|
+
* return workbook_close(workbook);
|
|
46
|
+
*
|
|
47
|
+
* }
|
|
48
|
+
* @endcode
|
|
49
|
+
*
|
|
50
|
+
* @image html chartsheet.png
|
|
51
|
+
*
|
|
52
|
+
* The data for the chartsheet chart must be contained on a separate
|
|
53
|
+
* worksheet. That is why it is always created in conjunction with at least
|
|
54
|
+
* one data worksheet, as shown above.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
#ifndef __LXW_CHARTSHEET_H__
|
|
58
|
+
#define __LXW_CHARTSHEET_H__
|
|
59
|
+
|
|
60
|
+
#include <stdint.h>
|
|
61
|
+
|
|
62
|
+
#include "common.h"
|
|
63
|
+
#include "worksheet.h"
|
|
64
|
+
#include "drawing.h"
|
|
65
|
+
#include "utility.h"
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @brief Struct to represent an Excel chartsheet.
|
|
69
|
+
*
|
|
70
|
+
* The members of the lxw_chartsheet struct aren't modified directly. Instead
|
|
71
|
+
* the chartsheet properties are set by calling the functions shown in
|
|
72
|
+
* chartsheet.h.
|
|
73
|
+
*/
|
|
74
|
+
typedef struct lxw_chartsheet {
|
|
75
|
+
|
|
76
|
+
FILE *file;
|
|
77
|
+
lxw_worksheet *worksheet;
|
|
78
|
+
lxw_chart *chart;
|
|
79
|
+
|
|
80
|
+
struct lxw_protection protection;
|
|
81
|
+
uint8_t is_protected;
|
|
82
|
+
|
|
83
|
+
char *name;
|
|
84
|
+
char *quoted_name;
|
|
85
|
+
char *tmpdir;
|
|
86
|
+
uint32_t index;
|
|
87
|
+
uint8_t active;
|
|
88
|
+
uint8_t selected;
|
|
89
|
+
uint8_t hidden;
|
|
90
|
+
uint16_t *active_sheet;
|
|
91
|
+
uint16_t *first_sheet;
|
|
92
|
+
uint16_t rel_count;
|
|
93
|
+
|
|
94
|
+
STAILQ_ENTRY (lxw_chartsheet) list_pointers;
|
|
95
|
+
|
|
96
|
+
} lxw_chartsheet;
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
/* *INDENT-OFF* */
|
|
100
|
+
#ifdef __cplusplus
|
|
101
|
+
extern "C" {
|
|
102
|
+
#endif
|
|
103
|
+
/* *INDENT-ON* */
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @brief Insert a chart object into a chartsheet.
|
|
107
|
+
*
|
|
108
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
109
|
+
* @param chart A #lxw_chart object created via workbook_add_chart().
|
|
110
|
+
*
|
|
111
|
+
* @return A #lxw_error code.
|
|
112
|
+
*
|
|
113
|
+
* The `%chartsheet_set_chart()` function can be used to insert a chart into a
|
|
114
|
+
* chartsheet. The chart object must be created first using the
|
|
115
|
+
* `workbook_add_chart()` function and configured using the @ref chart.h
|
|
116
|
+
* functions.
|
|
117
|
+
*
|
|
118
|
+
* @code
|
|
119
|
+
* // Create the chartsheet.
|
|
120
|
+
* lxw_chartsheet *chartsheet = workbook_add_chartsheet(workbook, NULL);
|
|
121
|
+
*
|
|
122
|
+
* // Create a chart object.
|
|
123
|
+
* lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_LINE);
|
|
124
|
+
*
|
|
125
|
+
* // Add a data series to the chart.
|
|
126
|
+
* chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$6");
|
|
127
|
+
*
|
|
128
|
+
* // Insert the chart into the chartsheet.
|
|
129
|
+
* chartsheet_set_chart(chartsheet, chart);
|
|
130
|
+
* @endcode
|
|
131
|
+
*
|
|
132
|
+
* @image html chartsheet2.png
|
|
133
|
+
*
|
|
134
|
+
* **Note:**
|
|
135
|
+
*
|
|
136
|
+
* A chart may only be inserted once into a chartsheet or a worksheet. If
|
|
137
|
+
* several similar charts are required then each one must be created
|
|
138
|
+
* separately.
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
lxw_error chartsheet_set_chart(lxw_chartsheet *chartsheet, lxw_chart *chart);
|
|
142
|
+
|
|
143
|
+
/* Not currently required since scale options aren't useful in a chartsheet. */
|
|
144
|
+
lxw_error chartsheet_set_chart_opt(lxw_chartsheet *chartsheet,
|
|
145
|
+
lxw_chart *chart,
|
|
146
|
+
lxw_image_options *user_options);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* @brief Make a chartsheet the active, i.e., visible chartsheet.
|
|
150
|
+
*
|
|
151
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
152
|
+
*
|
|
153
|
+
* The `%chartsheet_activate()` function is used to specify which chartsheet
|
|
154
|
+
* is initially visible in a multi-sheet workbook:
|
|
155
|
+
*
|
|
156
|
+
* @code
|
|
157
|
+
* lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL);
|
|
158
|
+
* lxw_chartsheet *chartsheet1 = workbook_add_chartsheet(workbook, NULL);
|
|
159
|
+
* lxw_chartsheet *chartsheet2 = workbook_add_chartsheet(workbook, NULL);
|
|
160
|
+
* lxw_chartsheet *chartsheet3 = workbook_add_chartsheet(workbook, NULL);
|
|
161
|
+
*
|
|
162
|
+
* chartsheet_activate(chartsheet3);
|
|
163
|
+
* @endcode
|
|
164
|
+
*
|
|
165
|
+
* @image html chartsheet_activate.png
|
|
166
|
+
*
|
|
167
|
+
* More than one chartsheet can be selected via the `chartsheet_select()`
|
|
168
|
+
* function, see below, however only one chartsheet can be active.
|
|
169
|
+
*
|
|
170
|
+
* The default active chartsheet is the first chartsheet.
|
|
171
|
+
*
|
|
172
|
+
* See also `worksheet_activate()`.
|
|
173
|
+
*
|
|
174
|
+
*/
|
|
175
|
+
void chartsheet_activate(lxw_chartsheet *chartsheet);
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @brief Set a chartsheet tab as selected.
|
|
179
|
+
*
|
|
180
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
181
|
+
*
|
|
182
|
+
* The `%chartsheet_select()` function is used to indicate that a chartsheet
|
|
183
|
+
* is selected in a multi-sheet workbook:
|
|
184
|
+
*
|
|
185
|
+
* @code
|
|
186
|
+
* chartsheet_activate(chartsheet1);
|
|
187
|
+
* chartsheet_select(chartsheet2);
|
|
188
|
+
* chartsheet_select(chartsheet3);
|
|
189
|
+
*
|
|
190
|
+
* @endcode
|
|
191
|
+
*
|
|
192
|
+
* A selected chartsheet has its tab highlighted. Selecting chartsheets is a
|
|
193
|
+
* way of grouping them together so that, for example, several chartsheets
|
|
194
|
+
* could be printed in one go. A chartsheet that has been activated via the
|
|
195
|
+
* `chartsheet_activate()` function will also appear as selected.
|
|
196
|
+
*
|
|
197
|
+
* See also `worksheet_select()`.
|
|
198
|
+
*
|
|
199
|
+
*/
|
|
200
|
+
void chartsheet_select(lxw_chartsheet *chartsheet);
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* @brief Hide the current chartsheet.
|
|
204
|
+
*
|
|
205
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
206
|
+
*
|
|
207
|
+
* The `%chartsheet_hide()` function is used to hide a chartsheet:
|
|
208
|
+
*
|
|
209
|
+
* @code
|
|
210
|
+
* chartsheet_hide(chartsheet2);
|
|
211
|
+
* @endcode
|
|
212
|
+
*
|
|
213
|
+
* You may wish to hide a chartsheet in order to avoid confusing a user with
|
|
214
|
+
* intermediate data or calculations.
|
|
215
|
+
*
|
|
216
|
+
* @image html hide_sheet.png
|
|
217
|
+
*
|
|
218
|
+
* A hidden chartsheet can not be activated or selected so this function is
|
|
219
|
+
* mutually exclusive with the `chartsheet_activate()` and
|
|
220
|
+
* `chartsheet_select()` functions. In addition, since the first chartsheet
|
|
221
|
+
* will default to being the active chartsheet, you cannot hide the first
|
|
222
|
+
* chartsheet without activating another sheet:
|
|
223
|
+
*
|
|
224
|
+
* @code
|
|
225
|
+
* chartsheet_activate(chartsheet2);
|
|
226
|
+
* chartsheet_hide(chartsheet1);
|
|
227
|
+
* @endcode
|
|
228
|
+
*
|
|
229
|
+
* See also `worksheet_hide()`.
|
|
230
|
+
*
|
|
231
|
+
*/
|
|
232
|
+
void chartsheet_hide(lxw_chartsheet *chartsheet);
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @brief Set current chartsheet as the first visible sheet tab.
|
|
236
|
+
*
|
|
237
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
238
|
+
*
|
|
239
|
+
* The `chartsheet_activate()` function determines which chartsheet is
|
|
240
|
+
* initially selected. However, if there are a large number of chartsheets the
|
|
241
|
+
* selected chartsheet may not appear on the screen. To avoid this you can
|
|
242
|
+
* select the leftmost visible chartsheet tab using
|
|
243
|
+
* `%chartsheet_set_first_sheet()`:
|
|
244
|
+
*
|
|
245
|
+
* @code
|
|
246
|
+
* chartsheet_set_first_sheet(chartsheet19); // First visible chartsheet tab.
|
|
247
|
+
* chartsheet_activate(chartsheet20); // First visible chartsheet.
|
|
248
|
+
* @endcode
|
|
249
|
+
*
|
|
250
|
+
* This function is not required very often. The default value is the first
|
|
251
|
+
* chartsheet.
|
|
252
|
+
*
|
|
253
|
+
* See also `worksheet_set_first_sheet()`.
|
|
254
|
+
*
|
|
255
|
+
*/
|
|
256
|
+
void chartsheet_set_first_sheet(lxw_chartsheet *chartsheet);
|
|
257
|
+
|
|
258
|
+
/**
|
|
259
|
+
* @brief Set the color of the chartsheet tab.
|
|
260
|
+
*
|
|
261
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
262
|
+
* @param color The tab color.
|
|
263
|
+
*
|
|
264
|
+
* The `%chartsheet_set_tab_color()` function is used to change the color of
|
|
265
|
+
* the chartsheet tab:
|
|
266
|
+
*
|
|
267
|
+
* @code
|
|
268
|
+
* chartsheet_set_tab_color(chartsheet1, LXW_COLOR_RED);
|
|
269
|
+
* chartsheet_set_tab_color(chartsheet2, LXW_COLOR_GREEN);
|
|
270
|
+
* chartsheet_set_tab_color(chartsheet3, 0xFF9900); // Orange.
|
|
271
|
+
* @endcode
|
|
272
|
+
*
|
|
273
|
+
* The color should be an RGB integer value, see @ref working_with_colors.
|
|
274
|
+
*
|
|
275
|
+
* See also `worksheet_set_tab_color()`.
|
|
276
|
+
*/
|
|
277
|
+
void chartsheet_set_tab_color(lxw_chartsheet *chartsheet, lxw_color_t color);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* @brief Protect elements of a chartsheet from modification.
|
|
281
|
+
*
|
|
282
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
283
|
+
* @param password A chartsheet password.
|
|
284
|
+
* @param options Chartsheet elements to protect.
|
|
285
|
+
*
|
|
286
|
+
* The `%chartsheet_protect()` function protects chartsheet elements from
|
|
287
|
+
* modification:
|
|
288
|
+
*
|
|
289
|
+
* @code
|
|
290
|
+
* chartsheet_protect(chartsheet, "Some Password", options);
|
|
291
|
+
* @endcode
|
|
292
|
+
*
|
|
293
|
+
* The `password` and lxw_protection pointer are both optional:
|
|
294
|
+
*
|
|
295
|
+
* @code
|
|
296
|
+
* chartsheet_protect(chartsheet2, NULL, my_options);
|
|
297
|
+
* chartsheet_protect(chartsheet3, "password", NULL);
|
|
298
|
+
* chartsheet_protect(chartsheet4, "password", my_options);
|
|
299
|
+
* @endcode
|
|
300
|
+
*
|
|
301
|
+
* Passing a `NULL` password is the same as turning on protection without a
|
|
302
|
+
* password. Passing a `NULL` password and `NULL` options had no effect on
|
|
303
|
+
* chartsheets.
|
|
304
|
+
*
|
|
305
|
+
* You can specify which chartsheet elements you wish to protect by passing a
|
|
306
|
+
* lxw_protection pointer in the `options` argument. In Excel chartsheets only
|
|
307
|
+
* have two protection options:
|
|
308
|
+
*
|
|
309
|
+
* no_content
|
|
310
|
+
* no_objects
|
|
311
|
+
*
|
|
312
|
+
* All parameters are off by default. Individual elements can be protected as
|
|
313
|
+
* follows:
|
|
314
|
+
*
|
|
315
|
+
* @code
|
|
316
|
+
* lxw_protection options = {
|
|
317
|
+
* .no_content = 1,
|
|
318
|
+
* .no_objects = 1,
|
|
319
|
+
* };
|
|
320
|
+
*
|
|
321
|
+
* chartsheet_protect(chartsheet, NULL, &options);
|
|
322
|
+
*
|
|
323
|
+
* @endcode
|
|
324
|
+
*
|
|
325
|
+
* See also worksheet_protect().
|
|
326
|
+
*
|
|
327
|
+
* **Note:** Sheet level passwords in Excel offer **very** weak
|
|
328
|
+
* protection. They don't encrypt your data and are very easy to
|
|
329
|
+
* deactivate. Full workbook encryption is not supported by `libxlsxwriter`
|
|
330
|
+
* since it requires a completely different file format.
|
|
331
|
+
*/
|
|
332
|
+
void chartsheet_protect(lxw_chartsheet *chartsheet, const char *password,
|
|
333
|
+
lxw_protection *options);
|
|
334
|
+
|
|
335
|
+
/**
|
|
336
|
+
* @brief Set the chartsheet zoom factor.
|
|
337
|
+
*
|
|
338
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
339
|
+
* @param scale Chartsheet zoom factor.
|
|
340
|
+
*
|
|
341
|
+
* Set the chartsheet zoom factor in the range `10 <= zoom <= 400`:
|
|
342
|
+
*
|
|
343
|
+
* @code
|
|
344
|
+
* chartsheet_set_zoom(chartsheet, 75);
|
|
345
|
+
* @endcode
|
|
346
|
+
*
|
|
347
|
+
* The default zoom factor is 100. It isn't possible to set the zoom to
|
|
348
|
+
* "Selection" because it is calculated by Excel at run-time.
|
|
349
|
+
*
|
|
350
|
+
* See also `worksheet_set_zoom()`.
|
|
351
|
+
*/
|
|
352
|
+
void chartsheet_set_zoom(lxw_chartsheet *chartsheet, uint16_t scale);
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* @brief Set the page orientation as landscape.
|
|
356
|
+
*
|
|
357
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
358
|
+
*
|
|
359
|
+
* This function is used to set the orientation of a chartsheet's printed page
|
|
360
|
+
* to landscape. The default chartsheet orientation is landscape, so this
|
|
361
|
+
* function isn't generally required:
|
|
362
|
+
*
|
|
363
|
+
* @code
|
|
364
|
+
* chartsheet_set_landscape(chartsheet);
|
|
365
|
+
* @endcode
|
|
366
|
+
*/
|
|
367
|
+
void chartsheet_set_landscape(lxw_chartsheet *chartsheet);
|
|
368
|
+
|
|
369
|
+
/**
|
|
370
|
+
* @brief Set the page orientation as portrait.
|
|
371
|
+
*
|
|
372
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
373
|
+
*
|
|
374
|
+
* This function is used to set the orientation of a chartsheet's printed page
|
|
375
|
+
* to portrait:
|
|
376
|
+
*
|
|
377
|
+
* @code
|
|
378
|
+
* chartsheet_set_portrait(chartsheet);
|
|
379
|
+
* @endcode
|
|
380
|
+
*/
|
|
381
|
+
void chartsheet_set_portrait(lxw_chartsheet *chartsheet);
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* @brief Set the paper type for printing.
|
|
385
|
+
*
|
|
386
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
387
|
+
* @param paper_type The Excel paper format type.
|
|
388
|
+
*
|
|
389
|
+
* This function is used to set the paper format for the printed output of a
|
|
390
|
+
* chartsheet:
|
|
391
|
+
*
|
|
392
|
+
* @code
|
|
393
|
+
* chartsheet_set_paper(chartsheet1, 1); // US Letter
|
|
394
|
+
* chartsheet_set_paper(chartsheet2, 9); // A4
|
|
395
|
+
* @endcode
|
|
396
|
+
*
|
|
397
|
+
* If you do not specify a paper type the chartsheet will print using the
|
|
398
|
+
* printer's default paper style.
|
|
399
|
+
*
|
|
400
|
+
* See `worksheet_set_paper()` for a full list of available paper sizes.
|
|
401
|
+
*/
|
|
402
|
+
void chartsheet_set_paper(lxw_chartsheet *chartsheet, uint8_t paper_type);
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* @brief Set the chartsheet margins for the printed page.
|
|
406
|
+
*
|
|
407
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
408
|
+
* @param left Left margin in inches. Excel default is 0.7.
|
|
409
|
+
* @param right Right margin in inches. Excel default is 0.7.
|
|
410
|
+
* @param top Top margin in inches. Excel default is 0.75.
|
|
411
|
+
* @param bottom Bottom margin in inches. Excel default is 0.75.
|
|
412
|
+
*
|
|
413
|
+
* The `%chartsheet_set_margins()` function is used to set the margins of the
|
|
414
|
+
* chartsheet when it is printed. The units are in inches. Specifying `-1` for
|
|
415
|
+
* any parameter will give the default Excel value as shown above.
|
|
416
|
+
*
|
|
417
|
+
* @code
|
|
418
|
+
* chartsheet_set_margins(chartsheet, 1.3, 1.2, -1, -1);
|
|
419
|
+
* @endcode
|
|
420
|
+
*
|
|
421
|
+
*/
|
|
422
|
+
void chartsheet_set_margins(lxw_chartsheet *chartsheet, double left,
|
|
423
|
+
double right, double top, double bottom);
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* @brief Set the printed page header caption.
|
|
427
|
+
*
|
|
428
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
429
|
+
* @param string The header string.
|
|
430
|
+
*
|
|
431
|
+
* @return A #lxw_error code.
|
|
432
|
+
*
|
|
433
|
+
* Headers and footers are generated using a string which is a combination of
|
|
434
|
+
* plain text and control characters
|
|
435
|
+
*
|
|
436
|
+
* @code
|
|
437
|
+
* chartsheet_set_header(chartsheet, "&LHello");
|
|
438
|
+
*
|
|
439
|
+
* // ---------------------------------------------------------------
|
|
440
|
+
* // | |
|
|
441
|
+
* // | Hello |
|
|
442
|
+
* // | |
|
|
443
|
+
*
|
|
444
|
+
*
|
|
445
|
+
* chartsheet_set_header(chartsheet, "&CHello");
|
|
446
|
+
*
|
|
447
|
+
* // ---------------------------------------------------------------
|
|
448
|
+
* // | |
|
|
449
|
+
* // | Hello |
|
|
450
|
+
* // | |
|
|
451
|
+
*
|
|
452
|
+
*
|
|
453
|
+
* chartsheet_set_header(chartsheet, "&RHello");
|
|
454
|
+
*
|
|
455
|
+
* // ---------------------------------------------------------------
|
|
456
|
+
* // | |
|
|
457
|
+
* // | Hello |
|
|
458
|
+
* // | |
|
|
459
|
+
*
|
|
460
|
+
*
|
|
461
|
+
* @endcode
|
|
462
|
+
*
|
|
463
|
+
* See `worksheet_set_header()` for a full explanation of the syntax of
|
|
464
|
+
* Excel's header formatting and control characters.
|
|
465
|
+
*
|
|
466
|
+
*/
|
|
467
|
+
lxw_error chartsheet_set_header(lxw_chartsheet *chartsheet,
|
|
468
|
+
const char *string);
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* @brief Set the printed page footer caption.
|
|
472
|
+
*
|
|
473
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
474
|
+
* @param string The footer string.
|
|
475
|
+
*
|
|
476
|
+
* @return A #lxw_error code.
|
|
477
|
+
*
|
|
478
|
+
* The syntax of this function is the same as chartsheet_set_header().
|
|
479
|
+
*
|
|
480
|
+
*/
|
|
481
|
+
lxw_error chartsheet_set_footer(lxw_chartsheet *chartsheet,
|
|
482
|
+
const char *string);
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* @brief Set the printed page header caption with additional options.
|
|
486
|
+
*
|
|
487
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
488
|
+
* @param string The header string.
|
|
489
|
+
* @param options Header options.
|
|
490
|
+
*
|
|
491
|
+
* @return A #lxw_error code.
|
|
492
|
+
*
|
|
493
|
+
* The syntax of this function is the same as chartsheet_set_header() with an
|
|
494
|
+
* additional parameter to specify options for the header.
|
|
495
|
+
*
|
|
496
|
+
* Currently, the only available option is the header margin:
|
|
497
|
+
*
|
|
498
|
+
* @code
|
|
499
|
+
*
|
|
500
|
+
* lxw_header_footer_options header_options = { 0.2 };
|
|
501
|
+
*
|
|
502
|
+
* chartsheet_set_header_opt(chartsheet, "Some text", &header_options);
|
|
503
|
+
*
|
|
504
|
+
* @endcode
|
|
505
|
+
*
|
|
506
|
+
*/
|
|
507
|
+
lxw_error chartsheet_set_header_opt(lxw_chartsheet *chartsheet,
|
|
508
|
+
const char *string,
|
|
509
|
+
lxw_header_footer_options *options);
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* @brief Set the printed page footer caption with additional options.
|
|
513
|
+
*
|
|
514
|
+
* @param chartsheet Pointer to a lxw_chartsheet instance to be updated.
|
|
515
|
+
* @param string The footer string.
|
|
516
|
+
* @param options Footer options.
|
|
517
|
+
*
|
|
518
|
+
* @return A #lxw_error code.
|
|
519
|
+
*
|
|
520
|
+
* The syntax of this function is the same as chartsheet_set_header_opt().
|
|
521
|
+
*
|
|
522
|
+
*/
|
|
523
|
+
lxw_error chartsheet_set_footer_opt(lxw_chartsheet *chartsheet,
|
|
524
|
+
const char *string,
|
|
525
|
+
lxw_header_footer_options *options);
|
|
526
|
+
|
|
527
|
+
lxw_chartsheet *lxw_chartsheet_new(lxw_worksheet_init_data *init_data);
|
|
528
|
+
void lxw_chartsheet_free(lxw_chartsheet *chartsheet);
|
|
529
|
+
void lxw_chartsheet_assemble_xml_file(lxw_chartsheet *chartsheet);
|
|
530
|
+
|
|
531
|
+
/* Declarations required for unit testing. */
|
|
532
|
+
#ifdef TESTING
|
|
533
|
+
|
|
534
|
+
STATIC void _chartsheet_xml_declaration(lxw_chartsheet *chartsheet);
|
|
535
|
+
STATIC void _chartsheet_write_sheet_protection(lxw_chartsheet *chartsheet);
|
|
536
|
+
#endif /* TESTING */
|
|
537
|
+
|
|
538
|
+
/* *INDENT-OFF* */
|
|
539
|
+
#ifdef __cplusplus
|
|
540
|
+
}
|
|
541
|
+
#endif
|
|
542
|
+
/* *INDENT-ON* */
|
|
543
|
+
|
|
544
|
+
#endif /* __LXW_CHARTSHEET_H__ */
|