mirror of
https://github.com/jmcnamara/libxlsxwriter.git
synced 2026-05-21 06:45:21 -06:00
Add chart series fill support.
This commit is contained in:
parent
e3d653fb79
commit
78bef13a49
20 changed files with 525 additions and 12 deletions
55
test/functional/src/test_chart_format03.c
Normal file
55
test/functional/src/test_chart_format03.c
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format03.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 46175744;
|
||||
chart->axis_id_2 = 46319488;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$B$1:$B$5"
|
||||
);
|
||||
|
||||
chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$C$1:$C$5"
|
||||
);
|
||||
|
||||
lxw_chart_line line = {.color = LXW_COLOR_YELLOW};
|
||||
lxw_chart_fill fill = {.color = LXW_COLOR_RED};
|
||||
|
||||
chart_series_set_line(series1, &line);
|
||||
chart_series_set_fill(series1, &fill);
|
||||
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
54
test/functional/src/test_chart_format04.c
Normal file
54
test/functional/src/test_chart_format04.c
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format04.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 46175744;
|
||||
chart->axis_id_2 = 46319488;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$B$1:$B$5"
|
||||
);
|
||||
|
||||
chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$C$1:$C$5"
|
||||
);
|
||||
|
||||
lxw_chart_fill fill = {.color = 0xFF0000};
|
||||
|
||||
|
||||
chart_series_set_fill(series1, &fill);
|
||||
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
|
|
@ -42,7 +42,9 @@ int main() {
|
|||
"=Sheet1!$C$1:$C$5"
|
||||
);
|
||||
|
||||
lxw_chart_line line = {.color = LXW_COLOR_RED, .width = 1.25, .dash_type = LXW_CHART_LINE_DASH_SQUARE_DOT};
|
||||
lxw_chart_line line = {.color = LXW_COLOR_RED,
|
||||
.width = 1.25,
|
||||
.dash_type = LXW_CHART_LINE_DASH_SQUARE_DOT};
|
||||
|
||||
chart_series_set_line(series1, &line);
|
||||
|
||||
|
|
|
|||
45
test/functional/src/test_chart_format17.c
Normal file
45
test/functional/src/test_chart_format17.c
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format17.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 42379520;
|
||||
chart->axis_id_2 = 47284608;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5");
|
||||
chart_add_series(chart, NULL, "=Sheet1!$B$1:$B$5");
|
||||
chart_add_series(chart, NULL, "=Sheet1!$C$1:$C$5");
|
||||
|
||||
lxw_chart_fill fill = {.none = LXW_TRUE};
|
||||
chart_series_set_fill(series1, &fill);
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
48
test/functional/src/test_chart_format18.c
Normal file
48
test/functional/src/test_chart_format18.c
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format18.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 42379520;
|
||||
chart->axis_id_2 = 47284608;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5");
|
||||
chart_add_series(chart, NULL, "=Sheet1!$B$1:$B$5");
|
||||
chart_add_series(chart, NULL, "=Sheet1!$C$1:$C$5");
|
||||
|
||||
lxw_chart_line line = {.none = LXW_TRUE};
|
||||
lxw_chart_fill fill = {.none = LXW_TRUE};
|
||||
|
||||
chart_series_set_line(series1, &line);
|
||||
chart_series_set_fill(series1, &fill);
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
54
test/functional/src/test_chart_format21.c
Normal file
54
test/functional/src/test_chart_format21.c
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format21.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 115390336;
|
||||
chart->axis_id_2 = 115417856;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$B$1:$B$5"
|
||||
);
|
||||
|
||||
chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$C$1:$C$5"
|
||||
);
|
||||
|
||||
lxw_chart_line line = {.color = LXW_COLOR_YELLOW};
|
||||
lxw_chart_fill fill = {.color = LXW_COLOR_RED, .transparency = 24};
|
||||
|
||||
chart_series_set_line(series1, &line);
|
||||
chart_series_set_fill(series1, &fill);
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
54
test/functional/src/test_chart_format22.c
Normal file
54
test/functional/src/test_chart_format22.c
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format22.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 108321024;
|
||||
chart->axis_id_2 = 108328448;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$B$1:$B$5"
|
||||
);
|
||||
|
||||
chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$C$1:$C$5"
|
||||
);
|
||||
|
||||
lxw_chart_line line = {.color = LXW_COLOR_YELLOW};
|
||||
lxw_chart_fill fill = {.color = LXW_COLOR_RED, .transparency = 1};
|
||||
|
||||
chart_series_set_line(series1, &line);
|
||||
chart_series_set_fill(series1, &fill);
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
54
test/functional/src/test_chart_format23.c
Normal file
54
test/functional/src/test_chart_format23.c
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format23.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 108321024;
|
||||
chart->axis_id_2 = 108328448;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$B$1:$B$5"
|
||||
);
|
||||
|
||||
chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$C$1:$C$5"
|
||||
);
|
||||
|
||||
lxw_chart_line line = {.color = LXW_COLOR_YELLOW};
|
||||
lxw_chart_fill fill = {.color = LXW_COLOR_RED, .transparency = 100};
|
||||
|
||||
chart_series_set_line(series1, &line);
|
||||
chart_series_set_fill(series1, &fill);
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
52
test/functional/src/test_chart_format25.c
Normal file
52
test/functional/src/test_chart_format25.c
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*****************************************************************************
|
||||
* Test cases for libxlsxwriter.
|
||||
*
|
||||
* Test to compare output against Excel files.
|
||||
*
|
||||
* Copyright 2014-2017, John McNamara, jmcnamara@cpan.org
|
||||
*
|
||||
*/
|
||||
|
||||
#include "xlsxwriter.h"
|
||||
|
||||
int main() {
|
||||
|
||||
lxw_workbook *workbook = new_workbook("test_chart_format25.xlsx");
|
||||
lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
|
||||
lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN);
|
||||
|
||||
/* For testing, copy the randomly generated axis ids in the target file. */
|
||||
chart->axis_id_1 = 108178048;
|
||||
chart->axis_id_2 = 108319488;
|
||||
|
||||
uint8_t data[5][3] = {
|
||||
{1, 2, 3},
|
||||
{2, 4, 6},
|
||||
{3, 6, 9},
|
||||
{4, 8, 12},
|
||||
{5, 10, 15}
|
||||
};
|
||||
|
||||
int row, col;
|
||||
for (row = 0; row < 5; row++)
|
||||
for (col = 0; col < 3; col++)
|
||||
worksheet_write_number(worksheet, row, col, data[row][col], NULL);
|
||||
|
||||
lxw_chart_series *series1 = chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$B$1:$B$5"
|
||||
);
|
||||
|
||||
chart_add_series(chart,
|
||||
"=Sheet1!$A$1:$A$5",
|
||||
"=Sheet1!$C$1:$C$5"
|
||||
);
|
||||
|
||||
lxw_chart_line line = {.color = LXW_COLOR_RED, .transparency = 50};
|
||||
|
||||
chart_series_set_line(series1, &line);
|
||||
|
||||
worksheet_insert_chart(worksheet, CELL("E9"), chart);
|
||||
|
||||
return workbook_close(workbook);
|
||||
}
|
||||
|
|
@ -19,7 +19,29 @@ class TestCompareXLSXFiles(base_test_class.XLSXBaseTest):
|
|||
def test_chart_format02(self):
|
||||
self.run_exe_test('test_chart_format02')
|
||||
|
||||
def test_chart_format03(self):
|
||||
self.run_exe_test('test_chart_format03')
|
||||
|
||||
def test_chart_format04(self):
|
||||
self.run_exe_test('test_chart_format04')
|
||||
|
||||
def test_chart_format09(self):
|
||||
self.run_exe_test('test_chart_format09')
|
||||
|
||||
def test_chart_format17(self):
|
||||
self.run_exe_test('test_chart_format17')
|
||||
|
||||
def test_chart_format18(self):
|
||||
self.run_exe_test('test_chart_format18')
|
||||
|
||||
def test_chart_format21(self):
|
||||
self.run_exe_test('test_chart_format21')
|
||||
|
||||
def test_chart_format22(self):
|
||||
self.run_exe_test('test_chart_format22')
|
||||
|
||||
def test_chart_format23(self):
|
||||
self.run_exe_test('test_chart_format23')
|
||||
|
||||
def test_chart_format25(self):
|
||||
self.run_exe_test('test_chart_format25')
|
||||
|
|
|
|||
BIN
test/functional/xlsx_files/chart_format03.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format03.xlsx
Normal file
Binary file not shown.
BIN
test/functional/xlsx_files/chart_format04.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format04.xlsx
Normal file
Binary file not shown.
BIN
test/functional/xlsx_files/chart_format17.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format17.xlsx
Normal file
Binary file not shown.
BIN
test/functional/xlsx_files/chart_format18.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format18.xlsx
Normal file
Binary file not shown.
BIN
test/functional/xlsx_files/chart_format21.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format21.xlsx
Normal file
Binary file not shown.
BIN
test/functional/xlsx_files/chart_format22.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format22.xlsx
Normal file
Binary file not shown.
BIN
test/functional/xlsx_files/chart_format23.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format23.xlsx
Normal file
Binary file not shown.
BIN
test/functional/xlsx_files/chart_format25.xlsx
Normal file
BIN
test/functional/xlsx_files/chart_format25.xlsx
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue