libxlsxwriter
Loading...
Searching...
No Matches
Data Fields
lxw_table_options Struct Reference

Worksheet table options. More...

Detailed Description

Options used to define worksheet tables. See Working with Worksheet Tables for more information.

Examples
tables.c.

Data Fields

const char * name
 
uint8_t no_header_row
 
uint8_t no_autofilter
 
uint8_t no_banded_rows
 
uint8_t banded_columns
 
uint8_t first_column
 
uint8_t last_column
 
uint8_t style_type
 
uint8_t style_type_number
 
uint8_t total_row
 
lxw_table_column ** columns
 

Field Documentation

◆ name

const char* lxw_table_options::name

The name parameter is used to set the name of the table. This parameter is optional and by default tables are named Table1, Table2, etc. in the worksheet order that they are added.

lxw_table_options options = {.name = "Sales"};
worksheet_add_table(worksheet, RANGE("B3:G8"), &options);
Worksheet table options.
Definition: worksheet.h:1422
const char * name
Definition: worksheet.h:1441
#define RANGE(range)
Convert an Excel A1:B2 range into a (first_row, first_col, last_row, last_col) sequence.
Definition: utility.h:83
lxw_error worksheet_add_table(lxw_worksheet *worksheet, lxw_row_t first_row, lxw_col_t first_col, lxw_row_t last_row, lxw_col_t last_col, lxw_table_options *options)
Add an Excel table to a worksheet.

If you override the table name you must ensure that it doesn't clash with an existing table name and that it follows Excel's requirements for table names, see the Microsoft Office documentation on [Naming an Excel Table] (https://support.microsoft.com/en-us/office/rename-an-excel-table-fbf49a4f-82a3-43eb-8ba2-44d21233b114).

◆ no_header_row

uint8_t lxw_table_options::no_header_row

The no_header_row parameter can be used to turn off the header row in the table. It is on by default:

worksheet_add_table(worksheet, RANGE("B4:F7"), &options);
@ LXW_TRUE
Definition: common.h:54
uint8_t no_header_row
Definition: worksheet.h:1460

Without this option the header row will contain default captions such as Column 1, Column 2, etc. These captions can be overridden using the columns parameter shown below.

Examples
tables.c.

◆ no_autofilter

uint8_t lxw_table_options::no_autofilter

The no_autofilter parameter can be used to turn off the autofilter in the header row. It is on by default:

worksheet_add_table(worksheet, RANGE("B3:F7"), &options);
uint8_t no_autofilter
Definition: worksheet.h:1478

The autofilter is only shown if the no_header_row parameter is off (the default). Filter conditions within the table are not supported.

Examples
tables.c.

◆ no_banded_rows

uint8_t lxw_table_options::no_banded_rows

The no_banded_rows parameter can be used to turn off the rows of alternating color in the table. It is on by default:

worksheet_add_table(worksheet, RANGE("B3:F7"), &options);
uint8_t no_banded_rows
Definition: worksheet.h:1493
Examples
tables.c.

◆ banded_columns

uint8_t lxw_table_options::banded_columns

The banded_columns parameter can be used to used to create columns of alternating color in the table. It is off by default:

worksheet_add_table(worksheet, RANGE("B3:F7"), &options);
uint8_t banded_columns
Definition: worksheet.h:1508

The banded columns formatting is shown in the image in the previous section above.

◆ first_column

uint8_t lxw_table_options::first_column

The first_column parameter can be used to highlight the first column of the table. The type of highlighting will depend on the style_type of the table. It may be bold text or a different color. It is off by default:

lxw_table_options options = {.first_column = LXW_TRUE, .last_column = LXW_TRUE};
worksheet_add_table(worksheet, RANGE("B3:F7"), &options);
uint8_t first_column
Definition: worksheet.h:1524
Examples
tables.c.

◆ last_column

uint8_t lxw_table_options::last_column

The last_column parameter can be used to highlight the last column of the table. The type of highlighting will depend on the style of the table. It may be bold text or a different color. It is off by default:

lxw_table_options options = {.first_column = LXW_TRUE, .last_column = LXW_TRUE};
worksheet_add_table(worksheet, RANGE("B3:F7"), &options);

The last_column formatting is shown in the image in the previous section above.

◆ style_type

uint8_t lxw_table_options::style_type

The style_type parameter can be used to set the style of the table, in conjunction with the style_type_number parameter:

lxw_table_options options = {
.style_type_number = 11,
};
worksheet_add_table(worksheet, RANGE("B3:G8"), &options);
uint8_t style_type
Definition: worksheet.h:1597
@ LXW_TABLE_STYLE_TYPE_LIGHT
Definition: worksheet.h:549

There are three types of table style in Excel: Light, Medium and Dark which are represented using the lxw_table_style_type enum values:

Within those ranges there are between 11 and 28 other style types which can be set with style_type_number (depending on the style type). Check Excel to find the style that you want. The dialog with the options laid out in numeric order are shown below:

The default table style in Excel is 'Table Style Medium 9' (highlighted with a green border in the image above), which is set by default in libxlsxwriter as:

lxw_table_options options = {
.style_type_number = 9,
};
@ LXW_TABLE_STYLE_TYPE_MEDIUM
Definition: worksheet.h:552

You can also turn the table style off by setting it to Light 0:

lxw_table_options options = {
.style_type_number = 0,
};
Examples
tables.c.

◆ style_type_number

uint8_t lxw_table_options::style_type_number

The style_type_number parameter is used with style_type to set the style of a worksheet table.

◆ total_row

uint8_t lxw_table_options::total_row

The total_row parameter can be used to turn on the total row in the last row of a table. It is distinguished from the other rows by a different formatting and also with dropdown SUBTOTAL functions:

worksheet_add_table(worksheet, RANGE("B3:G8"), &options);
uint8_t total_row
Definition: worksheet.h:1620

The default total row doesn't have any captions or functions. These must by specified via the columns parameter below.

Examples
tables.c.

◆ columns

lxw_table_column** lxw_table_options::columns

The columns parameter can be used to set properties for columns within the table. See Parameter: columns for a detailed explanation.

Examples
tables.c.