-
-
Notifications
You must be signed in to change notification settings - Fork 343
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
worksheet: add initial embedded image support
Feature request #417
- Loading branch information
Showing
54 changed files
with
2,232 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* An example of embedding images into a worksheet using the libxlsxwriter | ||
* library. | ||
* | ||
* Copyright 2014-2024, John McNamara, [email protected] | ||
* | ||
*/ | ||
|
||
#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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* libxlsxwriter | ||
* | ||
* Copyright 2014-2024, John McNamara, [email protected]. See LICENSE.txt. | ||
* | ||
* rich_value - A libxlsxwriter library for creating Excel XLSX rich_value files. | ||
* | ||
*/ | ||
#ifndef __LXW_RICH_VALUE_H__ | ||
#define __LXW_RICH_VALUE_H__ | ||
|
||
#include <stdint.h> | ||
|
||
#include "common.h" | ||
#include "workbook.h" | ||
|
||
/* | ||
* Struct to represent a rich_value object. | ||
*/ | ||
typedef struct lxw_rich_value { | ||
|
||
FILE *file; | ||
lxw_workbook *workbook; | ||
|
||
} lxw_rich_value; | ||
|
||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
lxw_rich_value *lxw_rich_value_new(void); | ||
void lxw_rich_value_free(lxw_rich_value *rich_value); | ||
void lxw_rich_value_assemble_xml_file(lxw_rich_value *self); | ||
|
||
/* Declarations required for unit testing. */ | ||
#ifdef TESTING | ||
|
||
STATIC void _rich_value_xml_declaration(lxw_rich_value *self); | ||
|
||
#endif /* TESTING */ | ||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
#endif /* __LXW_RICH_VALUE_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* libxlsxwriter | ||
* | ||
* Copyright 2014-2024, John McNamara, [email protected]. See LICENSE.txt. | ||
* | ||
* rich_value_rel - A libxlsxwriter library for creating Excel XLSX rich_value_rel files. | ||
* | ||
*/ | ||
#ifndef __LXW_RICH_VALUE_REL_H__ | ||
#define __LXW_RICH_VALUE_REL_H__ | ||
|
||
#include <stdint.h> | ||
|
||
#include "common.h" | ||
|
||
/* | ||
* Struct to represent a rich_value_rel object. | ||
*/ | ||
typedef struct lxw_rich_value_rel { | ||
|
||
FILE *file; | ||
uint32_t num_embedded_images; | ||
|
||
} lxw_rich_value_rel; | ||
|
||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
lxw_rich_value_rel *lxw_rich_value_rel_new(void); | ||
void lxw_rich_value_rel_free(lxw_rich_value_rel *rich_value_rel); | ||
void lxw_rich_value_rel_assemble_xml_file(lxw_rich_value_rel *self); | ||
|
||
/* Declarations required for unit testing. */ | ||
#ifdef TESTING | ||
|
||
STATIC void _rich_value_rel_xml_declaration(lxw_rich_value_rel *self); | ||
|
||
#endif /* TESTING */ | ||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
#endif /* __LXW_RICH_VALUE_REL_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* libxlsxwriter | ||
* | ||
* Copyright 2014-2024, John McNamara, [email protected]. See LICENSE.txt. | ||
* | ||
* rich_value_structure - A libxlsxwriter library for creating Excel XLSX rich_value_structure files. | ||
* | ||
*/ | ||
#ifndef __LXW_RICH_VALUE_STRUCTURE_H__ | ||
#define __LXW_RICH_VALUE_STRUCTURE_H__ | ||
|
||
#include <stdint.h> | ||
|
||
#include "common.h" | ||
|
||
/* | ||
* Struct to represent a rich_value_structure object. | ||
*/ | ||
typedef struct lxw_rich_value_structure { | ||
|
||
FILE *file; | ||
uint8_t has_embedded_image_descriptions; | ||
|
||
} lxw_rich_value_structure; | ||
|
||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
lxw_rich_value_structure *lxw_rich_value_structure_new(void); | ||
void lxw_rich_value_structure_free(lxw_rich_value_structure | ||
*rich_value_structure); | ||
void lxw_rich_value_structure_assemble_xml_file(lxw_rich_value_structure | ||
*self); | ||
|
||
/* Declarations required for unit testing. */ | ||
#ifdef TESTING | ||
|
||
STATIC void _rich_value_structure_xml_declaration(lxw_rich_value_structure | ||
*self); | ||
|
||
#endif /* TESTING */ | ||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
#endif /* __LXW_RICH_VALUE_STRUCTURE_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* libxlsxwriter | ||
* | ||
* Copyright 2014-2024, John McNamara, [email protected]. See LICENSE.txt. | ||
* | ||
* rich_value_types - A libxlsxwriter library for creating Excel XLSX rich_value_types files. | ||
* | ||
*/ | ||
#ifndef __LXW_RICH_VALUE_TYPES_H__ | ||
#define __LXW_RICH_VALUE_TYPES_H__ | ||
|
||
#include <stdint.h> | ||
|
||
#include "common.h" | ||
|
||
/* | ||
* Struct to represent a rich_value_types object. | ||
*/ | ||
typedef struct lxw_rich_value_types { | ||
|
||
FILE *file; | ||
|
||
} lxw_rich_value_types; | ||
|
||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
lxw_rich_value_types *lxw_rich_value_types_new(void); | ||
void lxw_rich_value_types_free(lxw_rich_value_types *rich_value_types); | ||
void lxw_rich_value_types_assemble_xml_file(lxw_rich_value_types *self); | ||
|
||
/* Declarations required for unit testing. */ | ||
#ifdef TESTING | ||
|
||
STATIC void _rich_value_types_xml_declaration(lxw_rich_value_types *self); | ||
|
||
#endif /* TESTING */ | ||
|
||
/* *INDENT-OFF* */ | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
/* *INDENT-ON* */ | ||
|
||
#endif /* __LXW_RICH_VALUE_TYPES_H__ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.