1 /*****************************************************************************
2  * Test cases for libxlsxwriter.
3  *
4  * Test to compare output against Excel files.
5  *
6  * Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
7  *
8  */
9 
10 #include "xlsxwriter.h"
11 
main()12 int main() {
13 
14     lxw_workbook  *workbook  = workbook_new("test_table09.xlsx");
15     lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
16 
17     worksheet_set_column(worksheet, COLS("B:K"), 10.288, NULL);
18 
19     worksheet_write_string(worksheet, CELL("A1"), "Column1", NULL);
20     worksheet_write_string(worksheet, CELL("B1"), "Column2", NULL);
21     worksheet_write_string(worksheet, CELL("C1"), "Column3", NULL);
22     worksheet_write_string(worksheet, CELL("D1"), "Column4", NULL);
23     worksheet_write_string(worksheet, CELL("E1"), "Column5", NULL);
24     worksheet_write_string(worksheet, CELL("F1"), "Column6", NULL);
25     worksheet_write_string(worksheet, CELL("G1"), "Column7", NULL);
26     worksheet_write_string(worksheet, CELL("H1"), "Column8", NULL);
27     worksheet_write_string(worksheet, CELL("I1"), "Column9", NULL);
28     worksheet_write_string(worksheet, CELL("J1"), "Column10", NULL);
29     worksheet_write_string(worksheet, CELL("K1"), "Total",   NULL);
30 
31     worksheet_write_number(worksheet, 3, 1, 0, NULL);
32     worksheet_write_number(worksheet, 3, 2, 0, NULL);
33     worksheet_write_number(worksheet, 3, 3, 0, NULL);
34     worksheet_write_number(worksheet, 3, 6, 0, NULL);
35     worksheet_write_number(worksheet, 3, 7, 0, NULL);
36     worksheet_write_number(worksheet, 3, 8, 0, NULL);
37     worksheet_write_number(worksheet, 3, 9, 0, NULL);
38     worksheet_write_number(worksheet, 3, 10, 0, NULL);
39 
40     worksheet_write_number(worksheet, 4, 1, 0, NULL);
41     worksheet_write_number(worksheet, 4, 2, 0, NULL);
42     worksheet_write_number(worksheet, 4, 3, 0, NULL);
43     worksheet_write_number(worksheet, 4, 6, 0, NULL);
44     worksheet_write_number(worksheet, 4, 7, 0, NULL);
45     worksheet_write_number(worksheet, 4, 8, 0, NULL);
46     worksheet_write_number(worksheet, 4, 9, 0, NULL);
47     worksheet_write_number(worksheet, 4, 10, 0, NULL);
48 
49 
50     lxw_table_column col1  = {.total_string = "Total"};
51     lxw_table_column col2  = {0};
52     lxw_table_column col3  = {.total_function = LXW_TABLE_FUNCTION_AVERAGE};
53     lxw_table_column col4  = {.total_function = LXW_TABLE_FUNCTION_COUNT};
54     lxw_table_column col5  = {.total_function = LXW_TABLE_FUNCTION_COUNT_NUMS};
55     lxw_table_column col6  = {.total_function = LXW_TABLE_FUNCTION_MAX};
56     lxw_table_column col7  = {.total_function = LXW_TABLE_FUNCTION_MIN};
57     lxw_table_column col8  = {.total_function = LXW_TABLE_FUNCTION_SUM};
58     lxw_table_column col9  = {.total_function = LXW_TABLE_FUNCTION_STD_DEV};
59     lxw_table_column col10 = {.total_function = LXW_TABLE_FUNCTION_VAR};
60 
61     lxw_table_column *columns[] = {&col1, &col2, &col3, &col4, &col5, &col6, &col7, &col8, &col9, &col10, NULL};
62 
63     lxw_table_options options = {.total_row = LXW_TRUE, .columns = columns};
64 
65 
66     worksheet_add_table(worksheet, RANGE("B3:K6"), &options);
67 
68     return workbook_close(workbook);
69 }
70