xlsxwriter 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +55 -5
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chartsheet.h +544 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +6 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +2 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +1 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +3 -1
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +7 -2
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +16 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +122 -24
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +236 -48
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +2 -0
- data/ext/xlsxwriter/libxlsxwriter/src/chart.c +40 -4
- data/ext/xlsxwriter/libxlsxwriter/src/chartsheet.c +508 -0
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +10 -0
- data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +100 -3
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +252 -30
- data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +16 -2
- data/ext/xlsxwriter/libxlsxwriter/src/styles.c +54 -7
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +43 -1
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +254 -41
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +381 -65
- data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +16 -7
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +10 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +2 -2
- data/ext/xlsxwriter/workbook.c +9 -6
- data/lib/xlsxwriter/version.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1006c5149aecad5096481659184650278b3c84edc11c2bc57be11511fc547887
|
4
|
+
data.tar.gz: b23c2ae64573d9cd68b12c0d7cf1012174270ab443be41a3c9a956786df9fe03
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d20d390898a083e74ad0f62757977a82ca6cf3b5218ea7c06c3ca3ffcd948dc2a37c4ded5256700fd94764e5302d22a3ec6346ccfdbce3d4bd963766428c1210
|
7
|
+
data.tar.gz: 4e6da916e8e9a97d8769d37f6cb1f84e9fe6151b8a3ee4cd4acef32cd061fe1d0ee3054a4a7fe8f360ae538fef1c648a4673b582952710d06fd36c92208b4053
|
@@ -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
|
/**
|
@@ -523,6 +529,20 @@ typedef enum lxw_chart_axis_label_position {
|
|
523
529
|
LXW_CHART_AXIS_LABEL_POSITION_NONE
|
524
530
|
} lxw_chart_axis_label_position;
|
525
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
|
+
|
526
546
|
/**
|
527
547
|
* @brief Display units for chart value axis.
|
528
548
|
*/
|
@@ -981,6 +1001,7 @@ typedef struct lxw_chart_axis {
|
|
981
1001
|
uint8_t axis_position;
|
982
1002
|
uint8_t position_axis;
|
983
1003
|
uint8_t label_position;
|
1004
|
+
uint8_t label_align;
|
984
1005
|
uint8_t hidden;
|
985
1006
|
uint8_t reverse;
|
986
1007
|
|
@@ -1048,6 +1069,7 @@ typedef struct lxw_chart {
|
|
1048
1069
|
uint8_t in_use;
|
1049
1070
|
uint8_t chart_group;
|
1050
1071
|
uint8_t cat_has_num_fmt;
|
1072
|
+
uint8_t is_chartsheet;
|
1051
1073
|
|
1052
1074
|
uint8_t has_horiz_cat_axis;
|
1053
1075
|
uint8_t has_horiz_val_axis;
|
@@ -1103,6 +1125,7 @@ typedef struct lxw_chart {
|
|
1103
1125
|
lxw_chart_fill *down_bar_fill;
|
1104
1126
|
|
1105
1127
|
uint8_t default_label_position;
|
1128
|
+
uint8_t is_protected;
|
1106
1129
|
|
1107
1130
|
STAILQ_ENTRY (lxw_chart) ordered_list_pointers;
|
1108
1131
|
STAILQ_ENTRY (lxw_chart) list_pointers;
|
@@ -1284,7 +1307,7 @@ void chart_series_set_values(lxw_chart_series *series, const char *sheetname,
|
|
1284
1307
|
* @code
|
1285
1308
|
* lxw_chart_series *series = chart_add_series(chart, NULL, "=Sheet1!$B$2:$B$7");
|
1286
1309
|
*
|
1287
|
-
* chart_series_set_name(series, "=Sheet1!$
|
1310
|
+
* chart_series_set_name(series, "=Sheet1!$B$1");
|
1288
1311
|
* @endcode
|
1289
1312
|
*
|
1290
1313
|
* See also the `chart_series_set_name_range()` function to see how to set the
|
@@ -2275,7 +2298,7 @@ lxw_chart_axis *chart_axis_get(lxw_chart *chart,
|
|
2275
2298
|
* a cell in the workbook that contains the name:
|
2276
2299
|
*
|
2277
2300
|
* @code
|
2278
|
-
* chart_axis_set_name(chart->x_axis, "=Sheet1!$
|
2301
|
+
* chart_axis_set_name(chart->x_axis, "=Sheet1!$B$1");
|
2279
2302
|
* @endcode
|
2280
2303
|
*
|
2281
2304
|
* See also the `chart_axis_set_name_range()` function to see how to set the
|
@@ -2567,7 +2590,7 @@ void chart_axis_set_position(lxw_chart_axis *axis, uint8_t position);
|
|
2567
2590
|
*
|
2568
2591
|
* @code
|
2569
2592
|
* chart_axis_set_label_position(chart->x_axis, LXW_CHART_AXIS_LABEL_POSITION_HIGH);
|
2570
|
-
|
2593
|
+
* chart_axis_set_label_position(chart->y_axis, LXW_CHART_AXIS_LABEL_POSITION_HIGH);
|
2571
2594
|
* @endcode
|
2572
2595
|
*
|
2573
2596
|
* @image html chart_label_position2.png
|
@@ -2590,6 +2613,31 @@ void chart_axis_set_position(lxw_chart_axis *axis, uint8_t position);
|
|
2590
2613
|
*/
|
2591
2614
|
void chart_axis_set_label_position(lxw_chart_axis *axis, uint8_t position);
|
2592
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
|
+
|
2593
2641
|
/**
|
2594
2642
|
* @brief Set the minimum value for a chart axis.
|
2595
2643
|
*
|
@@ -2958,7 +3006,7 @@ void chart_axis_minor_gridlines_set_line(lxw_chart_axis *axis,
|
|
2958
3006
|
* a cell in the workbook that contains the name:
|
2959
3007
|
*
|
2960
3008
|
* @code
|
2961
|
-
* chart_title_set_name(chart, "=Sheet1!$
|
3009
|
+
* chart_title_set_name(chart, "=Sheet1!$B$1");
|
2962
3010
|
* @endcode
|
2963
3011
|
*
|
2964
3012
|
* See also the `chart_title_set_name_range()` function to see how to set the
|
@@ -3040,8 +3088,10 @@ void chart_title_off(lxw_chart *chart);
|
|
3040
3088
|
* LXW_CHART_LEGEND_LEFT
|
3041
3089
|
* LXW_CHART_LEGEND_TOP
|
3042
3090
|
* LXW_CHART_LEGEND_BOTTOM
|
3091
|
+
* LXW_CHART_LEGEND_TOP_RIGHT
|
3043
3092
|
* LXW_CHART_LEGEND_OVERLAY_RIGHT
|
3044
3093
|
* LXW_CHART_LEGEND_OVERLAY_LEFT
|
3094
|
+
* LXW_CHART_LEGEND_OVERLAY_TOP_RIGHT
|
3045
3095
|
*
|
3046
3096
|
* For example:
|
3047
3097
|
*
|
@@ -0,0 +1,544 @@
|
|
1
|
+
/*
|
2
|
+
* libxlsxwriter
|
3
|
+
*
|
4
|
+
* Copyright 2014-2018, 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();
|
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__ */
|