int main() { lxw_workbook *workbook = new_workbook("test_chart_axis25.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 = 47471232; chart->axis_id_2 = 48509696; 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); 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"); chart_axis_set_num_format(chart->x_axis, "[$¥-411]#,##0.00"); chart_axis_set_num_format(chart->y_axis, "0.00%"); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_format51.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_format *format; double value = 123.456; worksheet_set_column(worksheet, 0, 0, 12, NULL); format = workbook_add_format(workbook); format_set_num_format(format, "0.0"); worksheet_write_number(worksheet, 0, 0, value, format); format = workbook_add_format(workbook); format_set_num_format(format, "0.000"); worksheet_write_number(worksheet, 1, 0, value, format); format = workbook_add_format(workbook); format_set_num_format(format, "0.0000"); worksheet_write_number(worksheet, 2, 0, value, format); format = workbook_add_format(workbook); format_set_num_format(format, "0.00000"); worksheet_write_number(worksheet, 3, 0, value, format); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_legend03.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_LINE); /* For testing, copy the randomly generated axis ids in the target file. */ chart->axis_id_1 = 93548928; chart->axis_id_2 = 93550464; 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); 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"); chart_legend_set_position(chart, LXW_CHART_LEGEND_TOP_RIGHT); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_format02.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_format *format1 = workbook_add_format(workbook); lxw_format *format2 = workbook_add_format(workbook); worksheet_set_row(worksheet, 0, 30, NULL, NULL); format_set_font_name(format1, "Arial"); format_set_bold(format1); format_set_align(format1, LXW_ALIGN_LEFT); format_set_align(format1, LXW_ALIGN_VERTICAL_BOTTOM); format_set_font_name(format2, "Arial"); format_set_bold(format2); format_set_rotation(format2, 90); format_set_align(format2, LXW_ALIGN_CENTER); format_set_align(format2, LXW_ALIGN_VERTICAL_BOTTOM); worksheet_write_string(worksheet, 0, 0, "Foo", format1); worksheet_write_string(worksheet, 0, 1, "Bar", format2); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_size01.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 = 61355904; chart->axis_id_2 = 61365248; 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); 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_image_options options = {.x_scale = 1.06666667, .y_scale = 1.11111112}; worksheet_insert_chart_opt(worksheet, CELL("E9"), chart, &options); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_display_units11.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 = 69559424; chart->axis_id_2 = 69560960; worksheet_write_number(worksheet, 0, 0, 10000000, NULL); worksheet_write_number(worksheet, 1, 0, 20000000, NULL); worksheet_write_number(worksheet, 2, 0, 30000000, NULL); worksheet_write_number(worksheet, 3, 0, 20000000, NULL); worksheet_write_number(worksheet, 4, 0, 10000000, NULL); chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5"); chart_axis_set_display_units(chart->y_axis, LXW_CHART_AXIS_UNITS_HUNDREDS); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_blank03.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_LINE); /* For testing, copy the randomly generated axis ids in the target file. */ chart->axis_id_1 = 44253568; chart->axis_id_2 = 44269952; 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); 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"); chart_show_blanks_as(chart, LXW_CHART_BLANKS_AS_CONNECTED); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_format19.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN_STACKED); /* For testing, copy the randomly generated axis ids in the target file. */ chart->axis_id_1 = 56127488; chart->axis_id_2 = 57455360; 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); chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5"); chart_add_series(chart, NULL, "=Sheet1!$B$1:$B$5"); lxw_chart_series *series = chart_add_series(chart, NULL, "=Sheet1!$C$1:$C$5"); chart_series_set_labels(series); chart_series_set_labels_position(series, LXW_CHART_LABEL_POSITION_INSIDE_BASE); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { /* Create a new workbook and add a worksheet. */ lxw_workbook *workbook = workbook_new("hide_row_col.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_row_t row; /* Write some data. */ worksheet_write_string(worksheet, 0, 3, "Some hidden columns.", NULL); worksheet_write_string(worksheet, 7, 0, "Some hidden rows.", NULL); /* Hide all rows without data. */ worksheet_set_default_row(worksheet, 15, LXW_TRUE); /* Set the height of empty rows that we do want to display even if it is */ /* the default height. */ for (row = 1; row <= 6; row++) worksheet_set_row(worksheet, row, 15, NULL); /* Columns can be hidden explicitly. This doesn't increase the file size. */ lxw_row_col_options options = {.hidden = 1}; worksheet_set_column_opt(worksheet, COLS("G:XFD"), 8.43, NULL, &options); workbook_close(workbook); return 0; }
int main() { lxw_workbook *workbook = new_workbook("test_chart_bar02.xlsx"); lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL); lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_BAR); /* For testing, copy the randomly generated axis ids in the target file. */ chart->axis_id_1 = 93218304; chart->axis_id_2 = 93219840; 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(worksheet2, row, col, data[row][col] , NULL); worksheet_write_string(worksheet1, CELL("A1"), "Foo" , NULL); chart_add_series(chart, "Sheet2!$A$1:$A$5", "Sheet2!$B$1:$B$5"); chart_add_series(chart, "Sheet2!$A$1:$A$5", "Sheet2!$C$1:$C$5"); worksheet_insert_chart(worksheet2, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_axis06.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_PIE); uint8_t data[3][2] = { {2, 60}, {4, 30}, {6, 10}, }; int row, col; for (row = 0; row < 3; row++) for (col = 0; col < 2; col++) worksheet_write_number(worksheet, row, col, data[row][col], NULL); chart_add_series(chart, "=Sheet1!$A$1:$A$3", "=Sheet1!$B$1:$B$3" ); chart_title_set_name(chart, "Title"); /* Axis formatting should be igmored. */ chart_axis_set_name(chart->x_axis, "XXX"); chart_axis_set_name(chart->y_axis, "YYY"); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_row_t row; lxw_col_t col; lxw_row_t max_row = 1000; lxw_col_t max_col = 50; // 1 lxw_workbook *workbook; lxw_worksheet *worksheet; /* Set the worksheet options. */ lxw_workbook_options options; options.constant_memory = 1; /* Create a new workbook with options. */ // 1 workbook = workbook_new_opt("constant_memory.xlsx", &options); worksheet = workbook_add_worksheet(workbook, NULL); for (row = 0; row < max_row; row++) { for (col = 0; col < max_col; col++) { worksheet_write_number(worksheet, row, col, 123.45, NULL); } } return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_format09.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_format *border1 = workbook_add_format(workbook); lxw_format *border2 = workbook_add_format(workbook); lxw_format *border3 = workbook_add_format(workbook); lxw_format *border4 = workbook_add_format(workbook); format_set_border (border1, LXW_BORDER_HAIR); format_set_border_color(border1, LXW_COLOR_RED); format_set_diag_type (border2, LXW_DIAGONAL_BORDER_UP); format_set_diag_color(border2, LXW_COLOR_RED); format_set_diag_type (border3, LXW_DIAGONAL_BORDER_DOWN); format_set_diag_color(border3, LXW_COLOR_RED); format_set_diag_type (border4, LXW_DIAGONAL_BORDER_UP_DOWN); format_set_diag_color(border4, LXW_COLOR_RED); worksheet_write_blank(worksheet, 1, 1, border1); worksheet_write_blank(worksheet, 3, 1, border2); worksheet_write_blank(worksheet, 5, 1, border3); worksheet_write_blank(worksheet, 7, 1, border4); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_defined_name01.xlsx"); lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL); lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL); lxw_worksheet *worksheet3 = workbook_add_worksheet(workbook, "Sheet 3"); worksheet_set_paper(worksheet1, 9); worksheet1->vertical_dpi = 200; worksheet_print_area(worksheet1, RANGE("A1:E6")); worksheet_autofilter(worksheet1, RANGE("F1:G1")); worksheet_write_string(worksheet1, CELL("G1"), "Filter", NULL); worksheet_write_string(worksheet1, CELL("F1"), "Auto", NULL); worksheet_fit_to_pages(worksheet1, 2, 2); workbook_define_name(workbook, "'Sheet 3'!Bar", "='Sheet 3'!$A$1"); workbook_define_name(workbook, "Abc", "=Sheet1!$A$1"); workbook_define_name(workbook, "Baz", "=0.98"); workbook_define_name(workbook, "Sheet1!Bar", "=Sheet1!$A$1"); workbook_define_name(workbook, "Sheet2!Bar", "=Sheet2!$A$1"); workbook_define_name(workbook, "Sheet2!aaa", "=Sheet2!$A$1"); workbook_define_name(workbook, "_Egg", "=Sheet1!$A$1"); workbook_define_name(workbook, "_Fog", "=Sheet1!$A$1"); (void)worksheet2; (void)worksheet3; return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_doughnut02.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_DOUGHNUT); uint8_t data[3][2] = { {2, 60}, {4, 30}, {6, 10}, }; int row, col; for (row = 0; row < 3; row++) for (col = 0; col < 2; col++) worksheet_write_number(worksheet, row, col, data[row][col], NULL); chart_add_series(chart, "=Sheet1!$A$1:$A$3", "=Sheet1!$B$1:$B$3" ); chart_set_hole_size(chart, 10); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_format08.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_format *border1 = workbook_add_format(workbook); lxw_format *border2 = workbook_add_format(workbook); lxw_format *border3 = workbook_add_format(workbook); lxw_format *border4 = workbook_add_format(workbook); lxw_format *border5 = workbook_add_format(workbook); format_set_bottom(border1, LXW_BORDER_THIN); format_set_bottom_color(border1, LXW_COLOR_RED); format_set_top(border2, LXW_BORDER_THIN); format_set_top_color(border2, LXW_COLOR_RED); format_set_left(border3, LXW_BORDER_THIN); format_set_left_color(border3, LXW_COLOR_RED); format_set_right(border4, LXW_BORDER_THIN); format_set_right_color(border4, LXW_COLOR_RED); format_set_border(border5, LXW_BORDER_THIN); format_set_border_color(border5, LXW_COLOR_RED); worksheet_write_blank(worksheet, 1, 1, border1); worksheet_write_blank(worksheet, 3, 1, border2); worksheet_write_blank(worksheet, 5, 1, border3); worksheet_write_blank(worksheet, 7, 1, border4); worksheet_write_blank(worksheet, 9, 1, border5); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_column05.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, "Foo"); 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 = 47292800; chart->axis_id_2 = 47295104; 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); chart_add_series(chart, NULL, "=Foo!$A$1:$A$5"); chart_add_series(chart, NULL, "=Foo!$B$1:$B$5"); chart_add_series(chart, NULL, "=Foo!$C$1:$C$5"); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_data_labels13.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_PIE); 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_series_set_labels(series1); chart_series_set_labels_position(series1, LXW_CHART_LABEL_POSITION_INSIDE_END); chart_series_set_labels_leader_line(series1); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_title01.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_COLUMN); lxw_chart_series *series; /* For testing, copy the randomly generated axis ids in the target file. */ chart->axis_id_1 = 46165376; chart->axis_id_2 = 54462720; 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); series = chart_add_series(chart, NULL, "=Sheet1!$A$1:$A$5"); chart_series_set_name(series, "Foo"); chart_title_off(chart); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_chart_axis29.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); lxw_chart *chart = workbook_add_chart(workbook, LXW_CHART_LINE); /* For testing, copy the randomly generated axis ids in the target file. */ chart->axis_id_1 = 45444480; chart->axis_id_2 = 47402368; 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); 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_font font1 = {.rotation = -90, .baseline = -1}; chart_axis_set_num_font(chart->x_axis, &font1); worksheet_insert_chart(worksheet, CELL("E9"), chart); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("utf8.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_string(worksheet, 2, 1, "Это фраза на русском!", NULL); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_hyperlink16.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_url(worksheet, CELL("B2"), "external:./subdir/blank.xlsx", NULL); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_image22.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_insert_image(worksheet, CELL("B2"), "images/black_300.jpg"); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_escapes04.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_url(worksheet, CELL("A1"), "http://www.perl.com/?a=1&b=2" , NULL); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_escapes07.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_url(worksheet, CELL("A1"), "http://example.com/!\"$%&'( )*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~", NULL); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_data01.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_string(worksheet, 0, 0, "Hello", NULL); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_hyperlink01.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_url(worksheet, CELL("A1"), "http://www.perl.org/" , NULL); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_image27.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_insert_image(worksheet, CELL("B2"), "images/mylogo.png"); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = new_workbook("test_data07.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_write_formula_num(worksheet, 0, 0, "=1+2", NULL, 3); return workbook_close(workbook); }
int main() { lxw_workbook *workbook = workbook_new("test_image82.xlsx"); lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL); worksheet_insert_image_buffer(worksheet, CELL("E9"), image_buffer, image_size); return workbook_close(workbook); }