本文整理汇总了C++中workbook_add_worksheet函数的典型用法代码示例。如果您正苦于以下问题:C++ workbook_add_worksheet函数的具体用法?C++ workbook_add_worksheet怎么用?C++ workbook_add_worksheet使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了workbook_add_worksheet函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
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);
}
示例2: CTEST
/* Test the _write_defined_name() method. */
CTEST(workbook, write_defined_names_sorted) {
char* got;
char exp[] = "<definedNames><definedName name=\"_Egg\">Sheet1!$A$1</definedName><definedName name=\"_Fog\">Sheet1!$A$1</definedName><definedName name=\"aaa\" localSheetId=\"1\">Sheet2!$A$1</definedName><definedName name=\"Abc\">Sheet1!$A$1</definedName><definedName name=\"Bar\" localSheetId=\"2\">'Sheet 3'!$A$1</definedName><definedName name=\"Bar\" localSheetId=\"0\">Sheet1!$A$1</definedName><definedName name=\"Bar\" localSheetId=\"1\">Sheet2!$A$1</definedName><definedName name=\"Baz\">0.98</definedName><definedName name=\"car\" localSheetId=\"2\">\"Saab 900\"</definedName></definedNames>";
FILE* testfile = lxw_tmpfile(NULL);
lxw_workbook *workbook = workbook_new(NULL);
workbook->file = testfile;
workbook_add_worksheet(workbook, NULL);
workbook_add_worksheet(workbook, NULL);
workbook_add_worksheet(workbook, "Sheet 3");
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, "'Sheet 3'!car", "=\"Saab 900\"" );
workbook_define_name(workbook, "_Egg", "=Sheet1!$A$1" );
workbook_define_name(workbook, "_Fog", "=Sheet1!$A$1" );
_write_defined_names(workbook);
RUN_XLSX_STREQ(exp, got);
lxw_workbook_free(workbook);
}
示例3: main
int main() {
lxw_workbook *workbook = workbook_new("test_image07.xlsx");
lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL);
worksheet_insert_image(worksheet1, CELL("E9"), "images/red.png");
worksheet_insert_image(worksheet2, CELL("E9"), "images/yellow.png");
return workbook_close(workbook);
}
示例4: main
int main() {
/* Create a new workbook. */
lxw_workbook *workbook = workbook_new("anatomy.xlsx");
/* Add a worksheet with a user defined sheet name. */
lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, "Demo");
/* Add a worksheet with Excel's default sheet name: Sheet2. */
lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL);
/* Add some cell formats. */
lxw_format *myformat1 = workbook_add_format(workbook);
lxw_format *myformat2 = workbook_add_format(workbook);
/* Set the bold property for the first format. */
format_set_bold(myformat1);
/* Set a number format for the second format. */
format_set_num_format(myformat2, "$#,##0.00");
/* Widen the first column to make the text clearer. */
worksheet_set_column(worksheet1, 0, 0, 20, NULL);
/* Write some unformatted data. */
worksheet_write_string(worksheet1, 0, 0, "Peach", NULL);
worksheet_write_string(worksheet1, 1, 0, "Plum", NULL);
/* Write formatted data. */
worksheet_write_string(worksheet1, 2, 0, "Pear", myformat1);
/* Formats can be reused. */
worksheet_write_string(worksheet1, 3, 0, "Persimmon", myformat1);
/* Write some numbers. */
worksheet_write_number(worksheet1, 5, 0, 123, NULL);
worksheet_write_number(worksheet1, 6, 0, 4567.555, myformat2);
/* Write to the second worksheet. */
worksheet_write_string(worksheet2, 0, 0, "Some text", myformat1);
/* Close the workbook, save the file and free any memory. */
uint8_t error = workbook_close(workbook);
/* Check if there was any error creating the xlsx file. */
if (error)
printf("Error in workbook_close().\n"
"Error %d = %s\n", error, lxw_strerror(error));
return error;
}
示例5: main
int main() {
lxw_workbook *workbook = new_workbook("test_chart_order01.xlsx");
lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet3 = workbook_add_worksheet(workbook, NULL);
lxw_chart *chart1 = workbook_add_chart(workbook, LXW_CHART_COLUMN);
lxw_chart *chart2 = workbook_add_chart(workbook, LXW_CHART_BAR);
lxw_chart *chart3 = workbook_add_chart(workbook, LXW_CHART_LINE);
lxw_chart *chart4 = workbook_add_chart(workbook, LXW_CHART_PIE);
/* For testing, copy the randomly generated axis ids in the target file. */
chart1->axis_id_1 = 54976896;
chart1->axis_id_2 = 54978432;
chart2->axis_id_1 = 54310784;
chart2->axis_id_2 = 54312320;
chart3->axis_id_1 = 69816704;
chart3->axis_id_2 = 69818240;
chart4->axis_id_1 = 69816704;
chart4->axis_id_2 = 69818240;
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(worksheet1, row, col, data[row][col], NULL);
worksheet_write_number(worksheet2, row, col, data[row][col], NULL);
worksheet_write_number(worksheet3, row, col, data[row][col], NULL);
}
chart_add_series(chart1, NULL, "=Sheet1!$A$1:$A$5");
chart_add_series(chart2, NULL, "=Sheet2!$A$1:$A$5");
chart_add_series(chart3, NULL, "=Sheet3!$A$1:$A$5");
chart_add_series(chart4, NULL, "=Sheet1!$B$1:$B$5");
worksheet_insert_chart(worksheet1, CELL("E9"), chart1);
worksheet_insert_chart(worksheet2, CELL("E9"), chart2);
worksheet_insert_chart(worksheet3, CELL("E9"), chart3);
worksheet_insert_chart(worksheet1, CELL("E24"), chart4);
return workbook_close(workbook);
}
示例6: main
int main() {
lxw_workbook *workbook = workbook_new("test_hide01.xlsx");
lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, NULL);
lxw_worksheet *worksheet3 = workbook_add_worksheet(workbook, NULL);
worksheet_hide(worksheet2);
/* Avoid warnings about unused variables. */
(void)worksheet1;
(void)worksheet3;
return workbook_close(workbook);
}
示例7: main
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);
}
示例8: main
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);
}
示例9: main
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);
}
示例10: main
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);
}
示例11: main
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);
}
示例12: main
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);
}
示例13: main
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);
}
示例14: main
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);
}
示例15: main
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);
}