libxlsxwriter
|
The Chartsheet object represents an Excel chartsheet. It handles operations such as adding a chart and setting the page layout.
A Chartsheet object isn't created directly. Instead a chartsheet is created by calling the workbook_add_chartsheet() function from a Workbook object. A chartsheet object functions as a worksheet and not as a chart. In order to have it display data a lxw_chart object must be created and added to the chartsheet:
The data for the chartsheet chart must be contained on a separate worksheet. That is why it is always created in conjunction with at least one data worksheet, as shown above.
Functions | |
lxw_error | chartsheet_set_chart (lxw_chartsheet *chartsheet, lxw_chart *chart) |
Insert a chart object into a chartsheet. | |
void | chartsheet_activate (lxw_chartsheet *chartsheet) |
Make a chartsheet the active, i.e., visible chartsheet. | |
void | chartsheet_select (lxw_chartsheet *chartsheet) |
Set a chartsheet tab as selected. | |
void | chartsheet_hide (lxw_chartsheet *chartsheet) |
Hide the current chartsheet. | |
void | chartsheet_set_first_sheet (lxw_chartsheet *chartsheet) |
Set current chartsheet as the first visible sheet tab. | |
void | chartsheet_set_tab_color (lxw_chartsheet *chartsheet, lxw_color_t color) |
Set the color of the chartsheet tab. | |
void | chartsheet_protect (lxw_chartsheet *chartsheet, const char *password, lxw_protection *options) |
Protect elements of a chartsheet from modification. | |
void | chartsheet_set_zoom (lxw_chartsheet *chartsheet, uint16_t scale) |
Set the chartsheet zoom factor. | |
void | chartsheet_set_landscape (lxw_chartsheet *chartsheet) |
Set the page orientation as landscape. | |
void | chartsheet_set_portrait (lxw_chartsheet *chartsheet) |
Set the page orientation as portrait. | |
void | chartsheet_set_paper (lxw_chartsheet *chartsheet, uint8_t paper_type) |
Set the paper type for printing. | |
void | chartsheet_set_margins (lxw_chartsheet *chartsheet, double left, double right, double top, double bottom) |
Set the chartsheet margins for the printed page. | |
lxw_error | chartsheet_set_header (lxw_chartsheet *chartsheet, const char *string) |
Set the printed page header caption. | |
lxw_error | chartsheet_set_footer (lxw_chartsheet *chartsheet, const char *string) |
Set the printed page footer caption. | |
lxw_error | chartsheet_set_header_opt (lxw_chartsheet *chartsheet, const char *string, lxw_header_footer_options *options) |
Set the printed page header caption with additional options. | |
lxw_error | chartsheet_set_footer_opt (lxw_chartsheet *chartsheet, const char *string, lxw_header_footer_options *options) |
Set the printed page footer caption with additional options. | |
lxw_error chartsheet_set_chart | ( | lxw_chartsheet * | chartsheet, |
lxw_chart * | chart | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
chart | A lxw_chart object created via workbook_add_chart(). |
The chartsheet_set_chart()
function can be used to insert a chart into a chartsheet. The chart object must be created first using the workbook_add_chart()
function and configured using the chart.h functions.
Note:
A chart may only be inserted once into a chartsheet or a worksheet. If several similar charts are required then each one must be created separately.
void chartsheet_activate | ( | lxw_chartsheet * | chartsheet | ) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
The chartsheet_activate()
function is used to specify which chartsheet is initially visible in a multi-sheet workbook:
More than one chartsheet can be selected via the chartsheet_select()
function, see below, however only one chartsheet can be active.
The default active chartsheet is the first chartsheet.
See also worksheet_activate()
.
void chartsheet_select | ( | lxw_chartsheet * | chartsheet | ) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
The chartsheet_select()
function is used to indicate that a chartsheet is selected in a multi-sheet workbook:
A selected chartsheet has its tab highlighted. Selecting chartsheets is a way of grouping them together so that, for example, several chartsheets could be printed in one go. A chartsheet that has been activated via the chartsheet_activate()
function will also appear as selected.
See also worksheet_select()
.
void chartsheet_hide | ( | lxw_chartsheet * | chartsheet | ) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
The chartsheet_hide()
function is used to hide a chartsheet:
You may wish to hide a chartsheet in order to avoid confusing a user with intermediate data or calculations.
A hidden chartsheet can not be activated or selected so this function is mutually exclusive with the chartsheet_activate()
and chartsheet_select()
functions. In addition, since the first chartsheet will default to being the active chartsheet, you cannot hide the first chartsheet without activating another sheet:
See also worksheet_hide()
.
void chartsheet_set_first_sheet | ( | lxw_chartsheet * | chartsheet | ) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
The chartsheet_activate()
function determines which chartsheet is initially selected. However, if there are a large number of chartsheets the selected chartsheet may not appear on the screen. To avoid this you can select the leftmost visible chartsheet tab using chartsheet_set_first_sheet()
:
This function is not required very often. The default value is the first chartsheet.
See also worksheet_set_first_sheet()
.
void chartsheet_set_tab_color | ( | lxw_chartsheet * | chartsheet, |
lxw_color_t | color | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
color | The tab color. |
The chartsheet_set_tab_color()
function is used to change the color of the chartsheet tab:
The color should be an RGB integer value, see Working with Colors.
See also worksheet_set_tab_color()
.
void chartsheet_protect | ( | lxw_chartsheet * | chartsheet, |
const char * | password, | ||
lxw_protection * | options | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
password | A chartsheet password. |
options | Chartsheet elements to protect. |
The chartsheet_protect()
function protects chartsheet elements from modification:
The password
and lxw_protection pointer are both optional:
Passing a NULL
password is the same as turning on protection without a password. Passing a NULL
password and NULL
options had no effect on chartsheets.
You can specify which chartsheet elements you wish to protect by passing a lxw_protection pointer in the options
argument. In Excel chartsheets only have two protection options:
no_content no_objects
All parameters are off by default. Individual elements can be protected as follows:
See also worksheet_protect().
Note: Sheet level passwords in Excel offer very weak protection. They don't encrypt your data and are very easy to deactivate. Full workbook encryption is not supported by libxlsxwriter
since it requires a completely different file format.
void chartsheet_set_zoom | ( | lxw_chartsheet * | chartsheet, |
uint16_t | scale | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
scale | Chartsheet zoom factor. |
Set the chartsheet zoom factor in the range 10 <= zoom <= 400
:
The default zoom factor is 100. It isn't possible to set the zoom to "Selection" because it is calculated by Excel at run-time.
See also worksheet_set_zoom()
.
void chartsheet_set_landscape | ( | lxw_chartsheet * | chartsheet | ) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
This function is used to set the orientation of a chartsheet's printed page to landscape. The default chartsheet orientation is landscape, so this function isn't generally required:
void chartsheet_set_portrait | ( | lxw_chartsheet * | chartsheet | ) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
This function is used to set the orientation of a chartsheet's printed page to portrait:
void chartsheet_set_paper | ( | lxw_chartsheet * | chartsheet, |
uint8_t | paper_type | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
paper_type | The Excel paper format type. |
This function is used to set the paper format for the printed output of a chartsheet:
If you do not specify a paper type the chartsheet will print using the printer's default paper style.
See worksheet_set_paper()
for a full list of available paper sizes.
void chartsheet_set_margins | ( | lxw_chartsheet * | chartsheet, |
double | left, | ||
double | right, | ||
double | top, | ||
double | bottom | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
left | Left margin in inches. Excel default is 0.7. |
right | Right margin in inches. Excel default is 0.7. |
top | Top margin in inches. Excel default is 0.75. |
bottom | Bottom margin in inches. Excel default is 0.75. |
The chartsheet_set_margins()
function is used to set the margins of the chartsheet when it is printed. The units are in inches. Specifying -1
for any parameter will give the default Excel value as shown above.
lxw_error chartsheet_set_header | ( | lxw_chartsheet * | chartsheet, |
const char * | string | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
string | The header string. |
Headers and footers are generated using a string which is a combination of plain text and control characters
See worksheet_set_header()
for a full explanation of the syntax of Excel's header formatting and control characters.
lxw_error chartsheet_set_footer | ( | lxw_chartsheet * | chartsheet, |
const char * | string | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
string | The footer string. |
The syntax of this function is the same as chartsheet_set_header().
lxw_error chartsheet_set_header_opt | ( | lxw_chartsheet * | chartsheet, |
const char * | string, | ||
lxw_header_footer_options * | options | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
string | The header string. |
options | Header options. |
The syntax of this function is the same as chartsheet_set_header() with an additional parameter to specify options for the header.
Currently, the only available option is the header margin:
lxw_error chartsheet_set_footer_opt | ( | lxw_chartsheet * | chartsheet, |
const char * | string, | ||
lxw_header_footer_options * | options | ||
) |
chartsheet | Pointer to a lxw_chartsheet instance to be updated. |
string | The footer string. |
options | Footer options. |
The syntax of this function is the same as chartsheet_set_header_opt().
typedef struct lxw_chartsheet lxw_chartsheet |
The members of the lxw_chartsheet struct aren't modified directly. Instead the chartsheet properties are set by calling the functions shown in chartsheet.h.
Data Structures | |
struct | lxw_chartsheet |
Struct to represent an Excel chartsheet. More... | |
Typedefs | |
typedef struct lxw_chartsheet | lxw_chartsheet |
Struct to represent an Excel chartsheet. | |