xlsxwriter 0.0.2
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 +7 -0
- data/Rakefile +40 -0
- data/ext/xlsxwriter/chart.c +105 -0
- data/ext/xlsxwriter/chart.h +27 -0
- data/ext/xlsxwriter/extconf.rb +14 -0
- data/ext/xlsxwriter/format.c +67 -0
- data/ext/xlsxwriter/format.h +9 -0
- data/ext/xlsxwriter/libxlsxwriter/LICENSE.txt +89 -0
- data/ext/xlsxwriter/libxlsxwriter/Makefile +141 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter.h +23 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/app.h +79 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/chart.h +1093 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/common.h +336 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/content_types.h +74 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/core.h +51 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/custom.h +52 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/drawing.h +111 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/format.h +1214 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/hash_table.h +76 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/packager.h +80 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/relationships.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/shared_strings.h +83 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/styles.h +77 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/theme.h +47 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +215 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/queue.h +694 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/tree.h +801 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/third_party/zip.h +375 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/utility.h +166 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/workbook.h +751 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/worksheet.h +2641 -0
- data/ext/xlsxwriter/libxlsxwriter/include/xlsxwriter/xmlwriter.h +178 -0
- data/ext/xlsxwriter/libxlsxwriter/lib/.gitignore +0 -0
- data/ext/xlsxwriter/libxlsxwriter/src/Makefile +125 -0
- data/ext/xlsxwriter/libxlsxwriter/src/app.c +439 -0
- data/ext/xlsxwriter/libxlsxwriter/src/chart.c +3420 -0
- data/ext/xlsxwriter/libxlsxwriter/src/content_types.c +341 -0
- data/ext/xlsxwriter/libxlsxwriter/src/core.c +293 -0
- data/ext/xlsxwriter/libxlsxwriter/src/custom.c +224 -0
- data/ext/xlsxwriter/libxlsxwriter/src/drawing.c +746 -0
- data/ext/xlsxwriter/libxlsxwriter/src/format.c +728 -0
- data/ext/xlsxwriter/libxlsxwriter/src/hash_table.c +223 -0
- data/ext/xlsxwriter/libxlsxwriter/src/packager.c +877 -0
- data/ext/xlsxwriter/libxlsxwriter/src/relationships.c +242 -0
- data/ext/xlsxwriter/libxlsxwriter/src/shared_strings.c +264 -0
- data/ext/xlsxwriter/libxlsxwriter/src/styles.c +1086 -0
- data/ext/xlsxwriter/libxlsxwriter/src/theme.c +348 -0
- data/ext/xlsxwriter/libxlsxwriter/src/utility.c +512 -0
- data/ext/xlsxwriter/libxlsxwriter/src/workbook.c +1895 -0
- data/ext/xlsxwriter/libxlsxwriter/src/worksheet.c +4992 -0
- data/ext/xlsxwriter/libxlsxwriter/src/xmlwriter.c +355 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/Makefile +44 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/crypt.h +131 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.c +247 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/ioapi.h +209 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.c +456 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/iowin32.h +28 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/miniunz.c +660 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/minizip.c +520 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.c +291 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/mztools.h +37 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.c +2125 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/unzip.h +437 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.c +2007 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/minizip/zip.h +367 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/Makefile +42 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.c +342 -0
- data/ext/xlsxwriter/libxlsxwriter/third_party/tmpfileplus/tmpfileplus.h +53 -0
- data/ext/xlsxwriter/workbook.c +257 -0
- data/ext/xlsxwriter/workbook.h +42 -0
- data/ext/xlsxwriter/workbook_properties.c +103 -0
- data/ext/xlsxwriter/workbook_properties.h +10 -0
- data/ext/xlsxwriter/worksheet.c +1064 -0
- data/ext/xlsxwriter/worksheet.h +74 -0
- data/ext/xlsxwriter/xlsxwriter.c +239 -0
- data/lib/xlsxwriter.rb +6 -0
- data/lib/xlsxwriter/version.rb +3 -0
- data/lib/xlsxwriter/worksheet.rb +72 -0
- data/test/run-test.rb +11 -0
- data/test/support/xlsx_comparable.rb +109 -0
- data/test/test-array-formula.rb +33 -0
- data/test/test-autofilter.rb +70 -0
- data/test/test-chart-area.rb +25 -0
- data/test/test-data.rb +65 -0
- data/test/test-default-row.rb +25 -0
- data/test/test-defined-name.rb +46 -0
- data/test/test-escapes.rb +33 -0
- data/test/test-fit-to-pages.rb +21 -0
- data/test/test-formatting.rb +137 -0
- data/test/test-gridlines.rb +15 -0
- data/test/test-hyperlink.rb +67 -0
- data/test/test-image.rb +84 -0
- data/test/test-merge-range.rb +18 -0
- data/test/test-misc.rb +29 -0
- data/test/test-optimize.rb +32 -0
- data/test/test-page-breaks.rb +13 -0
- data/test/test-page-setup.rb +28 -0
- data/test/test-panes.rb +45 -0
- data/test/test-print-area.rb +19 -0
- data/test/test-print-options.rb +61 -0
- data/test/test-print-scale.rb +12 -0
- data/test/test-properties.rb +51 -0
- data/test/test-protect.rb +27 -0
- data/test/test-repeat.rb +23 -0
- data/test/test-row-col-format.rb +35 -0
- data/test/test-set-selection.rb +13 -0
- data/test/test-set-start-page.rb +13 -0
- data/test/test-simple.rb +62 -0
- data/test/test-types.rb +17 -0
- data/test/xlsx-func-testcase.rb +36 -0
- metadata +228 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* libxlsxwriter
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @file xlsxwriter.h
|
|
9
|
+
*
|
|
10
|
+
* xlsxwriter - A library for creating Excel XLSX files.
|
|
11
|
+
*
|
|
12
|
+
*/
|
|
13
|
+
#ifndef __LXW_XLSXWRITER_H__
|
|
14
|
+
#define __LXW_XLSXWRITER_H__
|
|
15
|
+
|
|
16
|
+
#include "xlsxwriter/workbook.h"
|
|
17
|
+
#include "xlsxwriter/worksheet.h"
|
|
18
|
+
#include "xlsxwriter/format.h"
|
|
19
|
+
#include "xlsxwriter/utility.h"
|
|
20
|
+
|
|
21
|
+
#define LXW_VERSION "0.4.6"
|
|
22
|
+
|
|
23
|
+
#endif /* __LXW_XLSXWRITER_H__ */
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* libxlsxwriter
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
5
|
+
*
|
|
6
|
+
* app - A libxlsxwriter library for creating Excel XLSX app files.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
#ifndef __LXW_APP_H__
|
|
10
|
+
#define __LXW_APP_H__
|
|
11
|
+
|
|
12
|
+
#include <stdint.h>
|
|
13
|
+
#include <string.h>
|
|
14
|
+
#include "xlsxwriter/workbook.h"
|
|
15
|
+
#include "xlsxwriter/common.h"
|
|
16
|
+
|
|
17
|
+
/* Define the queue.h TAILQ structs for the App structs. */
|
|
18
|
+
STAILQ_HEAD(lxw_heading_pairs, lxw_heading_pair);
|
|
19
|
+
STAILQ_HEAD(lxw_part_names, lxw_part_name);
|
|
20
|
+
|
|
21
|
+
typedef struct lxw_heading_pair {
|
|
22
|
+
|
|
23
|
+
char *key;
|
|
24
|
+
char *value;
|
|
25
|
+
|
|
26
|
+
STAILQ_ENTRY (lxw_heading_pair) list_pointers;
|
|
27
|
+
|
|
28
|
+
} lxw_heading_pair;
|
|
29
|
+
|
|
30
|
+
typedef struct lxw_part_name {
|
|
31
|
+
|
|
32
|
+
char *name;
|
|
33
|
+
|
|
34
|
+
STAILQ_ENTRY (lxw_part_name) list_pointers;
|
|
35
|
+
|
|
36
|
+
} lxw_part_name;
|
|
37
|
+
|
|
38
|
+
/* Struct to represent an App object. */
|
|
39
|
+
typedef struct lxw_app {
|
|
40
|
+
|
|
41
|
+
FILE *file;
|
|
42
|
+
|
|
43
|
+
struct lxw_heading_pairs *heading_pairs;
|
|
44
|
+
struct lxw_part_names *part_names;
|
|
45
|
+
lxw_doc_properties *properties;
|
|
46
|
+
|
|
47
|
+
uint32_t num_heading_pairs;
|
|
48
|
+
uint32_t num_part_names;
|
|
49
|
+
|
|
50
|
+
} lxw_app;
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
/* *INDENT-OFF* */
|
|
54
|
+
#ifdef __cplusplus
|
|
55
|
+
extern "C" {
|
|
56
|
+
#endif
|
|
57
|
+
/* *INDENT-ON* */
|
|
58
|
+
|
|
59
|
+
lxw_app *lxw_app_new();
|
|
60
|
+
void lxw_app_free(lxw_app *app);
|
|
61
|
+
void lxw_app_assemble_xml_file(lxw_app *self);
|
|
62
|
+
void lxw_app_add_part_name(lxw_app *self, const char *name);
|
|
63
|
+
void lxw_app_add_heading_pair(lxw_app *self, const char *key,
|
|
64
|
+
const char *value);
|
|
65
|
+
|
|
66
|
+
/* Declarations required for unit testing. */
|
|
67
|
+
#ifdef TESTING
|
|
68
|
+
|
|
69
|
+
STATIC void _app_xml_declaration(lxw_app *self);
|
|
70
|
+
|
|
71
|
+
#endif /* TESTING */
|
|
72
|
+
|
|
73
|
+
/* *INDENT-OFF* */
|
|
74
|
+
#ifdef __cplusplus
|
|
75
|
+
}
|
|
76
|
+
#endif
|
|
77
|
+
/* *INDENT-ON* */
|
|
78
|
+
|
|
79
|
+
#endif /* __LXW_APP_H__ */
|
|
@@ -0,0 +1,1093 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* libxlsxwriter
|
|
3
|
+
*
|
|
4
|
+
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org. See LICENSE.txt.
|
|
5
|
+
*
|
|
6
|
+
* chart - A libxlsxwriter library for creating Excel XLSX chart files.
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @page chart_page The Chart object
|
|
12
|
+
*
|
|
13
|
+
* The Chart object represents an Excel chart. It provides functions for
|
|
14
|
+
* adding data series to the chart and for configuring the chart.
|
|
15
|
+
*
|
|
16
|
+
* See @ref chart.h for full details of the functionality.
|
|
17
|
+
*
|
|
18
|
+
* @file chart.h
|
|
19
|
+
*
|
|
20
|
+
* @brief Functions related to adding data to and configuring a chart.
|
|
21
|
+
*
|
|
22
|
+
* The Chart object represents an Excel chart. It provides functions for
|
|
23
|
+
* adding data series to the chart and for configuring the chart.
|
|
24
|
+
*
|
|
25
|
+
* A Chart object isn't created directly. Instead a chart is created by
|
|
26
|
+
* calling the `workbook_add_chart()` function from a Workbook object. For
|
|
27
|
+
* example:
|
|
28
|
+
*
|
|
29
|
+
* @code
|
|
30
|
+
*
|
|
31
|
+
* #include "xlsxwriter.h"
|
|
32
|
+
*
|
|
33
|
+
* int main() {
|
|
34
|
+
*
|
|
35
|
+
* lxw_workbook *workbook = new_workbook("chart.xlsx");
|
|
36
|
+
* lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
|
37
|
+
*
|
|
38
|
+
* // User function to add data to worksheet, not shown here.
|
|
39
|
+
* write_worksheet_data(worksheet);
|
|
40
|
+
*
|
|
41
|
+
* // Create a chart object.
|
|
42
|
+
* lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
|
43
|
+
*
|
|
44
|
+
* // In the simplest case we just add some value data series.
|
|
45
|
+
* // The NULL categories will default to 1 to 5 like in Excel.
|
|
46
|
+
* chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5");
|
|
47
|
+
* chart_add_series(chart, NULL, "=Sheet1!$B$1:$B$5");
|
|
48
|
+
* chart_add_series(chart, NULL, "=Sheet1!$C$1:$C$5");
|
|
49
|
+
*
|
|
50
|
+
* // Insert the chart into the worksheet
|
|
51
|
+
* worksheet_insert_chart(worksheet, CELL("B7"), chart);
|
|
52
|
+
*
|
|
53
|
+
* return workbook_close(workbook);
|
|
54
|
+
* }
|
|
55
|
+
*
|
|
56
|
+
* @endcode
|
|
57
|
+
*
|
|
58
|
+
* The chart in the worksheet will look like this:
|
|
59
|
+
* @image html chart_simple.png
|
|
60
|
+
*
|
|
61
|
+
* The basic procedure for adding a chart to a worksheet is:
|
|
62
|
+
*
|
|
63
|
+
* 1. Create the chart with `workbook_add_chart()`.
|
|
64
|
+
* 2. Add one or more data series to the chart which refers to data in the
|
|
65
|
+
* workbook using `chart_add_series()`.
|
|
66
|
+
* 3. Configure the chart with the other available functions shown below.
|
|
67
|
+
* 4. Insert the chart into a worksheet using `worksheet_insert_chart()`.
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
#ifndef __LXW_CHART_H__
|
|
72
|
+
#define __LXW_CHART_H__
|
|
73
|
+
|
|
74
|
+
#include <stdint.h>
|
|
75
|
+
#include <string.h>
|
|
76
|
+
|
|
77
|
+
#include "common.h"
|
|
78
|
+
#include "format.h"
|
|
79
|
+
|
|
80
|
+
STAILQ_HEAD(lxw_chart_series_list, lxw_chart_series);
|
|
81
|
+
STAILQ_HEAD(lxw_series_data_points, lxw_series_data_point);
|
|
82
|
+
|
|
83
|
+
#define LXW_CHART_NUM_FORMAT_LEN 128
|
|
84
|
+
|
|
85
|
+
/** Available chart types . */
|
|
86
|
+
typedef enum lxw_chart_type {
|
|
87
|
+
|
|
88
|
+
/** None. */
|
|
89
|
+
LXW_CHART_NONE = 0,
|
|
90
|
+
|
|
91
|
+
/** Area chart. */
|
|
92
|
+
LXW_CHART_AREA,
|
|
93
|
+
|
|
94
|
+
/** Area chart - stacked. */
|
|
95
|
+
LXW_CHART_AREA_STACKED,
|
|
96
|
+
|
|
97
|
+
/** Area chart - percentage stacked. */
|
|
98
|
+
LXW_CHART_AREA_STACKED_PERCENT,
|
|
99
|
+
|
|
100
|
+
/** Bar chart. */
|
|
101
|
+
LXW_CHART_BAR,
|
|
102
|
+
|
|
103
|
+
/** Bar chart - stacked. */
|
|
104
|
+
LXW_CHART_BAR_STACKED,
|
|
105
|
+
|
|
106
|
+
/** Bar chart - percentage stacked. */
|
|
107
|
+
LXW_CHART_BAR_STACKED_PERCENT,
|
|
108
|
+
|
|
109
|
+
/** Column chart. */
|
|
110
|
+
LXW_CHART_COLUMN,
|
|
111
|
+
|
|
112
|
+
/** Column chart - stacked. */
|
|
113
|
+
LXW_CHART_COLUMN_STACKED,
|
|
114
|
+
|
|
115
|
+
/** Column chart - percentage stacked. */
|
|
116
|
+
LXW_CHART_COLUMN_STACKED_PERCENT,
|
|
117
|
+
|
|
118
|
+
/** Doughnut chart. */
|
|
119
|
+
LXW_CHART_DOUGHNUT,
|
|
120
|
+
|
|
121
|
+
/** Line chart. */
|
|
122
|
+
LXW_CHART_LINE,
|
|
123
|
+
|
|
124
|
+
/** Pie chart. */
|
|
125
|
+
LXW_CHART_PIE,
|
|
126
|
+
|
|
127
|
+
/** Scatter chart. */
|
|
128
|
+
LXW_CHART_SCATTER,
|
|
129
|
+
|
|
130
|
+
/** Scatter chart - straight. */
|
|
131
|
+
LXW_CHART_SCATTER_STRAIGHT,
|
|
132
|
+
|
|
133
|
+
/** Scatter chart - straight with markers. */
|
|
134
|
+
LXW_CHART_SCATTER_STRAIGHT_WITH_MARKERS,
|
|
135
|
+
|
|
136
|
+
/** Scatter chart - smooth. */
|
|
137
|
+
LXW_CHART_SCATTER_SMOOTH,
|
|
138
|
+
|
|
139
|
+
/** Scatter chart - smooth with markers. */
|
|
140
|
+
LXW_CHART_SCATTER_SMOOTH_WITH_MARKERS,
|
|
141
|
+
|
|
142
|
+
/** Radar chart. */
|
|
143
|
+
LXW_CHART_RADAR,
|
|
144
|
+
|
|
145
|
+
/** Radar chart - with markers. */
|
|
146
|
+
LXW_CHART_RADAR_WITH_MARKERS,
|
|
147
|
+
|
|
148
|
+
/** Radar chart - filled. */
|
|
149
|
+
LXW_CHART_RADAR_FILLED
|
|
150
|
+
} lxw_chart_type;
|
|
151
|
+
|
|
152
|
+
/** Chart legend positions. */
|
|
153
|
+
typedef enum lxw_chart_legend_position {
|
|
154
|
+
|
|
155
|
+
/** No chart legend. */
|
|
156
|
+
LXW_CHART_LEGEND_NONE = 0,
|
|
157
|
+
|
|
158
|
+
/** Chart legend positioned at right side. */
|
|
159
|
+
LXW_CHART_LEGEND_RIGHT,
|
|
160
|
+
|
|
161
|
+
/** Chart legend positioned at left side. */
|
|
162
|
+
LXW_CHART_LEGEND_LEFT,
|
|
163
|
+
|
|
164
|
+
/** Chart legend positioned at top. */
|
|
165
|
+
LXW_CHART_LEGEND_TOP,
|
|
166
|
+
|
|
167
|
+
/** Chart legend positioned at bottom. */
|
|
168
|
+
LXW_CHART_LEGEND_BOTTOM,
|
|
169
|
+
|
|
170
|
+
/** Chart legend overlaid at right side. */
|
|
171
|
+
LXW_CHART_LEGEND_OVERLAY_RIGHT,
|
|
172
|
+
|
|
173
|
+
/** Chart legend overlaid at left side. */
|
|
174
|
+
LXW_CHART_LEGEND_OVERLAY_LEFT
|
|
175
|
+
} lxw_chart_legend_position;
|
|
176
|
+
|
|
177
|
+
/** @brief Chart line dash types.
|
|
178
|
+
*
|
|
179
|
+
* The dash types are shown in the order that they appear in the Excel dialog.
|
|
180
|
+
* See @ref chart_lines.
|
|
181
|
+
*/
|
|
182
|
+
typedef enum lxw_chart_line_dash_type {
|
|
183
|
+
|
|
184
|
+
/** Solid. */
|
|
185
|
+
LXW_CHART_LINE_DASH_SOLID = 0,
|
|
186
|
+
|
|
187
|
+
/** Round Dot. */
|
|
188
|
+
LXW_CHART_LINE_DASH_ROUND_DOT,
|
|
189
|
+
|
|
190
|
+
/** Square Dot. */
|
|
191
|
+
LXW_CHART_LINE_DASH_SQUARE_DOT,
|
|
192
|
+
|
|
193
|
+
/** Dash. */
|
|
194
|
+
LXW_CHART_LINE_DASH_DASH,
|
|
195
|
+
|
|
196
|
+
/** Dash Dot. */
|
|
197
|
+
LXW_CHART_LINE_DASH_DASH_DOT,
|
|
198
|
+
|
|
199
|
+
/** Long Dash. */
|
|
200
|
+
LXW_CHART_LINE_DASH_LONG_DASH,
|
|
201
|
+
|
|
202
|
+
/** Long Dash Dot. */
|
|
203
|
+
LXW_CHART_LINE_DASH_LONG_DASH_DOT,
|
|
204
|
+
|
|
205
|
+
/** Long Dash Dot Dot. */
|
|
206
|
+
LXW_CHART_LINE_DASH_LONG_DASH_DOT_DOT,
|
|
207
|
+
|
|
208
|
+
/* These aren't available in the dialog but are used by Excel. */
|
|
209
|
+
LXW_CHART_LINE_DASH_DOT,
|
|
210
|
+
LXW_CHART_LINE_DASH_SYSTEM_DASH_DOT,
|
|
211
|
+
LXW_CHART_LINE_DASH_SYSTEM_DASH_DOT_DOT
|
|
212
|
+
|
|
213
|
+
} lxw_chart_liLINE_ne_dash_type;
|
|
214
|
+
|
|
215
|
+
enum lxw_chart_subtype {
|
|
216
|
+
|
|
217
|
+
LXW_CHART_SUBTYPE_NONE = 0,
|
|
218
|
+
LXW_CHART_SUBTYPE_STACKED,
|
|
219
|
+
LXW_CHART_SUBTYPE_STACKED_PERCENT
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
enum lxw_chart_grouping {
|
|
223
|
+
LXW_GROUPING_CLUSTERED,
|
|
224
|
+
LXW_GROUPING_STANDARD,
|
|
225
|
+
LXW_GROUPING_PERCENTSTACKED,
|
|
226
|
+
LXW_GROUPING_STACKED
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
enum lxw_chart_axis_tick_position {
|
|
230
|
+
LXW_CHART_AXIS_POSITION_BETWEEN,
|
|
231
|
+
LXW_CHART_AXIS_POSITION_ON_TICK
|
|
232
|
+
};
|
|
233
|
+
|
|
234
|
+
enum lxw_chart_position {
|
|
235
|
+
LXW_CHART_AXIS_RIGHT,
|
|
236
|
+
LXW_CHART_AXIS_LEFT,
|
|
237
|
+
LXW_CHART_AXIS_TOP,
|
|
238
|
+
LXW_CHART_AXIS_BOTTOM
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
typedef struct lxw_series_range {
|
|
242
|
+
char *formula;
|
|
243
|
+
char *sheetname;
|
|
244
|
+
lxw_row_t first_row;
|
|
245
|
+
lxw_row_t last_row;
|
|
246
|
+
lxw_col_t first_col;
|
|
247
|
+
lxw_col_t last_col;
|
|
248
|
+
uint8_t ignore_cache;
|
|
249
|
+
|
|
250
|
+
uint8_t has_string_cache;
|
|
251
|
+
uint16_t num_data_points;
|
|
252
|
+
struct lxw_series_data_points *data_cache;
|
|
253
|
+
|
|
254
|
+
} lxw_series_range;
|
|
255
|
+
|
|
256
|
+
typedef struct lxw_series_data_point {
|
|
257
|
+
uint8_t is_string;
|
|
258
|
+
double number;
|
|
259
|
+
char *string;
|
|
260
|
+
uint8_t no_data;
|
|
261
|
+
|
|
262
|
+
STAILQ_ENTRY (lxw_series_data_point) list_pointers;
|
|
263
|
+
|
|
264
|
+
} lxw_series_data_point;
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* @brief Struct to represent a chart line.
|
|
268
|
+
*
|
|
269
|
+
* See @ref chart_lines.
|
|
270
|
+
*/
|
|
271
|
+
typedef struct lxw_chart_line {
|
|
272
|
+
|
|
273
|
+
/** The chart font color. See @ref working_with_colors. */
|
|
274
|
+
lxw_color_t color;
|
|
275
|
+
|
|
276
|
+
/** Turn off/hide line. Set to 0 or 1.*/
|
|
277
|
+
uint8_t none;
|
|
278
|
+
|
|
279
|
+
/** Width of the line in increments of 0.25. Default is 2.25. */
|
|
280
|
+
float width;
|
|
281
|
+
|
|
282
|
+
/** The line dash type. See #lxw_chart_line_dash_type. */
|
|
283
|
+
uint8_t dash_type;
|
|
284
|
+
|
|
285
|
+
/* Transparency for lines isn't generally useful. Undocumented for now. */
|
|
286
|
+
uint8_t transparency;
|
|
287
|
+
|
|
288
|
+
/* Members for internal use only. */
|
|
289
|
+
uint8_t has_color;
|
|
290
|
+
|
|
291
|
+
} lxw_chart_line;
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* @brief Struct to represent a chart line.
|
|
295
|
+
*
|
|
296
|
+
* See @ref chart_fills.
|
|
297
|
+
*/
|
|
298
|
+
typedef struct lxw_chart_fill {
|
|
299
|
+
|
|
300
|
+
/** The chart font color. See @ref working_with_colors. */
|
|
301
|
+
lxw_color_t color;
|
|
302
|
+
|
|
303
|
+
/** Turn off/hide line. Set to 0 or 1.*/
|
|
304
|
+
uint8_t none;
|
|
305
|
+
|
|
306
|
+
/** Set the transparency of the fill. 0 - 100. Default 0. */
|
|
307
|
+
uint8_t transparency;
|
|
308
|
+
|
|
309
|
+
/* Members for internal use only. */
|
|
310
|
+
uint8_t has_color;
|
|
311
|
+
|
|
312
|
+
} lxw_chart_fill;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* @brief Struct to represent a chart font.
|
|
316
|
+
*
|
|
317
|
+
* See @ref chart_fonts.
|
|
318
|
+
*/
|
|
319
|
+
typedef struct lxw_chart_font {
|
|
320
|
+
|
|
321
|
+
/** The chart font name, such as "Arial" or "Calibri". */
|
|
322
|
+
char *name;
|
|
323
|
+
|
|
324
|
+
/** The chart font size. The default is 11. */
|
|
325
|
+
uint16_t size;
|
|
326
|
+
|
|
327
|
+
/** The chart font bold property. Set to 0 or 1. */
|
|
328
|
+
uint8_t bold;
|
|
329
|
+
|
|
330
|
+
/** The chart font italic property. Set to 0 or 1. */
|
|
331
|
+
uint8_t italic;
|
|
332
|
+
|
|
333
|
+
/** The chart font underline property. Set to 0 or 1. */
|
|
334
|
+
uint8_t underline;
|
|
335
|
+
|
|
336
|
+
/** The chart font rotation property. Range: -90 to 90. */
|
|
337
|
+
int32_t rotation;
|
|
338
|
+
|
|
339
|
+
/** The chart font color. See @ref working_with_colors. */
|
|
340
|
+
lxw_color_t color;
|
|
341
|
+
|
|
342
|
+
/* Members for internal use only. */
|
|
343
|
+
uint8_t pitch_family;
|
|
344
|
+
uint8_t charset;
|
|
345
|
+
int8_t baseline;
|
|
346
|
+
uint8_t has_color;
|
|
347
|
+
|
|
348
|
+
} lxw_chart_font;
|
|
349
|
+
|
|
350
|
+
typedef struct lxw_chart_legend {
|
|
351
|
+
|
|
352
|
+
lxw_chart_font *font;
|
|
353
|
+
uint8_t position;
|
|
354
|
+
|
|
355
|
+
} lxw_chart_legend;
|
|
356
|
+
|
|
357
|
+
typedef struct lxw_chart_title {
|
|
358
|
+
|
|
359
|
+
char *name;
|
|
360
|
+
lxw_row_t row;
|
|
361
|
+
lxw_col_t col;
|
|
362
|
+
lxw_chart_font *font;
|
|
363
|
+
uint8_t off;
|
|
364
|
+
uint8_t is_horizontal;
|
|
365
|
+
uint8_t ignore_cache;
|
|
366
|
+
|
|
367
|
+
/* We use a range to hold the title formula properties even though it
|
|
368
|
+
* will only have 1 point in order to re-use similar functions.*/
|
|
369
|
+
lxw_series_range *range;
|
|
370
|
+
|
|
371
|
+
struct lxw_series_data_point data_point;
|
|
372
|
+
|
|
373
|
+
} lxw_chart_title;
|
|
374
|
+
|
|
375
|
+
/**
|
|
376
|
+
* @brief Struct to represent an Excel chart data series.
|
|
377
|
+
*
|
|
378
|
+
* The lxw_chart_series is created using the chart_add_series function. It is
|
|
379
|
+
* used in functions that modify a chart series but the members of the struct
|
|
380
|
+
* aren't modified directly.
|
|
381
|
+
*/
|
|
382
|
+
typedef struct lxw_chart_series {
|
|
383
|
+
|
|
384
|
+
lxw_series_range *categories;
|
|
385
|
+
lxw_series_range *values;
|
|
386
|
+
lxw_chart_title title;
|
|
387
|
+
lxw_chart_line *line;
|
|
388
|
+
lxw_chart_fill *fill;
|
|
389
|
+
|
|
390
|
+
STAILQ_ENTRY (lxw_chart_series) list_pointers;
|
|
391
|
+
|
|
392
|
+
} lxw_chart_series;
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* @brief Struct to represent an Excel chart axis.
|
|
396
|
+
*
|
|
397
|
+
* The lxw_chart_axis struct is used in functions that modify a chart axis
|
|
398
|
+
* but the members of the struct aren't modified directly.
|
|
399
|
+
*/
|
|
400
|
+
typedef struct lxw_chart_axis {
|
|
401
|
+
|
|
402
|
+
lxw_chart_title title;
|
|
403
|
+
|
|
404
|
+
char num_format[LXW_CHART_NUM_FORMAT_LEN];
|
|
405
|
+
char default_num_format[LXW_CHART_NUM_FORMAT_LEN];
|
|
406
|
+
|
|
407
|
+
uint8_t default_major_gridlines;
|
|
408
|
+
uint8_t major_tick_mark;
|
|
409
|
+
uint8_t is_horizontal;
|
|
410
|
+
|
|
411
|
+
lxw_chart_font *num_font;
|
|
412
|
+
lxw_chart_line *line;
|
|
413
|
+
lxw_chart_fill *fill;
|
|
414
|
+
|
|
415
|
+
} lxw_chart_axis;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* @brief Struct to represent an Excel chart.
|
|
419
|
+
*
|
|
420
|
+
* The members of the lxw_chart struct aren't modified directly. Instead
|
|
421
|
+
* the chart properties are set by calling the functions shown in chart.h.
|
|
422
|
+
*/
|
|
423
|
+
typedef struct lxw_chart {
|
|
424
|
+
|
|
425
|
+
FILE *file;
|
|
426
|
+
|
|
427
|
+
uint8_t type;
|
|
428
|
+
uint8_t subtype;
|
|
429
|
+
uint16_t series_index;
|
|
430
|
+
|
|
431
|
+
void (*write_chart_type) (struct lxw_chart *);
|
|
432
|
+
void (*write_plot_area) (struct lxw_chart *);
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* A pointer to the chart x_axis object which can be used in functions
|
|
436
|
+
* that configures the X axis.
|
|
437
|
+
*/
|
|
438
|
+
lxw_chart_axis *x_axis;
|
|
439
|
+
|
|
440
|
+
/**
|
|
441
|
+
* A pointer to the chart y_axis object which can be used in functions
|
|
442
|
+
* that configures the Y axis.
|
|
443
|
+
*/
|
|
444
|
+
lxw_chart_axis *y_axis;
|
|
445
|
+
|
|
446
|
+
lxw_chart_title title;
|
|
447
|
+
|
|
448
|
+
uint32_t id;
|
|
449
|
+
uint32_t axis_id_1;
|
|
450
|
+
uint32_t axis_id_2;
|
|
451
|
+
uint32_t axis_id_3;
|
|
452
|
+
uint32_t axis_id_4;
|
|
453
|
+
|
|
454
|
+
uint8_t in_use;
|
|
455
|
+
uint8_t is_scatter;
|
|
456
|
+
uint8_t cat_has_num_fmt;
|
|
457
|
+
|
|
458
|
+
uint8_t has_horiz_cat_axis;
|
|
459
|
+
uint8_t has_horiz_val_axis;
|
|
460
|
+
|
|
461
|
+
uint8_t style_id;
|
|
462
|
+
uint16_t rotation;
|
|
463
|
+
uint16_t hole_size;
|
|
464
|
+
|
|
465
|
+
uint8_t no_title;
|
|
466
|
+
uint8_t has_markers;
|
|
467
|
+
uint8_t has_overlap;
|
|
468
|
+
int series_overlap_1;
|
|
469
|
+
|
|
470
|
+
uint8_t grouping;
|
|
471
|
+
uint8_t cross_between;
|
|
472
|
+
uint8_t cat_axis_position;
|
|
473
|
+
uint8_t val_axis_position;
|
|
474
|
+
|
|
475
|
+
lxw_chart_legend legend;
|
|
476
|
+
int16_t *delete_series;
|
|
477
|
+
uint16_t delete_series_count;
|
|
478
|
+
|
|
479
|
+
struct lxw_chart_series_list *series_list;
|
|
480
|
+
|
|
481
|
+
STAILQ_ENTRY (lxw_chart) ordered_list_pointers;
|
|
482
|
+
STAILQ_ENTRY (lxw_chart) list_pointers;
|
|
483
|
+
|
|
484
|
+
} lxw_chart;
|
|
485
|
+
|
|
486
|
+
|
|
487
|
+
/* *INDENT-OFF* */
|
|
488
|
+
#ifdef __cplusplus
|
|
489
|
+
extern "C" {
|
|
490
|
+
#endif
|
|
491
|
+
/* *INDENT-ON* */
|
|
492
|
+
|
|
493
|
+
lxw_chart *lxw_chart_new(uint8_t type);
|
|
494
|
+
void lxw_chart_free(lxw_chart *chart);
|
|
495
|
+
void lxw_chart_assemble_xml_file(lxw_chart *chart);
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* @brief Add a data series to a chart.
|
|
499
|
+
*
|
|
500
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
501
|
+
* @param categories The range of categories in the data series.
|
|
502
|
+
* @param values The range of values in the data series.
|
|
503
|
+
*
|
|
504
|
+
* @return A lxw_chart_series object pointer.
|
|
505
|
+
*
|
|
506
|
+
* In Excel a chart **series** is a collection of information that defines
|
|
507
|
+
* which data is plotted such as the categories and values. It is also used to
|
|
508
|
+
* define the formatting for the data.
|
|
509
|
+
*
|
|
510
|
+
* For an libxlsxwriter chart object the `%chart_add_series()` function is
|
|
511
|
+
* used to set the categories and values of the series:
|
|
512
|
+
*
|
|
513
|
+
* @code
|
|
514
|
+
* chart_add_series(chart, "=Sheet1!$A$2:$A$7", "=Sheet1!$C$2:$C$7");
|
|
515
|
+
* @endcode
|
|
516
|
+
*
|
|
517
|
+
*
|
|
518
|
+
* The series parameters are:
|
|
519
|
+
*
|
|
520
|
+
* - `categories`: This sets the chart category labels. The category is more
|
|
521
|
+
* or less the same as the X axis. In most Excel chart types the
|
|
522
|
+
* `categories` property is optional and the chart will just assume a
|
|
523
|
+
* sequential series from `1..n`:
|
|
524
|
+
*
|
|
525
|
+
* @code
|
|
526
|
+
* // The NULL category will default to 1 to 5 like in Excel.
|
|
527
|
+
* chart_add_series(chart, NULL, "Sheet1!$A$1:$A$5");
|
|
528
|
+
* @endcode
|
|
529
|
+
*
|
|
530
|
+
* - `values`: This is the most important property of a series and is the
|
|
531
|
+
* only mandatory option for every chart object. This parameter links the
|
|
532
|
+
* chart with the worksheet data that it displays.
|
|
533
|
+
*
|
|
534
|
+
* The `categories` and `values` should be a string formula like
|
|
535
|
+
* `"=Sheet1!$A$2:$A$7"` in the same way it is represented in Excel. This is
|
|
536
|
+
* convenient when recreating a chart from an example in Excel but it is
|
|
537
|
+
* trickier to generate programmatically. For these cases you can set the
|
|
538
|
+
* `categories` and `values` to `NULL` and use the
|
|
539
|
+
* `chart_series_set_categories()` and `chart_series_set_values()` functions:
|
|
540
|
+
*
|
|
541
|
+
* @code
|
|
542
|
+
* lxw_chart_series *series = chart_add_series(chart, NULL, NULL);
|
|
543
|
+
*
|
|
544
|
+
* // Configure the series using a syntax that is easier to define programmatically.
|
|
545
|
+
* chart_series_set_categories(series, "Sheet1", 1, 0, 6, 0); // "=Sheet1!$A$2:$A$7"
|
|
546
|
+
* chart_series_set_values( series, "Sheet1", 1, 2, 6, 2); // "=Sheet1!$C$2:$C$7"
|
|
547
|
+
* @endcode
|
|
548
|
+
*
|
|
549
|
+
* As shown in the previous example the return value from
|
|
550
|
+
* `%chart_add_series()` is a lxw_chart_series pointer. This can be used in
|
|
551
|
+
* other functions that configure a series.
|
|
552
|
+
*
|
|
553
|
+
*
|
|
554
|
+
* More than one series can be added to a chart. The series numbering and
|
|
555
|
+
* order in the Excel chart will be the same as the order in which they are
|
|
556
|
+
* added in libxlsxwriter:
|
|
557
|
+
*
|
|
558
|
+
* @code
|
|
559
|
+
* chart_add_series(chart, NULL, "Sheet1!$A$1:$A$5");
|
|
560
|
+
* chart_add_series(chart, NULL, "Sheet1!$B$1:$B$5");
|
|
561
|
+
* chart_add_series(chart, NULL, "Sheet1!$C$1:$C$5");
|
|
562
|
+
* @endcode
|
|
563
|
+
*
|
|
564
|
+
* It is also possible to specify non-contiguous ranges:
|
|
565
|
+
*
|
|
566
|
+
* @code
|
|
567
|
+
* chart_add_series(
|
|
568
|
+
* chart,
|
|
569
|
+
* "=(Sheet1!$A$1:$A$9,Sheet1!$A$14:$A$25)",
|
|
570
|
+
* "=(Sheet1!$B$1:$B$9,Sheet1!$B$14:$B$25)"
|
|
571
|
+
* );
|
|
572
|
+
* @endcode
|
|
573
|
+
*
|
|
574
|
+
*/
|
|
575
|
+
lxw_chart_series *chart_add_series(lxw_chart *chart,
|
|
576
|
+
const char *categories,
|
|
577
|
+
const char *values);
|
|
578
|
+
|
|
579
|
+
/**
|
|
580
|
+
* @brief Set a series "categories" range using row and column values.
|
|
581
|
+
*
|
|
582
|
+
* @param series A series object created via `chart_add_series()`.
|
|
583
|
+
* @param sheetname The name of the worksheet that contains the data range.
|
|
584
|
+
* @param first_row The first row of the range. (All zero indexed.)
|
|
585
|
+
* @param first_col The first column of the range.
|
|
586
|
+
* @param last_row The last row of the range.
|
|
587
|
+
* @param last_col The last col of the range.
|
|
588
|
+
*
|
|
589
|
+
* The `categories` and `values` of a chart data series are generally set
|
|
590
|
+
* using the `chart_add_series()` function and Excel range formulas like
|
|
591
|
+
* `"=Sheet1!$A$2:$A$7"`.
|
|
592
|
+
*
|
|
593
|
+
* The `%chart_series_set_categories()` function is an alternative method that
|
|
594
|
+
* is easier to generate programmatically. It requires that you set the
|
|
595
|
+
* `categories` and `values` parameters in `chart_add_series()`to `NULL` and
|
|
596
|
+
* then set them using row and column values in
|
|
597
|
+
* `chart_series_set_categories()` and `chart_series_set_values()`:
|
|
598
|
+
*
|
|
599
|
+
* @code
|
|
600
|
+
* lxw_chart_series *series = chart_add_series(chart, NULL, NULL);
|
|
601
|
+
*
|
|
602
|
+
* // Configure the series ranges programmatically.
|
|
603
|
+
* chart_series_set_categories(series, "Sheet1", 1, 0, 6, 0); // "=Sheet1!$A$2:$A$7"
|
|
604
|
+
* chart_series_set_values( series, "Sheet1", 1, 2, 6, 2); // "=Sheet1!$C$2:$C$7"
|
|
605
|
+
* @endcode
|
|
606
|
+
*
|
|
607
|
+
*/
|
|
608
|
+
void chart_series_set_categories(lxw_chart_series *series,
|
|
609
|
+
const char *sheetname, lxw_row_t first_row,
|
|
610
|
+
lxw_col_t first_col, lxw_row_t last_row,
|
|
611
|
+
lxw_col_t last_col);
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* @brief Set a series "values" range using row and column values.
|
|
615
|
+
*
|
|
616
|
+
* @param series A series object created via `chart_add_series()`.
|
|
617
|
+
* @param sheetname The name of the worksheet that contains the data range.
|
|
618
|
+
* @param first_row The first row of the range. (All zero indexed.)
|
|
619
|
+
* @param first_col The first column of the range.
|
|
620
|
+
* @param last_row The last row of the range.
|
|
621
|
+
* @param last_col The last col of the range.
|
|
622
|
+
*
|
|
623
|
+
* The `categories` and `values` of a chart data series are generally set
|
|
624
|
+
* using the `chart_add_series()` function and Excel range formulas like
|
|
625
|
+
* `"=Sheet1!$A$2:$A$7"`.
|
|
626
|
+
*
|
|
627
|
+
* The `%chart_series_set_values()` function is an alternative method that is
|
|
628
|
+
* easier to generate programmatically. See the documentation for
|
|
629
|
+
* `chart_series_set_categories()` above.
|
|
630
|
+
*/
|
|
631
|
+
void chart_series_set_values(lxw_chart_series *series, const char *sheetname,
|
|
632
|
+
lxw_row_t first_row, lxw_col_t first_col,
|
|
633
|
+
lxw_row_t last_row, lxw_col_t last_col);
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* @brief Set the name of a chart series range.
|
|
637
|
+
*
|
|
638
|
+
* @param series A series object created via `chart_add_series()`.
|
|
639
|
+
* @param name The series name.
|
|
640
|
+
*
|
|
641
|
+
* The `%chart_series_set_name` function is used to set the name for a chart
|
|
642
|
+
* data series. The series name in Excel is displayed in the chart legend and
|
|
643
|
+
* in the formula bar. The name property is optional and if it isn't supplied
|
|
644
|
+
* it will default to `Series 1..n`.
|
|
645
|
+
*
|
|
646
|
+
* The function applies to a #lxw_chart_series object created using
|
|
647
|
+
* `chart_add_series()`:
|
|
648
|
+
*
|
|
649
|
+
* @code
|
|
650
|
+
* lxw_chart_series *series = chart_add_series(chart, NULL, "=Sheet1!$B$2:$B$7");
|
|
651
|
+
*
|
|
652
|
+
* chart_series_set_name(series, "Quarterly budget data");
|
|
653
|
+
* @endcode
|
|
654
|
+
*
|
|
655
|
+
* The name parameter can also be a formula such as `=Sheet1!$A$1` to point to
|
|
656
|
+
* a cell in the workbook that contains the name:
|
|
657
|
+
*
|
|
658
|
+
* @code
|
|
659
|
+
* lxw_chart_series *series = chart_add_series(chart, NULL, "=Sheet1!$B$2:$B$7");
|
|
660
|
+
*
|
|
661
|
+
* chart_series_set_name(series, "=Sheet1!$B1$1");
|
|
662
|
+
* @endcode
|
|
663
|
+
*
|
|
664
|
+
* See also the `chart_series_set_name_range()` function to see how to set the
|
|
665
|
+
* name formula programmatically.
|
|
666
|
+
*/
|
|
667
|
+
void chart_series_set_name(lxw_chart_series *series, const char *name);
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* @brief Set a series name formula using row and column values.
|
|
671
|
+
*
|
|
672
|
+
* @param series A series object created via `chart_add_series()`.
|
|
673
|
+
* @param sheetname The name of the worksheet that contains the cell range.
|
|
674
|
+
* @param row The zero indexed row number of the range.
|
|
675
|
+
* @param col The zero indexed column number of the range.
|
|
676
|
+
*
|
|
677
|
+
* The `%chart_series_set_name_range()` function can be used to set a series
|
|
678
|
+
* name range and is an alternative to using `chart_series_set_name()` and a
|
|
679
|
+
* string formula:
|
|
680
|
+
*
|
|
681
|
+
* @code
|
|
682
|
+
* lxw_chart_series *series = chart_add_series(chart, NULL, "=Sheet1!$B$2:$B$7");
|
|
683
|
+
*
|
|
684
|
+
* chart_series_set_name_range(series, "Sheet1", 0, 2); // "=Sheet1!$C$1"
|
|
685
|
+
* @endcode
|
|
686
|
+
*/
|
|
687
|
+
void chart_series_set_name_range(lxw_chart_series *series,
|
|
688
|
+
const char *sheetname, lxw_row_t row,
|
|
689
|
+
lxw_col_t col);
|
|
690
|
+
/**
|
|
691
|
+
* @brief Set the line properties for a chart series.
|
|
692
|
+
*
|
|
693
|
+
* @param series A series object created via `chart_add_series()`.
|
|
694
|
+
* @param line A #lxw_chart_line struct.
|
|
695
|
+
*
|
|
696
|
+
* Set the line/border properties of a chart series:
|
|
697
|
+
*
|
|
698
|
+
* @code
|
|
699
|
+
* lxw_chart_line line = {.color = LXW_COLOR_RED};
|
|
700
|
+
*
|
|
701
|
+
* chart_series_set_line(series1, &line);
|
|
702
|
+
* chart_series_set_line(series2, &line);
|
|
703
|
+
* chart_series_set_line(series3, &line);
|
|
704
|
+
* @endcode
|
|
705
|
+
*
|
|
706
|
+
* @image html chart_series_set_line.png
|
|
707
|
+
*
|
|
708
|
+
* For more information see @ref chart_lines.
|
|
709
|
+
*/
|
|
710
|
+
void chart_series_set_line(lxw_chart_series *series, lxw_chart_line *line);
|
|
711
|
+
|
|
712
|
+
/**
|
|
713
|
+
* @brief Set the fill properties for a chart series.
|
|
714
|
+
*
|
|
715
|
+
* @param series A series object created via `chart_add_series()`.
|
|
716
|
+
* @param fill A #lxw_chart_fill struct.
|
|
717
|
+
*
|
|
718
|
+
* Set the fill properties of a chart series:
|
|
719
|
+
*
|
|
720
|
+
* @code
|
|
721
|
+
* lxw_chart_fill fill1 = {.color = LXW_COLOR_RED};
|
|
722
|
+
* lxw_chart_fill fill2 = {.color = LXW_COLOR_YELLOW};
|
|
723
|
+
* lxw_chart_fill fill3 = {.color = LXW_COLOR_GREEN};
|
|
724
|
+
*
|
|
725
|
+
* chart_series_set_fill(series1, &fill1);
|
|
726
|
+
* chart_series_set_fill(series2, &fill2);
|
|
727
|
+
* chart_series_set_fill(series3, &fill3);
|
|
728
|
+
* @endcode
|
|
729
|
+
*
|
|
730
|
+
* @image html chart_series_set_fill.png
|
|
731
|
+
*
|
|
732
|
+
* For more information see @ref chart_fills.
|
|
733
|
+
*/
|
|
734
|
+
void chart_series_set_fill(lxw_chart_series *series, lxw_chart_fill *fill);
|
|
735
|
+
|
|
736
|
+
/**
|
|
737
|
+
* @brief Set the name caption of the an axis.
|
|
738
|
+
*
|
|
739
|
+
* @param axis A pointer to a chart #lxw_chart_axis object.
|
|
740
|
+
* @param name The name caption of the axis.
|
|
741
|
+
*
|
|
742
|
+
* The `%chart_axis_set_name()` function sets the name (also known as title or
|
|
743
|
+
* caption) for an axis. It can be used for the X or Y axes. The name is
|
|
744
|
+
* displayed below an X axis and to the side of a Y axis.
|
|
745
|
+
*
|
|
746
|
+
* @code
|
|
747
|
+
* chart_axis_set_name(chart->x_axis, "Earnings per Quarter");
|
|
748
|
+
* chart_axis_set_name(chart->y_axis, "US Dollars (Millions)");
|
|
749
|
+
* @endcode
|
|
750
|
+
*
|
|
751
|
+
* @image html chart_axis_set_name.png
|
|
752
|
+
*
|
|
753
|
+
* The name parameter can also be a formula such as `=Sheet1!$A$1` to point to
|
|
754
|
+
* a cell in the workbook that contains the name:
|
|
755
|
+
*
|
|
756
|
+
* @code
|
|
757
|
+
* chart_axis_set_name(chart->x_axis, "=Sheet1!$B1$1");
|
|
758
|
+
* @endcode
|
|
759
|
+
*
|
|
760
|
+
* See also the `chart_axis_set_name_range()` function to see how to set the
|
|
761
|
+
* name formula programmatically.
|
|
762
|
+
*
|
|
763
|
+
* This function is applicable to category, date and value axes.
|
|
764
|
+
*/
|
|
765
|
+
void chart_axis_set_name(lxw_chart_axis *axis, const char *name);
|
|
766
|
+
|
|
767
|
+
/**
|
|
768
|
+
* @brief Set a chart axis name formula using row and column values.
|
|
769
|
+
*
|
|
770
|
+
* @param axis A pointer to a chart #lxw_chart_axis object.
|
|
771
|
+
* @param sheetname The name of the worksheet that contains the cell range.
|
|
772
|
+
* @param row The zero indexed row number of the range.
|
|
773
|
+
* @param col The zero indexed column number of the range.
|
|
774
|
+
*
|
|
775
|
+
* The `%chart_axis_set_name_range()` function can be used to set an axis name
|
|
776
|
+
* range and is an alternative to using `chart_axis_set_name()` and a string
|
|
777
|
+
* formula:
|
|
778
|
+
*
|
|
779
|
+
* @code
|
|
780
|
+
* chart_axis_set_name_range(chart->x_axis, "Sheet1", 1, 0);
|
|
781
|
+
* chart_axis_set_name_range(chart->y_axis, "Sheet1", 2, 0);
|
|
782
|
+
* @endcode
|
|
783
|
+
*/
|
|
784
|
+
void chart_axis_set_name_range(lxw_chart_axis *axis, const char *sheetname,
|
|
785
|
+
lxw_row_t row, lxw_col_t col);
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* @brief Set the font properties for a chart axis name.
|
|
789
|
+
*
|
|
790
|
+
* @param axis A pointer to a chart #lxw_chart_axis object.
|
|
791
|
+
* @param font A pointer to a chart #lxw_chart_font font struct.
|
|
792
|
+
*
|
|
793
|
+
* The `%chart_axis_set_name_font()` function is used to set the font of an
|
|
794
|
+
* axis name:
|
|
795
|
+
*
|
|
796
|
+
* @code
|
|
797
|
+
* lxw_chart_font font = {.bold = LXW_TRUE, .color = LXW_COLOR_BLUE};
|
|
798
|
+
*
|
|
799
|
+
* chart_axis_set_name(chart->x_axis, "Yearly data");
|
|
800
|
+
* chart_axis_set_name_font(chart->x_axis, &font);
|
|
801
|
+
* @endcode
|
|
802
|
+
*
|
|
803
|
+
* @image html chart_axis_set_name_font.png
|
|
804
|
+
*
|
|
805
|
+
* For more information see @ref chart_fonts.
|
|
806
|
+
*/
|
|
807
|
+
void chart_axis_set_name_font(lxw_chart_axis *axis, lxw_chart_font *font);
|
|
808
|
+
|
|
809
|
+
/**
|
|
810
|
+
* @brief Set the font properties for the numbers of a chart axis.
|
|
811
|
+
*
|
|
812
|
+
* @param axis A pointer to a chart #lxw_chart_axis object.
|
|
813
|
+
* @param font A pointer to a chart #lxw_chart_font font struct.
|
|
814
|
+
*
|
|
815
|
+
* The `%chart_axis_set_num_font()` function is used to set the font of the
|
|
816
|
+
* numbers on an axis:
|
|
817
|
+
*
|
|
818
|
+
* @code
|
|
819
|
+
* lxw_chart_font font = {.bold = LXW_TRUE, .color = LXW_COLOR_BLUE};
|
|
820
|
+
*
|
|
821
|
+
* chart_axis_set_num_font(chart->x_axis, &font1);
|
|
822
|
+
* @endcode
|
|
823
|
+
*
|
|
824
|
+
* @image html chart_axis_set_num_font.png
|
|
825
|
+
*
|
|
826
|
+
* For more information see @ref chart_fonts.
|
|
827
|
+
*/
|
|
828
|
+
void chart_axis_set_num_font(lxw_chart_axis *axis, lxw_chart_font *font);
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* @brief Set the line properties for a chart axis.
|
|
832
|
+
*
|
|
833
|
+
* @param axis A pointer to a chart #lxw_chart_axis object.
|
|
834
|
+
* @param line A #lxw_chart_line struct.
|
|
835
|
+
*
|
|
836
|
+
* Set the line properties of a chart axis:
|
|
837
|
+
*
|
|
838
|
+
* @code
|
|
839
|
+
* // Hide the Y axis.
|
|
840
|
+
* lxw_chart_line line = {.none = LXW_TRUE};
|
|
841
|
+
*
|
|
842
|
+
* chart_axis_set_line(chart->y_axis, &line);
|
|
843
|
+
* @endcode
|
|
844
|
+
*
|
|
845
|
+
* @image html chart_axis_set_line.png
|
|
846
|
+
*
|
|
847
|
+
* For more information see @ref chart_lines.
|
|
848
|
+
*/
|
|
849
|
+
void chart_axis_set_line(lxw_chart_axis *axis, lxw_chart_line *line);
|
|
850
|
+
|
|
851
|
+
/**
|
|
852
|
+
* @brief Set the fill properties for a chart axis.
|
|
853
|
+
*
|
|
854
|
+
* @param axis A pointer to a chart #lxw_chart_axis object.
|
|
855
|
+
* @param fill A #lxw_chart_fill struct.
|
|
856
|
+
*
|
|
857
|
+
* Set the fill properties of a chart axis:
|
|
858
|
+
*
|
|
859
|
+
* @code
|
|
860
|
+
* lxw_chart_fill fill = {.color = LXW_COLOR_YELLOW};
|
|
861
|
+
*
|
|
862
|
+
* chart_axis_set_fill(chart->y_axis, &fill);
|
|
863
|
+
* @endcode
|
|
864
|
+
*
|
|
865
|
+
* @image html chart_axis_set_fill.png
|
|
866
|
+
*
|
|
867
|
+
* For more information see @ref chart_fills.
|
|
868
|
+
*/
|
|
869
|
+
void chart_axis_set_fill(lxw_chart_axis *axis, lxw_chart_fill *fill);
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* @brief Set the title of the chart.
|
|
873
|
+
*
|
|
874
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
875
|
+
* @param name The chart title name.
|
|
876
|
+
*
|
|
877
|
+
* The `%chart_title_set_name()` function sets the name (title) for the
|
|
878
|
+
* chart. The name is displayed above the chart.
|
|
879
|
+
*
|
|
880
|
+
* @code
|
|
881
|
+
* chart_title_set_name(chart, "Year End Results");
|
|
882
|
+
* @endcode
|
|
883
|
+
*
|
|
884
|
+
* @image html chart_title_set_name.png
|
|
885
|
+
*
|
|
886
|
+
* The name parameter can also be a formula such as `=Sheet1!$A$1` to point to
|
|
887
|
+
* a cell in the workbook that contains the name:
|
|
888
|
+
*
|
|
889
|
+
* @code
|
|
890
|
+
* chart_title_set_name(chart, "=Sheet1!$B1$1");
|
|
891
|
+
* @endcode
|
|
892
|
+
*
|
|
893
|
+
* See also the `chart_title_set_name_range()` function to see how to set the
|
|
894
|
+
* name formula programmatically.
|
|
895
|
+
*
|
|
896
|
+
* The Excel default is to have no chart title.
|
|
897
|
+
*/
|
|
898
|
+
void chart_title_set_name(lxw_chart *chart, const char *name);
|
|
899
|
+
|
|
900
|
+
/**
|
|
901
|
+
* @brief Set a chart title formula using row and column values.
|
|
902
|
+
*
|
|
903
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
904
|
+
* @param sheetname The name of the worksheet that contains the cell range.
|
|
905
|
+
* @param row The zero indexed row number of the range.
|
|
906
|
+
* @param col The zero indexed column number of the range.
|
|
907
|
+
*
|
|
908
|
+
* The `%chart_title_set_name_range()` function can be used to set a chart
|
|
909
|
+
* title range and is an alternative to using `chart_title_set_name()` and a
|
|
910
|
+
* string formula:
|
|
911
|
+
*
|
|
912
|
+
* @code
|
|
913
|
+
* chart_title_set_name_range(chart, "Sheet1", 1, 0);
|
|
914
|
+
* @endcode
|
|
915
|
+
*/
|
|
916
|
+
void chart_title_set_name_range(lxw_chart *chart, const char *sheetname,
|
|
917
|
+
lxw_row_t row, lxw_col_t col);
|
|
918
|
+
|
|
919
|
+
/**
|
|
920
|
+
* @brief Set the font properties for a chart title.
|
|
921
|
+
*
|
|
922
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
923
|
+
* @param font A pointer to a chart #lxw_chart_font font struct.
|
|
924
|
+
*
|
|
925
|
+
* The `%chart_title_set_name_font()` function is used to set the font of a
|
|
926
|
+
* chart title:
|
|
927
|
+
*
|
|
928
|
+
* @code
|
|
929
|
+
* lxw_chart_font font = {.bold = LXW_TRUE, .color = LXW_COLOR_BLUE};
|
|
930
|
+
*
|
|
931
|
+
* chart_title_set_name(chart, "Year End Results");
|
|
932
|
+
* chart_title_set_name_font(chart, &font);
|
|
933
|
+
* @endcode
|
|
934
|
+
*
|
|
935
|
+
* @image html chart_title_set_name_font.png
|
|
936
|
+
*
|
|
937
|
+
* For more information see @ref chart_fonts.
|
|
938
|
+
*/
|
|
939
|
+
void chart_title_set_name_font(lxw_chart *chart, lxw_chart_font *font);
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* @brief Turn off an automatic chart title.
|
|
943
|
+
*
|
|
944
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
945
|
+
*
|
|
946
|
+
* In general in Excel a chart title isn't displayed unless the user
|
|
947
|
+
* explicitly adds one. However, Excel adds an automatic chart title to charts
|
|
948
|
+
* with a single series and a user defined series name. The
|
|
949
|
+
* `chart_title_off()` function allows you to turn off this automatic chart
|
|
950
|
+
* title:
|
|
951
|
+
*
|
|
952
|
+
* @code
|
|
953
|
+
* chart_title_off(chart);
|
|
954
|
+
* @endcode
|
|
955
|
+
*/
|
|
956
|
+
void chart_title_off(lxw_chart *chart);
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* @brief Set the position of the chart legend.
|
|
960
|
+
*
|
|
961
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
962
|
+
* @param position The #lxw_chart_legend_position value for the legend.
|
|
963
|
+
*
|
|
964
|
+
* The `%chart_legend_set_position()` function is used to set the chart
|
|
965
|
+
* legend to one of the #lxw_chart_legend_position values:
|
|
966
|
+
*
|
|
967
|
+
* LXW_CHART_LEGEND_NONE
|
|
968
|
+
* LXW_CHART_LEGEND_RIGHT
|
|
969
|
+
* LXW_CHART_LEGEND_LEFT
|
|
970
|
+
* LXW_CHART_LEGEND_TOP
|
|
971
|
+
* LXW_CHART_LEGEND_BOTTOM
|
|
972
|
+
* LXW_CHART_LEGEND_OVERLAY_RIGHT
|
|
973
|
+
* LXW_CHART_LEGEND_OVERLAY_LEFT
|
|
974
|
+
*
|
|
975
|
+
* For example:
|
|
976
|
+
*
|
|
977
|
+
* @code
|
|
978
|
+
* chart_legend_set_position(chart, LXW_CHART_LEGEND_BOTTOM);
|
|
979
|
+
* @endcode
|
|
980
|
+
*
|
|
981
|
+
* @image html chart_legend_bottom.png
|
|
982
|
+
*
|
|
983
|
+
* This function can also be used to turn off a chart legend:
|
|
984
|
+
*
|
|
985
|
+
* @code
|
|
986
|
+
* chart_legend_set_position(chart, LXW_CHART_LEGEND_NONE);
|
|
987
|
+
* @endcode
|
|
988
|
+
*
|
|
989
|
+
* @image html chart_legend_none.png
|
|
990
|
+
*
|
|
991
|
+
*/
|
|
992
|
+
void chart_legend_set_position(lxw_chart *chart, uint8_t position);
|
|
993
|
+
|
|
994
|
+
/**
|
|
995
|
+
* @brief Set the font properties for a chart legend.
|
|
996
|
+
*
|
|
997
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
998
|
+
* @param font A pointer to a chart #lxw_chart_font font struct.
|
|
999
|
+
*
|
|
1000
|
+
* The `%chart_legend_set_font()` function is used to set the font of a
|
|
1001
|
+
* chart legend:
|
|
1002
|
+
*
|
|
1003
|
+
* @code
|
|
1004
|
+
* lxw_chart_font font = {.bold = LXW_TRUE, .color = LXW_COLOR_BLUE};
|
|
1005
|
+
*
|
|
1006
|
+
* chart_legend_set_font(chart, &font);
|
|
1007
|
+
* @endcode
|
|
1008
|
+
*
|
|
1009
|
+
* @image html chart_legend_set_font.png
|
|
1010
|
+
*
|
|
1011
|
+
* For more information see @ref chart_fonts.
|
|
1012
|
+
*/
|
|
1013
|
+
void chart_legend_set_font(lxw_chart *chart, lxw_chart_font *font);
|
|
1014
|
+
|
|
1015
|
+
/**
|
|
1016
|
+
* @brief Remove one or more series from the the legend.
|
|
1017
|
+
*
|
|
1018
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
1019
|
+
* @param delete_series An array of zero-indexed values to delete from series.
|
|
1020
|
+
*
|
|
1021
|
+
* @return A #lxw_error.
|
|
1022
|
+
*
|
|
1023
|
+
* The `%chart_legend_delete_series()` function allows you to remove/hide one
|
|
1024
|
+
* or more series in a chart legend (the series will still display on the chart).
|
|
1025
|
+
*
|
|
1026
|
+
* This function takes an array of one or more zero indexed series
|
|
1027
|
+
* numbers. The array should be terminated with -1.
|
|
1028
|
+
*
|
|
1029
|
+
* For example to remove the first and third zero-indexed series from the
|
|
1030
|
+
* legend of a chart with 3 series:
|
|
1031
|
+
*
|
|
1032
|
+
* @code
|
|
1033
|
+
* int16_t series[] = {0, 2, -1};
|
|
1034
|
+
*
|
|
1035
|
+
* chart_legend_delete_series(chart, series);
|
|
1036
|
+
* @endcode
|
|
1037
|
+
*
|
|
1038
|
+
* @image html chart_legend_delete.png
|
|
1039
|
+
*/
|
|
1040
|
+
lxw_error chart_legend_delete_series(lxw_chart *chart,
|
|
1041
|
+
int16_t delete_series[]);
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* @brief Set the chart style type.
|
|
1045
|
+
*
|
|
1046
|
+
* @param chart Pointer to a lxw_chart instance to be configured.
|
|
1047
|
+
* @param style_id An index representing the chart style, 1 - 48.
|
|
1048
|
+
*
|
|
1049
|
+
* The `%chart_set_style()` function is used to set the style of the chart to
|
|
1050
|
+
* one of the 48 built-in styles available on the "Design" tab in Excel 2007:
|
|
1051
|
+
*
|
|
1052
|
+
* @code
|
|
1053
|
+
* chart_set_style(chart, 37)
|
|
1054
|
+
* @endcode
|
|
1055
|
+
*
|
|
1056
|
+
* @image html chart_style.png
|
|
1057
|
+
*
|
|
1058
|
+
* The style index number is counted from 1 on the top left in the Excel
|
|
1059
|
+
* dialog. The default style is 2.
|
|
1060
|
+
*
|
|
1061
|
+
* **Note:**
|
|
1062
|
+
*
|
|
1063
|
+
* In Excel 2013 the Styles section of the "Design" tab in Excel shows what
|
|
1064
|
+
* were referred to as "Layouts" in previous versions of Excel. These layouts
|
|
1065
|
+
* are not defined in the file format. They are a collection of modifications
|
|
1066
|
+
* to the base chart type. They can not be defined by the `chart_set_style()``
|
|
1067
|
+
* function.
|
|
1068
|
+
*
|
|
1069
|
+
*
|
|
1070
|
+
*/
|
|
1071
|
+
void chart_set_style(lxw_chart *chart, uint8_t style_id);
|
|
1072
|
+
|
|
1073
|
+
void chart_set_rotation(lxw_chart *chart, uint16_t rotation);
|
|
1074
|
+
void chart_set_hole_size(lxw_chart *chart, uint8_t size);
|
|
1075
|
+
|
|
1076
|
+
int lxw_chart_add_data_cache(lxw_series_range *range, uint8_t *data,
|
|
1077
|
+
uint16_t rows, uint8_t cols, uint8_t col);
|
|
1078
|
+
|
|
1079
|
+
/* Declarations required for unit testing. */
|
|
1080
|
+
#ifdef TESTING
|
|
1081
|
+
|
|
1082
|
+
STATIC void _chart_xml_declaration(lxw_chart *chart);
|
|
1083
|
+
STATIC void _chart_write_legend(lxw_chart *chart);
|
|
1084
|
+
|
|
1085
|
+
#endif /* TESTING */
|
|
1086
|
+
|
|
1087
|
+
/* *INDENT-OFF* */
|
|
1088
|
+
#ifdef __cplusplus
|
|
1089
|
+
}
|
|
1090
|
+
#endif
|
|
1091
|
+
/* *INDENT-ON* */
|
|
1092
|
+
|
|
1093
|
+
#endif /* __LXW_CHART_H__ */
|