File: embed_images.c

package info (click to toggle)
libxlsxwriter 1.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,888 kB
  • sloc: ansic: 65,861; python: 2,106; makefile: 693; perl: 229; sh: 224; xml: 168; cpp: 73; javascript: 5
file content (37 lines) | stat: -rw-r--r-- 1,219 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/*
 * An example of embedding images into a worksheet using the libxlsxwriter
 * library.
 *
 * Copyright 2014-2026, John McNamara, jmcnamara@cpan.org
 *
 */

#include "xlsxwriter.h"

int main() {

    /* Create a new workbook and add a worksheet. */
    lxw_workbook  *workbook  = workbook_new("embed_images.xlsx");
    lxw_worksheet *worksheet = workbook_add_worksheet(workbook, NULL);

    /* Change some of the column widths for clarity. */
    worksheet_set_column(worksheet, COLS("A:B"), 30, NULL);

    /* Embed an image. */
    worksheet_write_string(worksheet, CELL("A2"), "Embed an image in a cell:", NULL);
    worksheet_embed_image(worksheet, CELL("B2"), "logo.png");

    /* Make a row bigger and embed the image. */
    worksheet_set_row(worksheet, 3, 72, NULL);
    worksheet_write_string(worksheet, CELL("A4"), "Embed an image in a cell:", NULL);
    worksheet_embed_image(worksheet, CELL("B4"), "logo.png");

    /* Make a row bigger and embed the image. */
    worksheet_set_row(worksheet, 5, 150, NULL);
    worksheet_write_string(worksheet, CELL("A6"), "Embed an image in a cell:", NULL);
    worksheet_embed_image(worksheet, CELL("B6"), "logo.png");

    workbook_close(workbook);

    return 0;
}