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
|
|
@ -244,15 +244,17 @@ typedef struct lxw_chart_line {
|
|||
|
||||
lxw_color_t color;
|
||||
uint8_t none;
|
||||
uint8_t dash_type;
|
||||
uint8_t has_color;
|
||||
float width;
|
||||
uint8_t dash_type;
|
||||
uint8_t transparency;
|
||||
uint8_t has_color;
|
||||
|
||||
} lxw_chart_line;
|
||||
|
||||
typedef struct lxw_chart_fill {
|
||||
|
||||
lxw_color_t color;
|
||||
uint8_t none;
|
||||
uint8_t transparency;
|
||||
uint8_t has_color;
|
||||
|
||||
|
|
@ -331,6 +333,7 @@ typedef struct lxw_chart_series {
|
|||
lxw_series_range *values;
|
||||
lxw_chart_title title;
|
||||
lxw_chart_line *line;
|
||||
lxw_chart_fill *fill;
|
||||
|
||||
STAILQ_ENTRY (lxw_chart_series) list_pointers;
|
||||
|
||||
|
|
@ -633,6 +636,8 @@ void chart_series_set_name_range(lxw_chart_series *series,
|
|||
|
||||
void chart_series_set_line(lxw_chart_series *series, lxw_chart_line *line);
|
||||
|
||||
void chart_series_set_fill(lxw_chart_series *series, lxw_chart_fill *fill);
|
||||
|
||||
/**
|
||||
* @brief Set the name caption of the an axis.
|
||||
*
|
||||
|
|
|
|||
82
src/chart.c
82
src/chart.c
|
|
@ -57,6 +57,7 @@ _chart_series_free(lxw_chart_series *series)
|
|||
|
||||
free(series->title.name);
|
||||
free(series->line);
|
||||
free(series->fill);
|
||||
|
||||
_chart_free_range(series->categories);
|
||||
_chart_free_range(series->values);
|
||||
|
|
@ -237,8 +238,10 @@ _chart_convert_font_args(lxw_chart_font *user_font)
|
|||
if (font->rotation)
|
||||
font->rotation = font->rotation * 60000;
|
||||
|
||||
if (font->color)
|
||||
if (font->color) {
|
||||
font->color = lxw_format_check_color(font->color);
|
||||
font->has_color = LXW_TRUE;
|
||||
}
|
||||
|
||||
return font;
|
||||
}
|
||||
|
|
@ -259,12 +262,44 @@ _chart_convert_line_args(lxw_chart_line *user_line)
|
|||
|
||||
memcpy(line, user_line, sizeof(lxw_chart_line));
|
||||
|
||||
if (line->color)
|
||||
if (line->color) {
|
||||
line->color = lxw_format_check_color(line->color);
|
||||
line->has_color = LXW_TRUE;
|
||||
}
|
||||
|
||||
if (line->transparency > 100)
|
||||
line->transparency = 0;
|
||||
|
||||
return line;
|
||||
}
|
||||
|
||||
/*
|
||||
* Create a copy of a user supplied fill.
|
||||
*/
|
||||
STATIC lxw_chart_fill *
|
||||
_chart_convert_fill_args(lxw_chart_fill *user_fill)
|
||||
{
|
||||
lxw_chart_fill *fill;
|
||||
|
||||
if (!user_fill)
|
||||
return NULL;
|
||||
|
||||
fill = calloc(1, sizeof(struct lxw_chart_fill));
|
||||
RETURN_ON_MEM_ERROR(fill, NULL);
|
||||
|
||||
memcpy(fill, user_fill, sizeof(lxw_chart_fill));
|
||||
|
||||
if (fill->color) {
|
||||
fill->color = lxw_format_check_color(fill->color);
|
||||
fill->has_color = LXW_TRUE;
|
||||
}
|
||||
|
||||
if (fill->transparency > 100)
|
||||
fill->transparency = 0;
|
||||
|
||||
return fill;
|
||||
}
|
||||
|
||||
/*
|
||||
* Add unique ids for primary or secondary axes.
|
||||
*/
|
||||
|
|
@ -494,7 +529,7 @@ _chart_write_a_alpha(lxw_chart *self, uint8_t transparency)
|
|||
{
|
||||
struct xml_attribute_list attributes;
|
||||
struct xml_attribute *attribute;
|
||||
uint16_t val;
|
||||
uint32_t val;
|
||||
|
||||
LXW_INIT_ATTRIBUTES();
|
||||
|
||||
|
|
@ -1408,7 +1443,7 @@ _chart_write_a_ln(lxw_chart *self, lxw_chart_line *line)
|
|||
}
|
||||
else if (line->has_color) {
|
||||
/* Write the a:solidFill element. */
|
||||
_chart_write_a_solid_fill(self, line->color, LXW_FALSE);
|
||||
_chart_write_a_solid_fill(self, line->color, line->transparency);
|
||||
}
|
||||
|
||||
/* Write the line/dash type. */
|
||||
|
|
@ -1429,13 +1464,28 @@ STATIC void
|
|||
_chart_write_sp_pr(lxw_chart *self, lxw_chart_series *series)
|
||||
{
|
||||
|
||||
if (!series->line)
|
||||
if (!series->line && !series->fill)
|
||||
return;
|
||||
|
||||
lxw_xml_start_tag(self->file, "c:spPr", NULL);
|
||||
|
||||
/* Write the series fill. */
|
||||
if (series->fill) {
|
||||
lxw_chart_fill *fill = series->fill;
|
||||
if (fill->none) {
|
||||
/* Write the a:noFill element. */
|
||||
_chart_write_a_no_fill(self);
|
||||
}
|
||||
else {
|
||||
/* Write the a:solidFill element. */
|
||||
_chart_write_a_solid_fill(self, fill->color, fill->transparency);
|
||||
}
|
||||
}
|
||||
|
||||
if (series->line) {
|
||||
/* Write the a:ln element. */
|
||||
_chart_write_a_ln(self, series->line);
|
||||
}
|
||||
|
||||
lxw_xml_end_tag(self->file, "c:spPr");
|
||||
}
|
||||
|
|
@ -2587,8 +2637,14 @@ _chart_write_scatter_chart(lxw_chart *self)
|
|||
* it has already been specified by the user.*/
|
||||
if (self->type == LXW_CHART_SCATTER) {
|
||||
if (!series->line) {
|
||||
lxw_chart_line line =
|
||||
{ 0x000000, LXW_TRUE, 0x0, LXW_FALSE, 2.25 };
|
||||
lxw_chart_line line = {
|
||||
0x000000,
|
||||
LXW_TRUE,
|
||||
2.25,
|
||||
LXW_CHART_LINE_DASH_SOLID,
|
||||
0,
|
||||
LXW_FALSE
|
||||
};
|
||||
series->line = _chart_convert_line_args(&line);
|
||||
}
|
||||
}
|
||||
|
|
@ -3147,6 +3203,18 @@ chart_series_set_line(lxw_chart_series *series, lxw_chart_line *line)
|
|||
series->line = _chart_convert_line_args(line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set a fill type for a series.
|
||||
*/
|
||||
void
|
||||
chart_series_set_fill(lxw_chart_series *series, lxw_chart_fill *fill)
|
||||
{
|
||||
if (!fill)
|
||||
return;
|
||||
|
||||
series->fill = _chart_convert_fill_args(fill);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set an axis caption.
|
||||
*/
|
||||
|
|
|
|||
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