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.
#include "xlsxwriter.h"
int main() {
write_worksheet_data(worksheet2, NULL);
write_worksheet_data(worksheet3, NULL);
write_worksheet_data(worksheet4, NULL);
"Default table with \"First Column\" and \"Last Column\" options.",
NULL);
write_worksheet_data(worksheet5, NULL);
"Table with banded columns but without default banded rows.",
NULL);
write_worksheet_data(worksheet6, NULL);
lxw_table_column *columns7[] = {&col7_1, &col7_2, &col7_3, &col7_4, &col7_5, NULL};
write_worksheet_data(worksheet7, NULL);
.formula = "=SUM(Table8[@[Quarter 1]:[Quarter 4]])"};
lxw_table_column *columns8[] = {&col8_1, &col8_2, &col8_3, &col8_4, &col8_5, &col8_6, NULL};
write_worksheet_data(worksheet8, NULL);
"Table with totals row (but no caption or totals).",
NULL);
.formula = "=SUM(Table9[@[Quarter 1]:[Quarter 4]])"};
lxw_table_column *columns9[] = {&col9_1, &col9_2, &col9_3, &col9_4, &col9_5, &col9_6, NULL};
write_worksheet_data(worksheet9, NULL);
"Table with totals row with user captions and functions.",
NULL);
.total_string = "Totals"};
.formula = "=SUM(Table10[@[Quarter 1]:[Quarter 4]])",
&col10_5, &col10_6, NULL};
write_worksheet_data(worksheet10, NULL);
.total_string = "Totals"};
.formula = "=SUM(Table11[@[Quarter 1]:[Quarter 4]])",
&col11_5, &col11_6, NULL};
.style_type_number = 11,
.columns = columns11
};
write_worksheet_data(worksheet11, NULL);
.total_string = "Totals"};
.formula = "=SUM(Table12[@[Quarter 1]:[Quarter 4]])",
&col12_5, &col12_6, NULL};
.style_type_number = 0,
.columns = columns12
};
write_worksheet_data(worksheet12, NULL);
.total_string = "Totals"};
.format = currency_format};
.format = currency_format};
.format = currency_format};
.format = currency_format};
.formula = "=SUM(Table13[@[Quarter 1]:[Quarter 4]])",
.format = currency_format};
&col13_5, &col13_6, NULL};
write_worksheet_data(worksheet13, currency_format);
}
}
@ LXW_TRUE
Definition: common.h:54
Table columns options.
Definition: worksheet.h:1391
const char * header
Definition: worksheet.h:1395
Worksheet table options.
Definition: worksheet.h:1424
uint8_t first_column
Definition: worksheet.h:1526
uint8_t style_type
Definition: worksheet.h:1599
uint8_t no_banded_rows
Definition: worksheet.h:1495
uint8_t no_header_row
Definition: worksheet.h:1462
lxw_table_column ** columns
Definition: worksheet.h:1629
uint8_t no_autofilter
Definition: worksheet.h:1480
uint8_t total_row
Definition: worksheet.h:1622
Struct to represent an Excel workbook.
Definition: workbook.h:293
Struct to represent an Excel worksheet.
Definition: worksheet.h:2115
#define COLS(cols)
Convert an Excel A:B column range into a (col1, col2) pair.
Definition: utility.h:64
#define RANGE(range)
Convert an Excel A1:B2 range into a (first_row, first_col, last_row, last_col) sequence.
Definition: utility.h:83
#define CELL(cell)
Convert an Excel A1 cell string into a (row, col) pair.
Definition: utility.h:46
lxw_workbook * workbook_new(const char *filename)
Create a new workbook object.
lxw_format * workbook_add_format(lxw_workbook *workbook)
Create a new Format object to formats cells in worksheets.
lxw_error workbook_close(lxw_workbook *workbook)
Close the Workbook object and write the XLSX file.
lxw_worksheet * workbook_add_worksheet(lxw_workbook *workbook, const char *sheetname)
Add a new worksheet to a workbook.
lxw_error worksheet_set_column(lxw_worksheet *worksheet, lxw_col_t first_col, lxw_col_t last_col, double width, lxw_format *format)
Set the properties for one or more columns of cells.
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.
lxw_error worksheet_write_string(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, const char *string, lxw_format *format)
Write a string to a worksheet cell.
@ LXW_TABLE_STYLE_TYPE_LIGHT
Definition: worksheet.h:549
lxw_error worksheet_write_number(lxw_worksheet *worksheet, lxw_row_t row, lxw_col_t col, double number, lxw_format *format)
Write a number to a worksheet cell.
@ LXW_TABLE_FUNCTION_SUM
Definition: worksheet.h:588