1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
|
/*
* Tests for the libxlsxwriter library.
*
* SPDX-License-Identifier: BSD-2-Clause
* Copyright 2014-2026, John McNamara, jmcnamara@cpan.org.
*
*/
#include "../ctest.h"
#include "../helper.h"
#include "../../../include/xlsxwriter/worksheet.h"
#include "../../../include/xlsxwriter/table.h"
// Test assembling a complete Table file.
CTEST(worksheet, worksheet_table03) {
char* got;
char exp[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
"<table xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" id=\"1\" name=\"Table1\" displayName=\"Table1\" ref=\"C5:D16\" totalsRowShown=\"0\">"
"<autoFilter ref=\"C5:D16\"/>"
"<tableColumns count=\"2\">"
"<tableColumn id=\"1\" name=\"Column1\"/>"
"<tableColumn id=\"2\" name=\"Column2\"/>"
"</tableColumns>"
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"1\" showLastColumn=\"1\" showRowStripes=\"0\" showColumnStripes=\"1\"/>"
"</table>";
FILE* testfile = lxw_tmpfile(NULL);
FILE* testfile2 = lxw_tmpfile(NULL);
lxw_worksheet *worksheet = lxw_worksheet_new(NULL);
worksheet->file = testfile2;
worksheet->sst = lxw_sst_new();
lxw_table *table = lxw_table_new();
table->file = testfile;
lxw_table_options options = {.first_column = LXW_TRUE, .last_column = LXW_TRUE, .no_banded_rows = LXW_TRUE, .banded_columns = LXW_TRUE};
worksheet_add_table(worksheet, RANGE("C5:D16"), &options);
table->table_obj = STAILQ_FIRST(worksheet->table_objs);
table->table_obj->id = 1;
lxw_table_assemble_xml_file(table);
RUN_XLSX_STREQ_SHORT(exp, got);
lxw_worksheet_free(worksheet);
lxw_table_free(table);
}
|