初始化PHP-Xlswrite扩展

This commit is contained in:
ykxiao
2024-03-05 10:01:08 +08:00
commit 879cf9584d
2483 changed files with 1054962 additions and 0 deletions

View File

@ -0,0 +1,15 @@
/*
* Test runner for xmlwriter using ctest.
*
* Copyright 2014-2021 John McNamara, jmcnamara@cpan.org
*
*/
#define CTEST_MAIN
#include "../ctest.h"
int main(int argc, const char *argv[])
{
return ctest_main(argc, argv);
}

View File

@ -0,0 +1,40 @@
/*
* Tests for the lib_xlsx_writer library.
*
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
*
*/
#include "../ctest.h"
#include "../helper.h"
#include "../../../include/xlsxwriter/chartsheet.h"
#include "../../../include/xlsxwriter/drawing.h"
// Test assembling a complete Chartsheet file.
CTEST(chartsheet, chartsheet) {
char* got;
char exp[] =
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
"<chartsheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\">"
"<sheetPr/>"
"<sheetViews>"
"<sheetView workbookViewId=\"0\"/>"
"</sheetViews>"
"<pageMargins left=\"0.7\" right=\"0.7\" top=\"0.75\" bottom=\"0.75\" header=\"0.3\" footer=\"0.3\"/>"
"<drawing r:id=\"rId1\"/>"
"</chartsheet>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->drawing = lxw_drawing_new();
lxw_chartsheet_assemble_xml_file(chartsheet);
RUN_XLSX_STREQ_SHORT(exp, got);
lxw_chartsheet_free(chartsheet);
}

View File

@ -0,0 +1,169 @@
/*
* Tests for the lib_xlsx_writer library.
*
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
*
*/
#include "../ctest.h"
#include "../helper.h"
#include "../../../include/xlsxwriter/chartsheet.h"
/* 1. Test the _write_sheet_protection() method. */
CTEST(chartsheet, write_write_sheet_protection01) {
char* got;
char exp[] = "<sheetProtection content=\"1\" objects=\"1\"/>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->file = testfile;
chartsheet_protect(chartsheet, NULL, NULL);
_chartsheet_write_sheet_protection(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}
/* 2. Test the _write_sheet_protection() method. */
CTEST(chartsheet, write_write_sheet_protection02) {
char* got;
char exp[] = "<sheetProtection password=\"83AF\" content=\"1\" objects=\"1\"/>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->file = testfile;
chartsheet_protect(chartsheet, "password", NULL);
_chartsheet_write_sheet_protection(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}
/* 3. Test the _write_sheet_protection() method. */
CTEST(chartsheet, write_write_sheet_protection03) {
char* got;
char exp[] = "<sheetProtection content=\"1\"/>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->file = testfile;
lxw_protection options = {.no_objects = 1};
chartsheet_protect(chartsheet, NULL, &options);
_chartsheet_write_sheet_protection(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}
/* 4. Test the _write_sheet_protection() method. */
CTEST(chartsheet, write_write_sheet_protection04) {
char* got;
char exp[] = "<sheetProtection objects=\"1\"/>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->file = testfile;
lxw_protection options = {.no_content = 1};
chartsheet_protect(chartsheet, NULL, &options);
_chartsheet_write_sheet_protection(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}
/* 5. Test the _write_sheet_protection() method. */
CTEST(chartsheet, write_write_sheet_protection05) {
char* got;
char exp[] = "";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->file = testfile;
lxw_protection options = {.no_content = 1, .no_objects = 1};
chartsheet_protect(chartsheet, NULL, &options);
_chartsheet_write_sheet_protection(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}
/* 6. Test the _write_sheet_protection() method. */
CTEST(chartsheet, write_write_sheet_protection06) {
char* got;
char exp[] = "<sheetProtection password=\"83AF\"/>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->file = testfile;
lxw_protection options = {.no_content = 1, .no_objects = 1};
chartsheet_protect(chartsheet, "password", &options);
_chartsheet_write_sheet_protection(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}
/* 7. Test the _write_sheet_protection() method. */
CTEST(chartsheet, write_write_sheet_protection07) {
char* got;
char exp[] = "<sheetProtection password=\"83AF\" content=\"1\" objects=\"1\"/>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
chartsheet->worksheet->file = testfile;
lxw_protection options = {
.objects = 1,
.scenarios = 1,
.format_cells = 1,
.format_columns = 1,
.format_rows = 1,
.insert_columns = 1,
.insert_rows = 1,
.insert_hyperlinks = 1,
.delete_columns = 1,
.delete_rows = 1,
.no_select_locked_cells = 1,
.sort = 1,
.autofilter = 1,
.pivot_tables = 1,
.no_select_unlocked_cells = 1,
};
chartsheet_protect(chartsheet, "password", &options);
_chartsheet_write_sheet_protection(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}

View File

@ -0,0 +1,28 @@
/*
* Tests for the libxlsxwriter library.
*
* Copyright 2014-2021, John McNamara, jmcnamara@cpan.org
*
*/
#include "../ctest.h"
#include "../helper.h"
#include "../../../include/xlsxwriter/chartsheet.h"
// Test _xml_declaration().
CTEST(chartsheet, xml_declaration) {
char* got;
char exp[] = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n";
FILE* testfile = tmpfile();
lxw_chartsheet *chartsheet = lxw_chartsheet_new(NULL);
chartsheet->file = testfile;
_chartsheet_xml_declaration(chartsheet);
RUN_XLSX_STREQ(exp, got);
lxw_chartsheet_free(chartsheet);
}