Ejemplo n.º 1
0
int main() {

    lxw_workbook  *workbook  = workbook_new("test_image14.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    worksheet_set_row(worksheet,    1,     4.5,  NULL);
    worksheet_set_row(worksheet,    2,    35.25, NULL);
    worksheet_set_column(worksheet, 2, 4,  3.29, NULL);
    worksheet_set_column(worksheet, 5, 5, 10.71, NULL);

    worksheet_insert_image(worksheet, CELL("C2"), "images/logo.png");

    return workbook_close(workbook);
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
int main() {

    lxw_workbook  *workbook  = new_workbook("test_row_col_format07.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    lxw_format    *bold      = workbook_add_format(workbook);
    format_set_bold(bold);

    worksheet_set_row(worksheet, 4, 15, bold, NULL);

    return workbook_close(workbook);
}
Ejemplo n.º 5
0
int main() {

    lxw_workbook  *workbook  = workbook_new("test_image18.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    lxw_image_options options = {.x_offset = 5, .y_offset = 5};

    worksheet_set_row(worksheet, 1, 96, NULL);
    worksheet_set_column(worksheet, 2, 2, 18, NULL);

    worksheet_insert_image_opt(worksheet, CELL("C2"), "images/issue32.png", &options);

    return workbook_close(workbook);
}
Ejemplo n.º 6
0
int main() {

    lxw_workbook_options options = {1, NULL};

    lxw_workbook  *workbook  = workbook_new_opt("test_optimize23.xlsx", &options);
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
    lxw_format    *bold      = workbook_add_format(workbook);

    format_set_bold(bold);

    worksheet_set_row(worksheet, 0, 20, bold);

    return workbook_close(workbook);
}
Ejemplo n.º 7
0
int main() {

    lxw_workbook  *workbook  = workbook_new("test_row_col_format18.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    lxw_format    *bold      = workbook_add_format(workbook);
    format_set_bold(bold);

    worksheet_set_row(worksheet, 1048575, 15, bold);

    worksheet_write_string(worksheet, 1048575, 0, "Bar", NULL);

    return workbook_close(workbook);
}
Ejemplo n.º 8
0
int main() {

    lxw_workbook  *workbook  = workbook_new("test_default_row02.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);
    uint8_t row;

    worksheet_set_default_row(worksheet, 15, LXW_TRUE);

    worksheet_write_string(worksheet, CELL("A1"), "Foo" , NULL);
    worksheet_write_string(worksheet, CELL("A10"), "Bar" , NULL);

    for (row = 1; row <= 8; row++)
        worksheet_set_row(worksheet, row, 15, NULL);

    return workbook_close(workbook);
}
Ejemplo n.º 9
0
int main() {

    int row;
    int col;

    /* Create a new workbook and add some worksheets. */
    lxw_workbook  *workbook   = workbook_new("panes.xlsx");

    lxw_worksheet *worksheet1 = workbook_add_worksheet(workbook, "Panes 1");
    lxw_worksheet *worksheet2 = workbook_add_worksheet(workbook, "Panes 2");
    lxw_worksheet *worksheet3 = workbook_add_worksheet(workbook, "Panes 3");
    lxw_worksheet *worksheet4 = workbook_add_worksheet(workbook, "Panes 4");


    /* Set up some formatting and text to highlight the panes. */
    lxw_format *header = workbook_add_format(workbook);
    format_set_align(header, LXW_ALIGN_CENTER);
    format_set_align(header, LXW_ALIGN_VERTICAL_CENTER);
    format_set_fg_color(header, 0xD7E4BC);
    format_set_bold(header);
    format_set_border(header, LXW_BORDER_THIN);

    lxw_format *center = workbook_add_format(workbook);
    format_set_align(center, LXW_ALIGN_CENTER);


    /*
     * Example 1. Freeze pane on the top row.
     */
    worksheet_freeze_panes(worksheet1, 1, 0);

    /* Some sheet formatting. */
    worksheet_set_column(worksheet1, 0, 8, 16, NULL);
    worksheet_set_row(worksheet1, 0, 20, NULL);
    worksheet_set_selection(worksheet1, 4, 3, 4, 3);

    /* Some worksheet text to demonstrate scrolling. */
    for (col = 0; col < 9; col++) {
        worksheet_write_string(worksheet1, 0, col, "Scroll down", header);
    }

    for (row = 1; row < 100; row++) {
        for (col = 0; col < 9; col++) {
            worksheet_write_number(worksheet1, row, col, row + 1, center);
        }
    }


    /*
     * Example 2. Freeze pane on the left column.
     */
    worksheet_freeze_panes(worksheet2, 0, 1);

    /* Some sheet formatting. */
    worksheet_set_column(worksheet2, 0, 0, 16, NULL);
    worksheet_set_selection(worksheet2, 4, 3, 4, 3);

    /* Some worksheet text to demonstrate scrolling. */
    for (row = 0; row < 50; row++) {
        worksheet_write_string(worksheet2, row, 0, "Scroll right", header);

        for (col = 1; col < 26; col++) {
            worksheet_write_number(worksheet2, row, col, col, center);
        }
    }


    /*
     * Example 3. Freeze pane on the top row and left column.
     */
    worksheet_freeze_panes(worksheet3, 1, 1);


    /* Some sheet formatting. */
    worksheet_set_column(worksheet3, 0, 25, 16, NULL);
    worksheet_set_row(worksheet3, 0, 20, NULL);
    worksheet_write_string(worksheet3, 0, 0, "", header);
    worksheet_set_selection(worksheet3, 4, 3, 4, 3);


    /* Some worksheet text to demonstrate scrolling. */
    for (col = 1; col < 26; col++) {
        worksheet_write_string(worksheet3, 0, col, "Scroll down", header);
    }

    for (row = 1; row < 50; row++) {
        worksheet_write_string(worksheet3, row, 0, "Scroll right", header);

        for (col = 1; col < 26; col++) {
            worksheet_write_number(worksheet3, row, col, col, center);
        }
    }


    /*
     * Example 4. Split pane on the top row and left column.
     *
     * The divisions must be specified in terms of row and column dimensions.
     * The default row height is 15 and the default column width is 8.43
     */
    worksheet_split_panes(worksheet4, 15, 8.43);


    /* Some sheet formatting. */

    /* Some worksheet text to demonstrate scrolling. */
    for (col = 1; col < 26; col++) {
        worksheet_write_string(worksheet4, 0, col, "Scroll", center);
    }

    for (row = 1; row < 50; row++) {
        worksheet_write_string(worksheet4, row, 0, "Scroll", center);

        for (col = 1; col < 26; col++) {
            worksheet_write_number(worksheet4, row, col, col, center);
        }
    }


    workbook_close(workbook);

    return 0;
}