mirror of
https://github.com/jmcnamara/libxlsxwriter
synced 2025-03-28 21:13:14 +00:00
1234 lines
24 KiB
Plaintext
1234 lines
24 KiB
Plaintext
/**
|
|
@page examples Example Programs
|
|
|
|
@example hello.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref examples "<< Examples page"</td>
|
|
<td align="right">@ref anatomy.c "anatomy.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
The simplest possible program and spreadsheet. This is a good place to start
|
|
to see if the libxlsxwriter library is installed and working correctly.
|
|
|
|
@image html hello01.png
|
|
|
|
|
|
|
|
|
|
@example anatomy.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref hello.c "<< hello.c"</td>
|
|
<td align="right">@ref demo.c "demo.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Anatomy of a simple libxlsxwriter program where the program is explained line
|
|
by line with comments.
|
|
|
|
@image html anatomy.png
|
|
|
|
|
|
|
|
|
|
@example demo.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref anatomy.c "<< anatomy.c"</td>
|
|
<td align="right">@ref format_font.c "format_font.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A simple example of some of the features of the libxlsxwriter library.
|
|
|
|
@image html demo.png
|
|
|
|
|
|
|
|
|
|
@example format_font.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref demo.c "<< demo.c"</td>
|
|
<td align="right">@ref format_num_format.c "format_num_format.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing some data with font formatting to a simple Excel
|
|
file using libxlsxwriter.
|
|
|
|
@image html format_font.png
|
|
|
|
|
|
|
|
|
|
@example format_num_format.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref format_font.c "<< format_font.c"</td>
|
|
<td align="right">@ref tutorial1.c "tutorial1.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing some data with numeric formatting to a simple Excel
|
|
file using libxlsxwriter.
|
|
|
|
@image html format_set_num_format.png
|
|
|
|
|
|
|
|
|
|
@example tutorial1.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref format_num_format.c "<< format_num_format.c"</td>
|
|
<td align="right">@ref tutorial2.c "tutorial2.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A tutorial program which is shown, with explanations, in @ref tutorial01.
|
|
|
|
@image html tutorial01.png
|
|
|
|
|
|
|
|
|
|
@example tutorial2.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref tutorial1.c "<< tutorial1.c"</td>
|
|
<td align="right">@ref tutorial3.c "tutorial3.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A tutorial program which is shown, with explanations, in @ref tutorial02.
|
|
|
|
@image html tutorial02.png
|
|
|
|
|
|
|
|
|
|
@example tutorial3.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref tutorial2.c "<< tutorial2.c"</td>
|
|
<td align="right">@ref dates_and_times01.c "dates_and_times01.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A tutorial program which is shown, with explanations, in @ref tutorial03.
|
|
|
|
@image html tutorial03.png
|
|
|
|
|
|
|
|
|
|
@example dates_and_times01.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref tutorial3.c "<< tutorial3.c"</td>
|
|
<td align="right">@ref dates_and_times02.c "dates_and_times02.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing a dates and time in Excel using a number with date
|
|
formatting. This demonstrates that dates and times in Excel are just formatted
|
|
real numbers. An easier approach using a lxw_datetime struct is shown in the
|
|
next example.
|
|
|
|
@image html date_example01.png
|
|
|
|
|
|
|
|
|
|
@example dates_and_times02.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref dates_and_times01.c "<< dates_and_times01.c"</td>
|
|
<td align="right">@ref dates_and_times03.c "dates_and_times03.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing dates and times in Excel using an lxw_datetime struct and
|
|
date formatting.
|
|
|
|
@image html date_example02.png
|
|
|
|
|
|
|
|
|
|
@example dates_and_times03.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref dates_and_times02.c "<< dates_and_times02.c"</td>
|
|
<td align="right">@ref dates_and_times04.c "dates_and_times04.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing dates and times in Excel using Unix datetimes and
|
|
formatting.
|
|
|
|
@image html date_example03.png
|
|
|
|
|
|
|
|
|
|
@example dates_and_times04.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref dates_and_times03.c "<< dates_and_times03.c"</td>
|
|
<td align="right">@ref hyperlinks.c "hyperlinks.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing dates and times in Excel using different date formats.
|
|
|
|
@image html date_example04.png
|
|
|
|
|
|
|
|
|
|
@example hyperlinks.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref dates_and_times04.c "<< dates_and_times04.c"</td>
|
|
<td align="right">@ref rich_strings.c "rich_strings.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing urls/hyperlinks to a worksheet.
|
|
|
|
@image html hyperlinks.png
|
|
|
|
|
|
|
|
|
|
@example rich_strings.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref hyperlinks.c "<< hyperlinks.c"</td>
|
|
<td align="right">@ref array_formula.c "array_formula.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing "rich" multi-format strings to a worksheet.
|
|
|
|
@image html rich_strings.png
|
|
|
|
|
|
|
|
|
|
|
|
@example array_formula.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref rich_strings.c "<< rich_strings.c"</td>
|
|
<td align="right">@ref dynamic_arrays.c "dynamic_arrays.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing array formulas to a worksheet.
|
|
|
|
@image html array_formula.png
|
|
|
|
|
|
|
|
|
|
|
|
@example dynamic_arrays.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref array_formula.c "<< array_formula.c"</td>
|
|
<td align="right">@ref utf8.c "utf8.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of writing Excel 365 dynamic array formulas to a worksheet.
|
|
|
|
@image html dynamic_arrays01.png
|
|
|
|
|
|
|
|
|
|
@example utf8.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref dynamic_arrays.c "<< dynamic_arrays.c"</td>
|
|
<td align="right">@ref constant_memory.c "constant_memory.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
A simple Unicode UTF-8 example. Note, the source file is UTF-8 encoded.
|
|
|
|
@image html utf8.png
|
|
|
|
|
|
|
|
|
|
@example constant_memory.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref utf8.c "<< utf8.c"</td>
|
|
<td align="right">@ref output_buffer.c "output_buffer.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of using libxlsxwriter for writing large files in constant memory
|
|
mode.
|
|
|
|
@image html constant_memory.png
|
|
|
|
|
|
|
|
|
|
@example output_buffer.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref constant_memory.c "<< constant_memory.c"</td>
|
|
<td align="right">@ref image_buffer.c "image_buffer.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of using libxlsxwriter to write a workbook file to a memory buffer.
|
|
|
|
@image html hello01.png
|
|
|
|
|
|
|
|
|
|
@example image_buffer.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref output_buffer.c "<< output_buffer.c"</td>
|
|
<td align="right">@ref embed_image_buffer.c "embed_image_buffer.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of inserting an image in a worksheet from a memory buffer.
|
|
|
|
@image html image_buffer2.png
|
|
|
|
|
|
|
|
|
|
@example embed_image_buffer.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref image_buffer.c "<< image_buffer.c"</td>
|
|
<td align="right">@ref merge_range.c "merge_range.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of embedding an image in a worksheet from a memory buffer.
|
|
|
|
@image html embed_image_buffer.png
|
|
|
|
|
|
|
|
|
|
@example merge_range.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref embed_image_buffer.c "<< embed_image_buffer.c"</td>
|
|
<td align="right">@ref merge_rich_string.c "merge_rich_string.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of merging cells in a worksheet.
|
|
|
|
@image html merge_range.png
|
|
|
|
|
|
|
|
|
|
@example merge_rich_string.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref merge_range.c "<< merge_range.c"</td>
|
|
<td align="right">@ref autofilter.c "autofilter.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of merging cells with a rich string in a worksheet.
|
|
|
|
@image html merge_rich.png
|
|
|
|
|
|
|
|
|
|
@example autofilter.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref merge_rich_string.c "<< merge_rich_string.c"</td>
|
|
<td align="right">@ref data_validate.c "data_validate.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of adding autofilters to a worksheets and adding filter conditions.
|
|
|
|
@image html autofilter3.png
|
|
|
|
|
|
|
|
|
|
@example data_validate.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref autofilter.c "<< autofilter.c"</td>
|
|
<td align="right">@ref conditional_format1.c "conditional_format1.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of adding data validations to a worksheet.
|
|
|
|
@image html data_validate4.png
|
|
|
|
|
|
|
|
|
|
@example conditional_format1.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref data_validate.c "<< data_validate.c"</td>
|
|
<td align="right">@ref conditional_format2.c "conditional_format2.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A simple example of how to add a conditional format a
|
|
libxlsxwriter file. Conditional formatting allows you to apply
|
|
a format to a cell or a range of cells based on certain criteria.
|
|
|
|
@image html conditional_format12.png
|
|
|
|
|
|
|
|
|
|
|
|
@example conditional_format2.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref conditional_format1.c "<< conditional_format1.c"</td>
|
|
<td align="right">@ref tables.c "tables.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A more comprehensive example of how to add conditional formatting
|
|
to an libxlsxwriter file. Conditional formatting allows you to
|
|
apply a format to a cell or a range of cells based on certain
|
|
criteria.
|
|
|
|
@image html conditional_format1.png
|
|
|
|
|
|
|
|
|
|
|
|
@example tables.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref conditional_format2.c "<< conditional_format2.c"</td>
|
|
<td align="right">@ref images.c "images.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to add tables to a worksheet. Tables in Excel are used to group
|
|
rows and columns of data into a single structure that can be referenced in a
|
|
formula or formatted collectively.
|
|
|
|
@image html tables12.png
|
|
|
|
|
|
|
|
|
|
@example images.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref tables.c "<< tables.c"</td>
|
|
<td align="right">@ref embed_images.c "embed_images.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of inserting images in a worksheet.
|
|
|
|
@image html images.png
|
|
|
|
|
|
|
|
|
|
@example embed_images.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref images.c "<< images.c"</td>
|
|
<td align="right">@ref headers_footers.c "headers_footers.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of embedding images in a worksheet.
|
|
|
|
@image html embed_image.png
|
|
|
|
|
|
|
|
|
|
@example headers_footers.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref embed_images.c "<< embed_images.c"</td>
|
|
<td align="right">@ref defined_name.c "defined_name.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of adding worksheet headers and footers to worksheets.
|
|
|
|
@image html headers_footers.png
|
|
|
|
|
|
|
|
|
|
@example defined_name.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref headers_footers.c "<< headers_footers.c"</td>
|
|
<td align="right">@ref outline.c "outline.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to create defined names (named ranges) using libxlsxwriter.
|
|
|
|
Defined names are used to define descriptive names to represent a value, a
|
|
single cell or a range of cells in a workbook or worksheet.
|
|
|
|
@image html defined_name.png
|
|
|
|
|
|
|
|
|
|
@example outline.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref defined_name.c "<< defined_name.c"</td>
|
|
<td align="right">@ref outline_collapsed.c "outline_collapsed.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to generate Excel outlines and grouping.
|
|
|
|
@image html outline1.png
|
|
|
|
|
|
|
|
|
|
@example outline_collapsed.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref outline.c "<< outline.c"</td>
|
|
<td align="right">@ref watermark.c "watermark.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to generate Excel outlines and grouping. These examples focus
|
|
mainly on collapsed outlines.
|
|
|
|
@image html outline2.png
|
|
|
|
|
|
|
|
|
|
@example watermark.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref outline_collapsed.c "<< outline_collapsed.c"</td>
|
|
<td align="right">@ref background.c "background.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to a watermark image for a worksheet using the method suggested
|
|
in the Microsoft documentation:
|
|
https://support.microsoft.com/en-us/office/add-a-watermark-in-excel-a372182a-d733-484e-825c-18ddf3edf009
|
|
|
|
@image html worksheet_watermark.png
|
|
|
|
|
|
|
|
|
|
@example background.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref watermark.c "<< watermark.c"</td>
|
|
<td align="right">@ref tab_colors.c "tab_colors.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to set the background image for a worksheet.
|
|
|
|
@image html background.png
|
|
|
|
|
|
|
|
|
|
@example tab_colors.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref background.c "<< background.c"</td>
|
|
<td align="right">@ref diagonal_border.c "diagonal_border.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to set Excel worksheet tab colors.
|
|
|
|
@image html tab_colors.png
|
|
|
|
|
|
|
|
|
|
@example diagonal_border.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref tab_colors.c "<< tab_colors.c"</td>
|
|
<td align="right">@ref hide_sheet.c "hide_sheet.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to set a worksheet cell diagonal border.
|
|
|
|
@image html diagonal_border.png
|
|
|
|
|
|
|
|
|
|
@example hide_sheet.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref diagonal_border.c "<< diagonal_border.c"</td>
|
|
<td align="right">@ref doc_properties.c "doc_properties.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of how to hide an Excel worksheet.
|
|
|
|
@image html hide_sheet.png
|
|
|
|
|
|
|
|
|
|
@example doc_properties.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref hide_sheet.c "<< hide_sheet.c"</td>
|
|
<td align="right">@ref doc_custom_properties.c "doc_custom_properties.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of setting Excel document properties.
|
|
|
|
@image html doc_properties.png
|
|
|
|
|
|
|
|
|
|
@example doc_custom_properties.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref doc_properties.c "<< doc_properties.c"</td>
|
|
<td align="right">@ref worksheet_protection.c "worksheet_protection.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of setting Excel custom document properties, i.e., properties
|
|
non-standard document properties.
|
|
|
|
@image html custom_properties.png
|
|
|
|
|
|
|
|
|
|
@example worksheet_protection.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref doc_custom_properties.c "<< doc_custom_properties.c"</td>
|
|
<td align="right">@ref macro.c "macro.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of setting Excel worksheet protection.
|
|
|
|
@image html worksheet_protection.png
|
|
|
|
|
|
|
|
|
|
@example macro.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref worksheet_protection.c "<< worksheet_protection.c"</td>
|
|
<td align="right">@ref comments1.c "comments1.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example adding a VBA macro to a workbook.
|
|
|
|
@image html macros.png
|
|
|
|
|
|
|
|
|
|
@example comments1.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref macro.c "<< macro.c"</td>
|
|
<td align="right">@ref comments2.c "comments2.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A simple example of adding cell comments to a worksheet.
|
|
|
|
@image html comments1.png
|
|
|
|
|
|
|
|
|
|
@example comments2.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref comments1.c "<< comments1.c"</td>
|
|
<td align="right">@ref hide_row_col.c "hide_row_col.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Another example of adding cell comments to a worksheet. This example
|
|
demonstrates most of the available comment formatting options.
|
|
|
|
@image html comments2.png
|
|
|
|
|
|
|
|
|
|
@example hide_row_col.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref comments2.c "<< comments2.c"</td>
|
|
<td align="right">@ref panes.c "panes.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of hiding rows and columns in an Excel worksheet.
|
|
|
|
@image html hide_row_col.png
|
|
|
|
|
|
|
|
|
|
@example panes.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref hide_row_col.c "<< hide_row_col.c"</td>
|
|
<td align="right">@ref ignore_errors.c "ignore_errors.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
An example of how to create panes in a worksheet, both "freeze" panes and
|
|
"split" panes.
|
|
|
|
@image html panes.png
|
|
|
|
|
|
|
|
|
|
@example ignore_errors.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref panes.c "<< panes.c"</td>
|
|
<td align="right">@ref lambda.c "lambda.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of hiding worksheet errors and warnings.
|
|
|
|
@image html ignore_errors2.png
|
|
|
|
|
|
|
|
|
|
@example lambda.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref ignore_errors.c "<< ignore_errors.c"</td>
|
|
<td align="right">@ref chart.c "chart.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of using the new Excel `LAMBDA()` function. It demonstrates how to
|
|
create a lambda function in Excel and also how to assign a name to it so that
|
|
it can be called as a user defined function. This particular example converts
|
|
from Fahrenheit to Celsius.
|
|
|
|
@image html lambda01.png
|
|
|
|
|
|
|
|
|
|
@example chart.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref lambda.c "<< lambda.c"</td>
|
|
<td align="right">@ref chart_area.c "chart_area.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
An example of creating a simple column chart with 3 data series.
|
|
|
|
@image html chart_simple.png
|
|
|
|
|
|
|
|
|
|
@example chart_area.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart.c "<< chart.c"</td>
|
|
<td align="right">@ref chart_bar.c "chart_bar.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating Excel Area charts. Three types of area chart are shown.
|
|
|
|
The default area chart:
|
|
@image html chart_area1.png
|
|
|
|
Stacked area chart:
|
|
@image html chart_area2.png
|
|
|
|
Percent stacked area chart:
|
|
@image html chart_area3.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_bar.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_area.c "<< chart_area.c"</td>
|
|
<td align="right">@ref chart_column.c "chart_column.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating Excel Bar charts. Three types of bar chart are shown.
|
|
|
|
The default bar chart:
|
|
@image html chart_bar1.png
|
|
|
|
Stacked bar chart:
|
|
@image html chart_bar2.png
|
|
|
|
Percent stacked bar chart:
|
|
@image html chart_bar3.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_column.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_bar.c "<< chart_bar.c"</td>
|
|
<td align="right">@ref chart_line.c "chart_line.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating Excel Column charts. Three types of column chart are shown.
|
|
|
|
The default column chart:
|
|
@image html chart_column1.png
|
|
|
|
Stacked column chart:
|
|
@image html chart_column2.png
|
|
|
|
Percent stacked column chart:
|
|
@image html chart_column3.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_line.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_column.c "<< chart_column.c"</td>
|
|
<td align="right">@ref chart_scatter.c "chart_scatter.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating Excel Line charts. Three types of line chart are shown.
|
|
|
|
The default line chart:
|
|
@image html chart_line1.png
|
|
|
|
Stacked line chart:
|
|
@image html chart_line2.png
|
|
|
|
Percent stacked line chart:
|
|
@image html chart_line3.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_scatter.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_line.c "<< chart_line.c"</td>
|
|
<td align="right">@ref chart_radar.c "chart_radar.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating Excel Scatter charts. Five types of scatter chart are shown.
|
|
|
|
The default scatter chart:
|
|
@image html chart_scatter1.png
|
|
|
|
Straight scatter chart with markers:
|
|
@image html chart_scatter2.png
|
|
|
|
Straight scatter chart:
|
|
@image html chart_scatter3.png
|
|
|
|
Smooth scatter chart with markers:
|
|
@image html chart_scatter4.png
|
|
|
|
Smooth scatter chart:
|
|
@image html chart_scatter5.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_radar.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_scatter.c "<< chart_scatter.c"</td>
|
|
<td align="right">@ref chart_pie.c "chart_pie.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating Excel Radar charts. Three types of radar chart are shown.
|
|
|
|
The default radar chart:
|
|
@image html chart_radar1.png
|
|
|
|
Radar chart with markers:
|
|
@image html chart_radar2.png
|
|
|
|
Filled radar chart:
|
|
@image html chart_radar3.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_pie.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_radar.c "<< chart_radar.c"</td>
|
|
<td align="right">@ref chart_doughnut.c "chart_doughnut.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Examples of creating an Excel Pie chart.
|
|
|
|
The default pie chart:
|
|
@image html chart_pie1.png
|
|
|
|
A pie chart with user defined colors:
|
|
@image html chart_pie2.png
|
|
|
|
A pie chart with rotated segments:
|
|
@image html chart_pie3.png
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_doughnut.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_pie.c "<< chart_pie.c"</td>
|
|
<td align="right">@ref chart_clustered.c "chart_clustered.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating an Excel Doughnut chart.
|
|
|
|
The default doughnut chart:
|
|
@image html chart_doughnut1.png
|
|
|
|
It is possible to define chart colors for most types of libxlsxwriter charts
|
|
via the series formatting functions. However, Pie/Doughnut charts are a
|
|
special case since each segment is represented as a point so it is necessary
|
|
to assign formatting to each point in the series.
|
|
|
|
Chart 4 shows how to set segment colors and other options.
|
|
@image html chart_doughnut2.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_clustered.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_doughnut.c "<< chart_doughnut.c"</td>
|
|
<td align="right">@ref chart_data_table.c "chart_data_table.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating a clustered Excel chart where there are two levels of
|
|
category on the X axis.
|
|
|
|
The categories in clustered charts are 2D ranges, instead of the more normal
|
|
1D ranges. The series are shown as formula strings for clarity but you can
|
|
also use the a list syntax.
|
|
|
|
@image html chart_clustered.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_data_table.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_clustered.c "<< chart_clustered.c"</td>
|
|
<td align="right">@ref chart_data_tools.c "chart_data_tools.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
Example of creating charts with data tables.
|
|
|
|
Chart 1 in the following example is a column chart with default data table:
|
|
@image html chart_data_table1.png
|
|
|
|
|
|
Chart 2 is a column chart with default data table with legend keys:
|
|
@image html chart_data_table2.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_data_tools.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_data_table.c "<< chart_data_table.c"</td>
|
|
<td align="right">@ref chart_data_labels.c "chart_data_labels.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A demo of an various Excel chart data tools that are available via a
|
|
libxlsxwriter chart. These include Drop Lines and High-Low Lines.
|
|
|
|
|
|
Chart 1: chart with high-low lines.
|
|
@image html chart_data_tools5.png
|
|
|
|
Chart 2: chart with drop lines.
|
|
@image html chart_data_tools6.png
|
|
|
|
Chart 3: chart with up-down bars.
|
|
@image html chart_data_tools4.png
|
|
|
|
Chart 4: chart with formatted Up-down bars.
|
|
@image html chart_data_tools7.png
|
|
|
|
Chart 5: chart with markers and data labels.
|
|
@image html chart_data_tools8.png
|
|
|
|
Chart 6: chart with error bars.
|
|
@image html chart_data_tools3.png
|
|
|
|
Chart 7: chart with a trendline.
|
|
@image html chart_data_tools9.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_data_labels.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_data_tools.c "<< chart_data_tools.c"</td>
|
|
<td align="right">@ref chart_fonts.c "chart_fonts.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
A demo of an various Excel chart data label features that are available via a
|
|
libxlsxwriter chart, including custom data labels.
|
|
|
|
Chart 1: chart with standard data labels.
|
|
@image html chart_data_labels11.png
|
|
|
|
Chart 2: chart with Category and Value data labels.
|
|
@image html chart_data_labels12.png
|
|
|
|
Chart 3: chart with data labels with a user defined font.
|
|
@image html chart_data_labels13.png
|
|
|
|
Chart 4: chart with data labels and formatting.
|
|
@image html chart_data_labels22.png
|
|
|
|
Chart 5: chart with custom string data labels.
|
|
@image html chart_data_labels14.png
|
|
|
|
Chart 6: chart with custom data labels referenced from worksheet cells.
|
|
@image html chart_data_labels15.png
|
|
|
|
Chart 7: chart with a mix of custom and default labels. The items initialized
|
|
with '{0}' and items without a custom label (points 5 and 6 which come after
|
|
NULL) will get the default value. We also set a font for the custom items as
|
|
an extra example.
|
|
@image html chart_data_labels16.png
|
|
|
|
Chart 8: chart with some deleted custom labels and defaults.
|
|
@image html chart_data_labels17.png
|
|
|
|
Chart 9: chart with custom string data labels and formatting.
|
|
@image html chart_data_labels23.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_fonts.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_data_labels.c "<< chart_data_labels.c"</td>
|
|
<td align="right">@ref chart_pattern.c "chart_pattern.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
An example of creating a simple chart with different fonts.
|
|
|
|
@image html chart_fonts.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_pattern.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_fonts.c "<< chart_fonts.c"</td>
|
|
<td align="right">@ref chart_styles.c "chart_styles.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
An example of creating a simple chart with different patterns.
|
|
|
|
@image html chart_pattern.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chart_styles.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_pattern.c "<< chart_pattern.c"</td>
|
|
<td align="right">@ref chartsheet.c "chartsheet.c >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
An example showing all 48 default chart styles available in Excel 2007 using
|
|
the chart `chart_set_style()` method.
|
|
|
|
@image html chart_styles.png
|
|
|
|
|
|
|
|
|
|
|
|
@example chartsheet.c
|
|
|
|
<table width="600">
|
|
<tr>
|
|
<td>@ref chart_styles.c "<< chart_styles.c"</td>
|
|
<td align="right">@ref examples "Examples page >>"</td>
|
|
</tr>
|
|
</table>
|
|
|
|
An example of creating a simple bar chart in a chartsheet.
|
|
|
|
@image html chartsheet.png
|
|
|
|
|
|
|
|
|
|
*/
|