功能: 服务端生成完整报告并保护单任务
- 使用 libxlsxwriter 常量内存导出 Excel\n- 增加全局任务占用提示与原始数据持久化\n- 保留运行时任务数据并更新接口文档
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
###############################################################################
|
||||
#
|
||||
# Makefile for libxlsxwriter library.
|
||||
#
|
||||
# Copyright 2014-2015, John McNamara, jmcnamara@cpan.org
|
||||
#
|
||||
|
||||
include ../Makefile.unit
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Test runner for xmlwriter using ctest.
|
||||
*
|
||||
* Copyright 2014-2022 John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
#define CTEST_MAIN
|
||||
|
||||
#include "../ctest.h"
|
||||
|
||||
int main(int argc, const char *argv[])
|
||||
{
|
||||
return ctest_main(argc, argv);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table01) {
|
||||
|
||||
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=\"C3:F13\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"C3:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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;
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F13"), NULL);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table02) {
|
||||
|
||||
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=\"D4:I15\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"D4:I15\"/>"
|
||||
"<tableColumns count=\"6\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"<tableColumn id=\"5\" name=\"Column5\"/>"
|
||||
"<tableColumn id=\"6\" name=\"Column6\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleLight17\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.style_type = LXW_TABLE_STYLE_TYPE_LIGHT, .style_type_number = 17};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("D4:I15"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table04) {
|
||||
|
||||
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=\"C3:F13\" totalsRowShown=\"0\">"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.no_autofilter = LXW_TRUE};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F13"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table05) {
|
||||
|
||||
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=\"C4:F13\" headerRowCount=\"0\" totalsRowShown=\"0\">"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.no_header_row = LXW_TRUE};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C4:F13"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table06) {
|
||||
|
||||
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=\"C3:F13\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"C3:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Foo\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Baz\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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_column col1 = {.header = "Foo"};
|
||||
lxw_table_column col2 = {0};
|
||||
lxw_table_column col3 = {0};
|
||||
lxw_table_column col4 = {.header = "Baz"};
|
||||
lxw_table_column *columns[] = {&col1, &col2, &col3, &col4, NULL};
|
||||
|
||||
lxw_table_options options = {.columns = columns};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F13"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table07) {
|
||||
|
||||
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=\"C3:F14\" totalsRowCount=\"1\">"
|
||||
"<autoFilter ref=\"C3:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.total_row = LXW_TRUE};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F14"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table08) {
|
||||
|
||||
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=\"C3:F14\" totalsRowCount=\"1\">"
|
||||
"<autoFilter ref=\"C3:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\" totalsRowLabel=\"Total\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\" totalsRowFunction=\"count\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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_column col1 = {.total_string = "Total"};
|
||||
lxw_table_column col2 = {0};
|
||||
lxw_table_column col3 = {0};
|
||||
lxw_table_column col4 = {.total_function = LXW_TABLE_FUNCTION_COUNT};
|
||||
lxw_table_column *columns[] = {&col1, &col2, &col3, &col4, NULL};
|
||||
|
||||
lxw_table_options options = {.total_row = LXW_TRUE, .columns = columns};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F14"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table09) {
|
||||
|
||||
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=\"B2:K8\" totalsRowCount=\"1\">"
|
||||
"<autoFilter ref=\"B2:K7\"/>"
|
||||
"<tableColumns count=\"10\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\" totalsRowLabel=\"Total\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\" totalsRowFunction=\"average\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\" totalsRowFunction=\"count\"/>"
|
||||
"<tableColumn id=\"5\" name=\"Column5\" totalsRowFunction=\"countNums\"/>"
|
||||
"<tableColumn id=\"6\" name=\"Column6\" totalsRowFunction=\"max\"/>"
|
||||
"<tableColumn id=\"7\" name=\"Column7\" totalsRowFunction=\"min\"/>"
|
||||
"<tableColumn id=\"8\" name=\"Column8\" totalsRowFunction=\"sum\"/>"
|
||||
"<tableColumn id=\"9\" name=\"Column9\" totalsRowFunction=\"stdDev\"/>"
|
||||
"<tableColumn id=\"10\" name=\"Column10\" totalsRowFunction=\"var\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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_column col1 = {.total_string = "Total"};
|
||||
lxw_table_column col2 = {0};
|
||||
lxw_table_column col3 = {.total_function = LXW_TABLE_FUNCTION_AVERAGE};
|
||||
lxw_table_column col4 = {.total_function = LXW_TABLE_FUNCTION_COUNT};
|
||||
lxw_table_column col5 = {.total_function = LXW_TABLE_FUNCTION_COUNT_NUMS};
|
||||
lxw_table_column col6 = {.total_function = LXW_TABLE_FUNCTION_MAX};
|
||||
lxw_table_column col7 = {.total_function = LXW_TABLE_FUNCTION_MIN};
|
||||
lxw_table_column col8 = {.total_function = LXW_TABLE_FUNCTION_SUM};
|
||||
lxw_table_column col9 = {.total_function = LXW_TABLE_FUNCTION_STD_DEV};
|
||||
lxw_table_column col10 = {.total_function = LXW_TABLE_FUNCTION_VAR};
|
||||
|
||||
lxw_table_column *columns[] = {&col1, &col2, &col3, &col4, &col5, &col6, &col7, &col8, &col9, &col10, NULL};
|
||||
|
||||
lxw_table_options options = {.total_row = LXW_TRUE, .columns = columns};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("B2:K8"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table10) {
|
||||
|
||||
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=\"MyTable\" displayName=\"MyTable\" ref=\"C2:F13\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"C2:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.name = "MyTable"};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C2:F13"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table11) {
|
||||
|
||||
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=\"C3:F13\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"C3:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.style_type = LXW_TABLE_STYLE_TYPE_LIGHT, .style_type_number = 0};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F13"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table12) {
|
||||
|
||||
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=\"C3:F13\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"C3:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium1\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.style_type = LXW_TABLE_STYLE_TYPE_MEDIUM, .style_type_number = 1};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F13"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table13) {
|
||||
|
||||
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=\"C3:F13\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"C3:F13\"/>"
|
||||
"<tableColumns count=\"4\">"
|
||||
"<tableColumn id=\"1\" name=\"Column1\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Column2\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Column3\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Column4\"/>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleDark11\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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 = {.style_type = LXW_TABLE_STYLE_TYPE_DARK, .style_type_number = 11};
|
||||
|
||||
worksheet_add_table(worksheet, RANGE("C3:F13"), &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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table14) {
|
||||
|
||||
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=\"B3:G7\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"B3:G7\"/>"
|
||||
"<tableColumns count=\"6\">"
|
||||
"<tableColumn id=\"1\" name=\"Product\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Quarter 1\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Quarter 2\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Quarter 3\"/>"
|
||||
"<tableColumn id=\"5\" name=\"Quarter 4\"/>"
|
||||
"<tableColumn id=\"6\" name=\"Year\">"
|
||||
"<calculatedColumnFormula>SUM(Table1[[#This Row],[Quarter 1]:[Quarter 4]])</calculatedColumnFormula>"
|
||||
"</tableColumn>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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;
|
||||
|
||||
/* Set the table options. */
|
||||
lxw_table_column col8_1 = {.header = "Product"};
|
||||
lxw_table_column col8_2 = {.header = "Quarter 1"};
|
||||
lxw_table_column col8_3 = {.header = "Quarter 2"};
|
||||
lxw_table_column col8_4 = {.header = "Quarter 3"};
|
||||
lxw_table_column col8_5 = {.header = "Quarter 4"};
|
||||
lxw_table_column col8_6 = {.header = "Year",
|
||||
.formula = "=SUM(Table1[@[Quarter 1]:[Quarter 4]])"};
|
||||
|
||||
lxw_table_column *columns8[] = {&col8_1, &col8_2, &col8_3, &col8_4, &col8_5, &col8_6, NULL};
|
||||
|
||||
lxw_table_options options8 = {.columns = columns8};
|
||||
|
||||
/* Add a table to the worksheet. */
|
||||
worksheet_add_table(worksheet, RANGE("B3:G7"), &options8);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, 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_table15) {
|
||||
|
||||
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=\"B3:G7\" totalsRowShown=\"0\">"
|
||||
"<autoFilter ref=\"B3:G7\"/>"
|
||||
"<tableColumns count=\"6\">"
|
||||
"<tableColumn id=\"1\" name=\"Product\"/>"
|
||||
"<tableColumn id=\"2\" name=\"Quarter 1\"/>"
|
||||
"<tableColumn id=\"3\" name=\"Quarter 2\"/>"
|
||||
"<tableColumn id=\"4\" name=\"Quarter 3\"/>"
|
||||
"<tableColumn id=\"5\" name=\"Quarter 4\"/>"
|
||||
"<tableColumn id=\"6\" name=\"Year\">"
|
||||
"<calculatedColumnFormula>[#This Row],[#This Row], [#This Row], [#This Row],[#This Row],</calculatedColumnFormula>"
|
||||
"</tableColumn>"
|
||||
"</tableColumns>"
|
||||
"<tableStyleInfo name=\"TableStyleMedium9\" showFirstColumn=\"0\" showLastColumn=\"0\" showRowStripes=\"1\" showColumnStripes=\"0\"/>"
|
||||
"</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;
|
||||
|
||||
/* Set the table options. */
|
||||
lxw_table_column col8_1 = {.header = "Product"};
|
||||
lxw_table_column col8_2 = {.header = "Quarter 1"};
|
||||
lxw_table_column col8_3 = {.header = "Quarter 2"};
|
||||
lxw_table_column col8_4 = {.header = "Quarter 3"};
|
||||
lxw_table_column col8_5 = {.header = "Quarter 4"};
|
||||
lxw_table_column col8_6 = {.header = "Year",
|
||||
.formula = "@@ @ @@"};
|
||||
|
||||
lxw_table_column *columns8[] = {&col8_1, &col8_2, &col8_3, &col8_4, &col8_5, &col8_6, NULL};
|
||||
|
||||
lxw_table_options options8 = {.columns = columns8};
|
||||
|
||||
/* Add a table to the worksheet. */
|
||||
worksheet_add_table(worksheet, RANGE("B3:G7"), &options8);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
* Tests for the libxlsxwriter library.
|
||||
*
|
||||
* Copyright 2014-2022, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "../ctest.h"
|
||||
#include "../helper.h"
|
||||
|
||||
#include "xlsxwriter/table.h"
|
||||
|
||||
// Test _xml_declaration().
|
||||
CTEST(table, xml_declaration) {
|
||||
|
||||
char* got;
|
||||
char exp[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
|
||||
FILE* testfile = tmpfile();
|
||||
|
||||
lxw_table *table = lxw_table_new();
|
||||
table->file = testfile;
|
||||
|
||||
_table_xml_declaration(table);
|
||||
|
||||
RUN_XLSX_STREQ(exp, got);
|
||||
|
||||
lxw_table_free(table);
|
||||
}
|
||||
Reference in New Issue
Block a user