-
-
Notifications
You must be signed in to change notification settings - Fork 631
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add docs and example for embed_image()
- Loading branch information
Showing
6 changed files
with
181 additions
and
2 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,19 @@ | ||
.. SPDX-License-Identifier: BSD-2-Clause | ||
Copyright 2013-2023, John McNamara, jmcnamara@cpan.org | ||
.. _ex_embedded_images: | ||
|
||
Example: Embedding images into a worksheet | ||
========================================== | ||
|
||
This program is an example of embedding images into a worksheet. This is | ||
equivalent to Excel's "Place in cell" image insert. The image will scale | ||
automatically to fit the cell. | ||
|
||
See the | ||
:func:`embed_image` method for more details. | ||
|
||
.. image:: _images/embedded_images.png | ||
|
||
.. literalinclude:: ../../../examples/embedded_images.py | ||
|
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,29 @@ | ||
############################################################################## | ||
# | ||
# An example of embedding images into a worksheet cells using the XlsxWriter | ||
# Python module. This is equivalent to Excel's "Place in cell" image insert. | ||
# | ||
# SPDX-License-Identifier: BSD-2-Clause | ||
# Copyright 2013-2023, John McNamara, jmcnamara@cpan.org | ||
# | ||
import xlsxwriter | ||
|
||
|
||
# Create an new Excel file and add a worksheet. | ||
workbook = xlsxwriter.Workbook("embedded_images.xlsx") | ||
worksheet = workbook.add_worksheet() | ||
|
||
# Widen the first column to make the caption clearer. | ||
worksheet.set_column(0, 0, 30) | ||
worksheet.write(0, 0, "Embed images that scale to cell size") | ||
|
||
# Embed an images in cells of different widths/heights. | ||
worksheet.set_column(1, 1, 14) | ||
|
||
worksheet.set_row(1, 60) | ||
worksheet.embed_image(1, 1, "python.png") | ||
|
||
worksheet.set_row(3, 120) | ||
worksheet.embed_image(3, 1, "python.png") | ||
|
||
workbook.close() |
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