SlideShare une entreprise Scribd logo
1  sur  81
Télécharger pour lire hors ligne
Creating Excel files
with Python and
XlsxWriter
John McNamara
Emutex Ltd
whoami
John McNamara
Software developer at Emutex Ltd
http://www.emutex.com
http://github.com/jmcnamara
Why Excel
•
•
•
•
•

Bosses like it
Useful as a data source
More useful with formatting
Input/output source for Pandas
Can be misused: Excel as a database
Available Python modules
•

csv.py
Readers and writers in core libs

•

xlwt/xlrd
Mature, stable modules, mainly XLS support

•

openpyxl
Reads and writes XLSX files

•

xlsxwriter
New module from early 2013
Excel File Formats
Excel 2003 : xls

Excel 2007 : xlsx

xlwt

xlsxwriter

Write
Read

openpyxl

xlrd
XlsxWriter
•
•
•
•
•

Write Excel XLSX files only
Doesn’t read or re-write Excel files
Adds many new features
Uses core modules only
Python 2.5, 2.6, 2.7, 3.1, 3.2, 3.3, PyPy, Jython
Why another module
•
•

Why not?

•

XlsxWriter adds support for:

Other modules support some but not all
features
charts, autofilters, tables, data validation,
merged cells, rich text, conditional
formatting, defined names, images, cell
comments, sparklines, outlines
Getting Started
•

Install:
$ sudo pip install xlsxwriter

•

Clone or fork:
$ git clone git@github.com:jmcnamara/XlsxWriter.git
$ cd XlsxWriter
$ make test
$ sudo python setup.py install

•

Read:
https://xlsxwriter.readthedocs.org
Hello World.xlsx
Hello World.xlsx
import xlsxwriter
workbook = xlsxwriter.Workbook('hello_world.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write(0, 0, 'Hello world')
workbook.close()
Hello World.xlsx
import xlsxwriter
workbook = xlsxwriter.Workbook('hello_world.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write(0, 0, 'Hello world')
workbook.close()
Hello World.xlsx
import xlsxwriter
workbook = xlsxwriter.Workbook('hello_world.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write(0, 0, 'Hello world')
worksheet.write(2, 1, 'Hello world')
workbook.close()
Hello World.xlsx
import xlsxwriter
workbook = xlsxwriter.Workbook('hello_world.xlsx')
worksheet = workbook.add_worksheet()
worksheet.write(0, 0, 'Hello world')
worksheet.write(2, 1, 'Hello world')
worksheet.write('C5', 'Hello world')
workbook.close()
Cell Formatting
Cell Formatting
import xlsxwriter
workbook = xlsxwriter.Workbook('formatting.xlsx')
worksheet = workbook.add_worksheet()
italic = workbook.add_format({'italic': True})
bold
= workbook.add_format({'bold':
True, 'font_color': '#9CB640'})
worksheet.write(0, 0, 'Hello')
workbook.close()
Cell Formatting
import xlsxwriter
workbook = xlsxwriter.Workbook('formatting.xlsx')
worksheet = workbook.add_worksheet()
italic = workbook.add_format({'italic': True})
bold
= workbook.add_format({'bold':
True, 'font_color': '#9CB640'})
worksheet.write(0, 0, 'Hello')
worksheet.write(1, 0, 'Hello', italic)
workbook.close()
Cell Formatting
import xlsxwriter
workbook = xlsxwriter.Workbook('formatting.xlsx')
worksheet = workbook.add_worksheet()
italic = workbook.add_format({'italic': True})
bold
= workbook.add_format({'bold':
True, 'font_color': '#9CB640'})
worksheet.write(0, 0, 'Hello')
worksheet.write(1, 0, 'Hello', italic)
worksheet.write(2, 0, 'Hello', bold)
workbook.close()
Cell Formatting
set_font_name()

set_text_wrap()

set_border_color()

set_font_size()

set_rotation()

set_bottom_color()

set_font_color()

set_indent()

set_top_color()

set_bold()

set_shrink()

set_left_color()

set_italic()

set_text_justlast()

set_right_color()

set_underline()

set_pattern()

set_font_strikeout()

set_bg_color()

set_font_script()

set_fg_color()

set_num_format()

set_border()

set_locked()

set_bottom()

set_hidden()

set_top()

set_align()

set_left()

set_center_across()

set_right()
Types
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0, 0, 'Hello world')
workbook.close()
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0, 0, 'Hello world')
workbook.close()
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0, 0, 'Hello world')
worksheet.write(1, 0, 'Это фраза на русском!')
workbook.close()
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0, 0, 'Hello world')
worksheet.write(1, 0, 'Это фраза на русском!')
worksheet.write(2, 0, 123)
workbook.close()
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0,
worksheet.write(1,
worksheet.write(2,
worksheet.write(3,
workbook.close()

0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0,
worksheet.write(1,
worksheet.write(2,
worksheet.write(3,
worksheet.write(4,
workbook.close()

0,
0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
date(2013, 10, 13), date_format)
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0,
worksheet.write(1,
worksheet.write(2,
worksheet.write(3,
worksheet.write(4,
worksheet.write(5,
workbook.close()

0,
0,
0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
date(2013, 10, 13), date_format)
'=PI()')
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0,
worksheet.write(1,
worksheet.write(2,
worksheet.write(3,
worksheet.write(4,
worksheet.write(5,
worksheet.write(6,
workbook.close()

0,
0,
0,
0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
date(2013, 10, 13), date_format)
'=PI()')
'http://python.com')
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0,
worksheet.write(1,
worksheet.write(2,
worksheet.write(3,
worksheet.write(4,
worksheet.write(5,
worksheet.write(6,
worksheet.write(7,
workbook.close()

0,
0,
0,
0,
0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
date(2013, 10, 13), date_format)
'=PI()')
'http://python.com')
True)
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write(0,
worksheet.write(1,
worksheet.write(2,
worksheet.write(3,
worksheet.write(4,
worksheet.write(5,
worksheet.write(6,
worksheet.write(7,
workbook.close()

0,
0,
0,
0,
0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
date(2013, 10, 13), date_format)
'=PI()')
'http://python.com')
True)
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write
worksheet.write
worksheet.write
worksheet.write
worksheet.write
worksheet.write
worksheet.write
worksheet.write
workbook.close()

(0,
(1,
(2,
(3,
(4,
(5,
(6,
(7,

0,
0,
0,
0,
0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
date(2013, 10, 13), date_format)
'=PI()')
'http://python.com')
True)
Types
from datetime import date
import xlsxwriter
workbook
= xlsxwriter.Workbook('types.xlsx')
worksheet
= workbook.add_worksheet()
date_format = workbook.add_format({'num_format': 'd mmm yyyy'})
worksheet.write_string (0,
worksheet.write_string (1,
worksheet.write_number (2,
worksheet.write_number (3,
worksheet.write_datetime(4,
worksheet.write_formula (5,
worksheet.write_url
(6,
worksheet.write_boolean (7,
workbook.close()

0,
0,
0,
0,
0,
0,
0,
0,

'Hello world')
'Это фраза на русском!')
123)
123.456)
date(2013, 10, 13), date_format)
'=PI()')
'http://python.com')
True)
Formulas
Formulas
worksheet.write_formula('A1', '=1+2')
worksheet.write_formula('A2', '=A1')
worksheet.write_formula('A3', '{=SUM(B1:C1*B2:C2)}')
worksheet.write_formula('A4', '=VLOOKUP("Acme", A2:D6, 3, FALSE)')
Images
Images
import xlsxwriter
workbook = xlsxwriter.Workbook('image.xlsx')
worksheet = workbook.add_worksheet()
worksheet.insert_image(0, 0, 'logo.png')
workbook.close()
Conditional Formatting
Conditional Formatting
import xlsxwriter
wb = xlsxwriter.Workbook('conditional_format.xlsx')
ws = wb.add_worksheet()
high = wb.add_format({'bg_color': '#FFC7CE', 'font_color': '#9C0006'})
low = wb.add_format({'bg_color': '#C6EFCE', 'font_color': '#006100'})
data = [
[88,
[24,
[6,
[73,
[36,
]

25,
100,
57,
78,
54,

33,
20,
88,
1,
22,

23,
88,
28,
96,
66,

67,
29,
10,
26,
81,

13],
33],
26],
45],
90],

for row, row_data in enumerate(data):
ws.write_row(row, 0, row_data)
ws.conditional_format('A1:F5', {'type':
'criteria':
'value':
'format':

'cell',
'>=',
50,
high})

ws.conditional_format('A1:F5', {'type':
'criteria':
'value':
'format':

'cell',
'<',
50,
low})

wb.close()
Charts
Charts
Area
stacked
percent_stacked
Bar
stacked
percent_stacked

Pie
Radar
with_markers
filled

Column
stacked
percent_stacked

Scatter
straight_with_markers
straight
smooth_with_markers
smooth

Line

Stock
Charts
import xlsxwriter
workbook = xlsxwriter.Workbook('chart.xlsx')
worksheet = workbook.add_worksheet()
# Add the worksheet data to be plotted.
data = [10, 40, 50, 20, 10, 50]
worksheet.write_column('A1', data)
# Create a new chart object.
chart = workbook.add_chart({'type': 'area'})
# Add a series to the chart.
chart.add_series({'values': '=Sheet1!$A$1:$A$6'})
# Insert the chart into the worksheet.
worksheet.insert_chart('C1', chart)
workbook.close()
Charts
chart = workbook.add_chart({'type': 'area'})
Charts
chart = workbook.add_chart({'type': 'bar'})
Charts
chart = workbook.add_chart({'type': 'column'})
Charts
chart = workbook.add_chart({'type': 'line'})
Charts
chart = workbook.add_chart({'type': 'pie'})
Charts
chart = workbook.add_chart({'type': 'radar'})
Charts
•

Configurability
Charts
Stacked chart with captions
Charts
Change chart styles
Charts
Add trendlines to charts
Charts
Format data points
Charts
Secondary axes
Autofilters
Autofilters
import xlsxwriter
workbook = xlsxwriter.Workbook('autofilter.xlsx')
worksheet = workbook.add_worksheet()
# Add a format for the headers.
header_format = workbook.add_format({'bold': 1, 'bg_color': '#C6EFCE'})
# Populate the worksheet data.
# See the xlsxwriter docs for a full example.
...
# Make the columns wider.
worksheet.set_column('A:D', 12)
# Format the header row.
worksheet.set_row(0, 20, header_format)
# Set the autofilter.
worksheet.autofilter('A1:D51')
workbook.close()
Tables
Tables
•
•
•

Group a range of cells into a single entity
Apply a uniform formatting across the cells
Refer to the table in formulas
worksheet.add_table('B3:F7', {options})
Data Validation
Data Validation
•
•
•

Restrict data entry to certain ranges
Raise errors/warning within Excel
Allow selection from drop down lists

data_validation(
'B25',
{'validate': 'integer',
'criteria': 'between',
'minimum': 1,
'maximum': 10})
Cell Comments
Cell Comments
•

Add comments to cells
worksheet.write('A1', 'Hello')
worksheet.write_comment('A1', 'This is a comment')
Sparklines
Sparklines
•
•

Mini charts within cells to show trends
Invented by Edward Tufte
Code All the Things!
•

Lots of features
Code All the Things!
•
•
•
•

Lots of features
Useful when you need them
Ignore them when you don’t
Plenty of examples and documentation to
get you started
How does it work
How does it work
•

20% of a studio audience guessed Witchcraft
How does it work
•
•
•
•

20% of a studio audience guessed Witchcraft
Actually a collection of XML files in a Zip file
Can be unzipped using standard utilities
Even modified in-place (if you are desperate)
How does it work
$ unzip -o -d hello_world hello_world.xlsx
Archive:

hello_world.xlsx

inflating: hello_world/[Content_Types].xml
inflating: hello_world/_rels/.rels
inflating: hello_world/docProps/app.xml
inflating: hello_world/docProps/core.xml
inflating: hello_world/xl/sharedStrings.xml
inflating: hello_world/xl/styles.xml
inflating: hello_world/xl/workbook.xml
inflating: hello_world/xl/_rels/workbook.xml.rels
inflating: hello_world/xl/theme/theme1.xml
inflating: hello_world/xl/worksheets/sheet1.xml
How does it work
$ unzip -o -d hello_world hello_world.xlsx
Archive:

hello_world.xlsx

inflating: hello_world/[Content_Types].xml
inflating: hello_world/_rels/.rels
inflating: hello_world/docProps/app.xml
inflating: hello_world/docProps/core.xml
inflating: hello_world/xl/sharedStrings.xml
inflating: hello_world/xl/styles.xml
inflating: hello_world/xl/workbook.xml
inflating: hello_world/xl/_rels/workbook.xml.rels
inflating: hello_world/xl/theme/theme1.xml
inflating: hello_world/xl/worksheets/sheet1.xml
How does it work
$ unzip -o -d hello_world hello_world.xlsx
Archive:

hello_world.xlsx

inflating: hello_world/[Content_Types].xml
inflating: hello_world/_rels/.rels
inflating: hello_world/docProps/app.xml
inflating: hello_world/docProps/core.xml
inflating: hello_world/xl/sharedStrings.xml
inflating: hello_world/xl/styles.xml
inflating: hello_world/xl/workbook.xml
inflating: hello_world/xl/_rels/workbook.xml.rels
inflating: hello_world/xl/theme/theme1.xml
inflating: hello_world/xl/worksheets/sheet1.xml
How does it work
$ unzip -o -d hello_world hello_world.xlsx
Archive:

hello_world.xlsx

inflating: hello_world/[Content_Types].xml
inflating: hello_world/_rels/.rels
inflating: hello_world/docProps/app.xml
inflating: hello_world/docProps/core.xml
inflating: hello_world/xl/sharedStrings.xml
inflating: hello_world/xl/styles.xml
inflating: hello_world/xl/workbook.xml
inflating: hello_world/xl/_rels/workbook.xml.rels
inflating: hello_world/xl/theme/theme1.xml
inflating: hello_world/xl/worksheets/sheet1.xml
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
How does it work
$ unzip -o -d hello_world hello_world.xlsx
...
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
How does it work
$ unzip -o -d hello_world hello_world.xlsx
...
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="..." xmlns:r="...">
<dimension ref="A1"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0"/>
</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row r="1" spans="1:1">
<c r="A1" t="s">
<v>0</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
How does it work
$ unzip -o -d hello_world hello_world.xlsx
...
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="..." xmlns:r="...">
<dimension ref="A1"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0"/>
</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row r="1" spans="1:1">
<c r="A1" t="s">
<v>0</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
How does it work
$ unzip -o -d hello_world hello_world.xlsx
...
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="..." xmlns:r="...">
<dimension ref="A1"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0"/>
</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row r="1" spans="1:1">
<c r="A1" t="s">
<v>0</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
How does it work
$ unzip -o -d hello_world hello_world.xlsx
...
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="..." xmlns:r="...">
<dimension ref="A1"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0"/>
</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row r="1" spans="1:1">
<c r="A1" t="s">
<v>0</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
How does it work
$ unzip -o -d hello_world hello_world.xlsx
...
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="..." xmlns:r="...">
<dimension ref="A1"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0"/>
</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row r="1" spans="1:1">
<c r="A1" t="s">
<v>0</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
How does it work
$ unzip -o -d hello_world hello_world.xlsx
...
$ xmllint --format hello_world/xl/worksheets/sheet1.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<worksheet xmlns="..." xmlns:r="...">
<dimension ref="A1"/>
<sheetViews>
<sheetView tabSelected="1" workbookViewId="0"/>
</sheetViews>
<sheetFormatPr defaultRowHeight="15"/>
<sheetData>
<row r="1" spans="1:1">
<c r="A1" t="s">
<v>0</v>
</c>
</row>
</sheetData>
<pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/>
</worksheet>
How does it work
•
•

It works well
XlsxWriter does the hard work so you
don’t have to
close()
•

Next time you need to write an Excel file with
Python try XlsxWriter

•

Clone it on Github, submit issues, add stars
http://github.com/jmcnamara/XlsxWriter

•

Read the documentation
https://xlsxwriter.readthedocs.org
PDF tutorial, cookbook and manual
Thank You

John McNamara
Emutex Ltd

Contenu connexe

Tendances

JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object ModelWebStackAcademy
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Edureka!
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File HandlingSunil OS
 
How to Define One2Many Field in Odoo 15
 How to Define One2Many Field in Odoo 15 How to Define One2Many Field in Odoo 15
How to Define One2Many Field in Odoo 15Celine George
 
javascript objects
javascript objectsjavascript objects
javascript objectsVijay Kalyan
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSXMicah Wood
 
"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGapChristian Rokitta
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging TechniquesWebStackAcademy
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Tom Brander
 
File Handling Python
File Handling PythonFile Handling Python
File Handling PythonAkhil Kaushik
 
Python SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabasePython SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabaseElangovanTechNotesET
 
Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To DjangoJay Graves
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events WebStackAcademy
 

Tendances (20)

PHP Presentation
PHP PresentationPHP Presentation
PHP Presentation
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
JavaScript: Events Handling
JavaScript: Events HandlingJavaScript: Events Handling
JavaScript: Events Handling
 
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
Tkinter Python Tutorial | Python GUI Programming Using Tkinter Tutorial | Pyt...
 
Java Input Output and File Handling
Java Input Output and File HandlingJava Input Output and File Handling
Java Input Output and File Handling
 
Java IO
Java IOJava IO
Java IO
 
How to Define One2Many Field in Odoo 15
 How to Define One2Many Field in Odoo 15 How to Define One2Many Field in Odoo 15
How to Define One2Many Field in Odoo 15
 
javascript objects
javascript objectsjavascript objects
javascript objects
 
Introduction to JSX
Introduction to JSXIntroduction to JSX
Introduction to JSX
 
Flask – Python
Flask – PythonFlask – Python
Flask – Python
 
"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap"Native" Apps with APEX and PhoneGap
"Native" Apps with APEX and PhoneGap
 
JavaScript - Chapter 15 - Debugging Techniques
 JavaScript - Chapter 15 - Debugging Techniques JavaScript - Chapter 15 - Debugging Techniques
JavaScript - Chapter 15 - Debugging Techniques
 
Django, What is it, Why is it cool?
Django, What is it, Why is it cool?Django, What is it, Why is it cool?
Django, What is it, Why is it cool?
 
File Handling Python
File Handling PythonFile Handling Python
File Handling Python
 
Python SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite DatabasePython SQite3 database Tutorial | SQlite Database
Python SQite3 database Tutorial | SQlite Database
 
Introduction To Django
Introduction To DjangoIntroduction To Django
Introduction To Django
 
JavaScript - Chapter 11 - Events
 JavaScript - Chapter 11 - Events  JavaScript - Chapter 11 - Events
JavaScript - Chapter 11 - Events
 
Java packages
Java packagesJava packages
Java packages
 
Wpf Introduction
Wpf IntroductionWpf Introduction
Wpf Introduction
 
Json
JsonJson
Json
 

En vedette

xlwings – Make Excel Fly with Python
xlwings – Make Excel Fly with Pythonxlwings – Make Excel Fly with Python
xlwings – Make Excel Fly with Pythonodsc
 
Python + Excel
Python + Excel Python + Excel
Python + Excel POSTECH
 
xlwings - Connecting Python with Excel
xlwings - Connecting Python with Excelxlwings - Connecting Python with Excel
xlwings - Connecting Python with Excelxlwings
 
Python. Finance. Excel. - The Thalesians
Python. Finance. Excel. - The ThalesiansPython. Finance. Excel. - The Thalesians
Python. Finance. Excel. - The Thalesiansxlwings
 
xlwings Presentation (Excel & Python) Swiss FinteCH event
xlwings Presentation (Excel & Python) Swiss FinteCH eventxlwings Presentation (Excel & Python) Swiss FinteCH event
xlwings Presentation (Excel & Python) Swiss FinteCH eventxlwings
 
Scraping in 60 minutes
Scraping in 60 minutesScraping in 60 minutes
Scraping in 60 minutesPaul Bradshaw
 
Lobbycloud .- how they are writing your laws
Lobbycloud .- how they are writing your lawsLobbycloud .- how they are writing your laws
Lobbycloud .- how they are writing your lawsMartin Virtel
 
Don Bailey - A Million Little Tracking Devices
Don Bailey  - A Million Little Tracking DevicesDon Bailey  - A Million Little Tracking Devices
Don Bailey - A Million Little Tracking DevicesSource Conference
 
29c3 OpenBTS workshop - Mini-Workshop
29c3 OpenBTS workshop - Mini-Workshop29c3 OpenBTS workshop - Mini-Workshop
29c3 OpenBTS workshop - Mini-WorkshopAlexander Chemeris
 
How To Automate Part 1
How To Automate Part 1How To Automate Part 1
How To Automate Part 1Sean Durocher
 
DAB+ for local and community radio
DAB+ for local and community radioDAB+ for local and community radio
DAB+ for local and community radioradioradioradio
 
Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)Qiangning Hong
 
Python在豆瓣的应用
Python在豆瓣的应用Python在豆瓣的应用
Python在豆瓣的应用Qiangning Hong
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundationKevlin Henney
 
The new Odoo warehouse management system
The new Odoo warehouse management systemThe new Odoo warehouse management system
The new Odoo warehouse management systemOdoo
 

En vedette (20)

xlwings – Make Excel Fly with Python
xlwings – Make Excel Fly with Pythonxlwings – Make Excel Fly with Python
xlwings – Make Excel Fly with Python
 
Python + Excel
Python + Excel Python + Excel
Python + Excel
 
xlwings - Connecting Python with Excel
xlwings - Connecting Python with Excelxlwings - Connecting Python with Excel
xlwings - Connecting Python with Excel
 
Python. Finance. Excel. - The Thalesians
Python. Finance. Excel. - The ThalesiansPython. Finance. Excel. - The Thalesians
Python. Finance. Excel. - The Thalesians
 
xlwings Presentation (Excel & Python) Swiss FinteCH event
xlwings Presentation (Excel & Python) Swiss FinteCH eventxlwings Presentation (Excel & Python) Swiss FinteCH event
xlwings Presentation (Excel & Python) Swiss FinteCH event
 
Scraping in 60 minutes
Scraping in 60 minutesScraping in 60 minutes
Scraping in 60 minutes
 
Lobbycloud .- how they are writing your laws
Lobbycloud .- how they are writing your lawsLobbycloud .- how they are writing your laws
Lobbycloud .- how they are writing your laws
 
Don Bailey - A Million Little Tracking Devices
Don Bailey  - A Million Little Tracking DevicesDon Bailey  - A Million Little Tracking Devices
Don Bailey - A Million Little Tracking Devices
 
29c3 OpenBTS workshop - Mini-Workshop
29c3 OpenBTS workshop - Mini-Workshop29c3 OpenBTS workshop - Mini-Workshop
29c3 OpenBTS workshop - Mini-Workshop
 
How To Automate Part 1
How To Automate Part 1How To Automate Part 1
How To Automate Part 1
 
DAB+ for local and community radio
DAB+ for local and community radioDAB+ for local and community radio
DAB+ for local and community radio
 
Python高级编程(二)
Python高级编程(二)Python高级编程(二)
Python高级编程(二)
 
Python and ArcGIS 10.1
Python and ArcGIS 10.1Python and ArcGIS 10.1
Python and ArcGIS 10.1
 
ArcGIS Python Programming (3Nov11)
ArcGIS Python Programming (3Nov11)ArcGIS Python Programming (3Nov11)
ArcGIS Python Programming (3Nov11)
 
Python在豆瓣的应用
Python在豆瓣的应用Python在豆瓣的应用
Python在豆瓣的应用
 
20 cool things python
20 cool things python20 cool things python
20 cool things python
 
Biz plan
Biz planBiz plan
Biz plan
 
Mixing Python and Java
Mixing Python and JavaMixing Python and Java
Mixing Python and Java
 
Python Advanced – Building on the foundation
Python Advanced – Building on the foundationPython Advanced – Building on the foundation
Python Advanced – Building on the foundation
 
The new Odoo warehouse management system
The new Odoo warehouse management systemThe new Odoo warehouse management system
The new Odoo warehouse management system
 

Similaire à Creating Excel files with Python and XlsxWriter

PYTHON FOR SPREADSHEET USERS.pptx
PYTHON FOR SPREADSHEET USERS.pptxPYTHON FOR SPREADSHEET USERS.pptx
PYTHON FOR SPREADSHEET USERS.pptxrmlkmrPphtt
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196Mahmoud Samir Fayed
 
AD215 - Practical Magic with DXL
AD215 - Practical Magic with DXLAD215 - Practical Magic with DXL
AD215 - Practical Magic with DXLStephan H. Wissel
 
Session 3.2 Your first excel and word automations
Session 3.2 Your first excel and word automationsSession 3.2 Your first excel and word automations
Session 3.2 Your first excel and word automationsCristina Vidu
 
Microsoft Excel Tutorial
Microsoft Excel TutorialMicrosoft Excel Tutorial
Microsoft Excel TutorialFaHaD .H. NooR
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developersJim Roepcke
 
Making WorkFlows XML Report Output Work For You
Making WorkFlows XML Report Output Work For YouMaking WorkFlows XML Report Output Work For You
Making WorkFlows XML Report Output Work For YouLOUIS Libraries
 
Getting Started With Xsl Templates
Getting Started With Xsl TemplatesGetting Started With Xsl Templates
Getting Started With Xsl TemplatesWill Trillich
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189Mahmoud Samir Fayed
 
Exploiting JXL using Selenium
Exploiting JXL using SeleniumExploiting JXL using Selenium
Exploiting JXL using SeleniumOSSCube
 
The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184Mahmoud Samir Fayed
 
XMLPublisher
XMLPublisherXMLPublisher
XMLPublisherJAYAARC
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld BookNet Canada
 

Similaire à Creating Excel files with Python and XlsxWriter (20)

Apache poi tutorial
Apache poi tutorialApache poi tutorial
Apache poi tutorial
 
Apachepoitutorial
ApachepoitutorialApachepoitutorial
Apachepoitutorial
 
PHP - Introduction to PHP Date and Time Functions
PHP -  Introduction to  PHP Date and Time FunctionsPHP -  Introduction to  PHP Date and Time Functions
PHP - Introduction to PHP Date and Time Functions
 
PYTHON FOR SPREADSHEET USERS.pptx
PYTHON FOR SPREADSHEET USERS.pptxPYTHON FOR SPREADSHEET USERS.pptx
PYTHON FOR SPREADSHEET USERS.pptx
 
VSTO
VSTOVSTO
VSTO
 
The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196The Ring programming language version 1.7 book - Part 17 of 196
The Ring programming language version 1.7 book - Part 17 of 196
 
AD215 - Practical Magic with DXL
AD215 - Practical Magic with DXLAD215 - Practical Magic with DXL
AD215 - Practical Magic with DXL
 
Python openpyxl
Python openpyxlPython openpyxl
Python openpyxl
 
Session 3.2 Your first excel and word automations
Session 3.2 Your first excel and word automationsSession 3.2 Your first excel and word automations
Session 3.2 Your first excel and word automations
 
Part 7
Part 7Part 7
Part 7
 
Microsoft Excel Tutorial
Microsoft Excel TutorialMicrosoft Excel Tutorial
Microsoft Excel Tutorial
 
Introduction to Python for Plone developers
Introduction to Python for Plone developersIntroduction to Python for Plone developers
Introduction to Python for Plone developers
 
Making WorkFlows XML Report Output Work For You
Making WorkFlows XML Report Output Work For YouMaking WorkFlows XML Report Output Work For You
Making WorkFlows XML Report Output Work For You
 
Introduction to Microsoft Excel
Introduction to Microsoft ExcelIntroduction to Microsoft Excel
Introduction to Microsoft Excel
 
Getting Started With Xsl Templates
Getting Started With Xsl TemplatesGetting Started With Xsl Templates
Getting Started With Xsl Templates
 
The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189The Ring programming language version 1.6 book - Part 16 of 189
The Ring programming language version 1.6 book - Part 16 of 189
 
Exploiting JXL using Selenium
Exploiting JXL using SeleniumExploiting JXL using Selenium
Exploiting JXL using Selenium
 
The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184The Ring programming language version 1.5.3 book - Part 18 of 184
The Ring programming language version 1.5.3 book - Part 18 of 184
 
XMLPublisher
XMLPublisherXMLPublisher
XMLPublisher
 
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
The Ebook Developer's Toolbox - ebookcraft 2016 - Sanders Kleinfeld
 

Dernier

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 

Dernier (20)

Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 

Creating Excel files with Python and XlsxWriter

  • 1. Creating Excel files with Python and XlsxWriter John McNamara Emutex Ltd
  • 2. whoami John McNamara Software developer at Emutex Ltd http://www.emutex.com http://github.com/jmcnamara
  • 3. Why Excel • • • • • Bosses like it Useful as a data source More useful with formatting Input/output source for Pandas Can be misused: Excel as a database
  • 4. Available Python modules • csv.py Readers and writers in core libs • xlwt/xlrd Mature, stable modules, mainly XLS support • openpyxl Reads and writes XLSX files • xlsxwriter New module from early 2013
  • 5. Excel File Formats Excel 2003 : xls Excel 2007 : xlsx xlwt xlsxwriter Write Read openpyxl xlrd
  • 6. XlsxWriter • • • • • Write Excel XLSX files only Doesn’t read or re-write Excel files Adds many new features Uses core modules only Python 2.5, 2.6, 2.7, 3.1, 3.2, 3.3, PyPy, Jython
  • 7. Why another module • • Why not? • XlsxWriter adds support for: Other modules support some but not all features charts, autofilters, tables, data validation, merged cells, rich text, conditional formatting, defined names, images, cell comments, sparklines, outlines
  • 8. Getting Started • Install: $ sudo pip install xlsxwriter • Clone or fork: $ git clone git@github.com:jmcnamara/XlsxWriter.git $ cd XlsxWriter $ make test $ sudo python setup.py install • Read: https://xlsxwriter.readthedocs.org
  • 10. Hello World.xlsx import xlsxwriter workbook = xlsxwriter.Workbook('hello_world.xlsx') worksheet = workbook.add_worksheet() worksheet.write(0, 0, 'Hello world') workbook.close()
  • 11. Hello World.xlsx import xlsxwriter workbook = xlsxwriter.Workbook('hello_world.xlsx') worksheet = workbook.add_worksheet() worksheet.write(0, 0, 'Hello world') workbook.close()
  • 12. Hello World.xlsx import xlsxwriter workbook = xlsxwriter.Workbook('hello_world.xlsx') worksheet = workbook.add_worksheet() worksheet.write(0, 0, 'Hello world') worksheet.write(2, 1, 'Hello world') workbook.close()
  • 13. Hello World.xlsx import xlsxwriter workbook = xlsxwriter.Workbook('hello_world.xlsx') worksheet = workbook.add_worksheet() worksheet.write(0, 0, 'Hello world') worksheet.write(2, 1, 'Hello world') worksheet.write('C5', 'Hello world') workbook.close()
  • 15. Cell Formatting import xlsxwriter workbook = xlsxwriter.Workbook('formatting.xlsx') worksheet = workbook.add_worksheet() italic = workbook.add_format({'italic': True}) bold = workbook.add_format({'bold': True, 'font_color': '#9CB640'}) worksheet.write(0, 0, 'Hello') workbook.close()
  • 16. Cell Formatting import xlsxwriter workbook = xlsxwriter.Workbook('formatting.xlsx') worksheet = workbook.add_worksheet() italic = workbook.add_format({'italic': True}) bold = workbook.add_format({'bold': True, 'font_color': '#9CB640'}) worksheet.write(0, 0, 'Hello') worksheet.write(1, 0, 'Hello', italic) workbook.close()
  • 17. Cell Formatting import xlsxwriter workbook = xlsxwriter.Workbook('formatting.xlsx') worksheet = workbook.add_worksheet() italic = workbook.add_format({'italic': True}) bold = workbook.add_format({'bold': True, 'font_color': '#9CB640'}) worksheet.write(0, 0, 'Hello') worksheet.write(1, 0, 'Hello', italic) worksheet.write(2, 0, 'Hello', bold) workbook.close()
  • 19. Types
  • 20. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, 0, 'Hello world') workbook.close()
  • 21. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, 0, 'Hello world') workbook.close()
  • 22. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, 0, 'Hello world') worksheet.write(1, 0, 'Это фраза на русском!') workbook.close()
  • 23. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, 0, 'Hello world') worksheet.write(1, 0, 'Это фраза на русском!') worksheet.write(2, 0, 123) workbook.close()
  • 24. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, worksheet.write(1, worksheet.write(2, worksheet.write(3, workbook.close() 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456)
  • 25. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, worksheet.write(1, worksheet.write(2, worksheet.write(3, worksheet.write(4, workbook.close() 0, 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456) date(2013, 10, 13), date_format)
  • 26. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, worksheet.write(1, worksheet.write(2, worksheet.write(3, worksheet.write(4, worksheet.write(5, workbook.close() 0, 0, 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456) date(2013, 10, 13), date_format) '=PI()')
  • 27. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, worksheet.write(1, worksheet.write(2, worksheet.write(3, worksheet.write(4, worksheet.write(5, worksheet.write(6, workbook.close() 0, 0, 0, 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456) date(2013, 10, 13), date_format) '=PI()') 'http://python.com')
  • 28. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, worksheet.write(1, worksheet.write(2, worksheet.write(3, worksheet.write(4, worksheet.write(5, worksheet.write(6, worksheet.write(7, workbook.close() 0, 0, 0, 0, 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456) date(2013, 10, 13), date_format) '=PI()') 'http://python.com') True)
  • 29. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write(0, worksheet.write(1, worksheet.write(2, worksheet.write(3, worksheet.write(4, worksheet.write(5, worksheet.write(6, worksheet.write(7, workbook.close() 0, 0, 0, 0, 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456) date(2013, 10, 13), date_format) '=PI()') 'http://python.com') True)
  • 30. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write worksheet.write worksheet.write worksheet.write worksheet.write worksheet.write worksheet.write worksheet.write workbook.close() (0, (1, (2, (3, (4, (5, (6, (7, 0, 0, 0, 0, 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456) date(2013, 10, 13), date_format) '=PI()') 'http://python.com') True)
  • 31. Types from datetime import date import xlsxwriter workbook = xlsxwriter.Workbook('types.xlsx') worksheet = workbook.add_worksheet() date_format = workbook.add_format({'num_format': 'd mmm yyyy'}) worksheet.write_string (0, worksheet.write_string (1, worksheet.write_number (2, worksheet.write_number (3, worksheet.write_datetime(4, worksheet.write_formula (5, worksheet.write_url (6, worksheet.write_boolean (7, workbook.close() 0, 0, 0, 0, 0, 0, 0, 0, 'Hello world') 'Это фраза на русском!') 123) 123.456) date(2013, 10, 13), date_format) '=PI()') 'http://python.com') True)
  • 33. Formulas worksheet.write_formula('A1', '=1+2') worksheet.write_formula('A2', '=A1') worksheet.write_formula('A3', '{=SUM(B1:C1*B2:C2)}') worksheet.write_formula('A4', '=VLOOKUP("Acme", A2:D6, 3, FALSE)')
  • 35. Images import xlsxwriter workbook = xlsxwriter.Workbook('image.xlsx') worksheet = workbook.add_worksheet() worksheet.insert_image(0, 0, 'logo.png') workbook.close()
  • 37. Conditional Formatting import xlsxwriter wb = xlsxwriter.Workbook('conditional_format.xlsx') ws = wb.add_worksheet() high = wb.add_format({'bg_color': '#FFC7CE', 'font_color': '#9C0006'}) low = wb.add_format({'bg_color': '#C6EFCE', 'font_color': '#006100'}) data = [ [88, [24, [6, [73, [36, ] 25, 100, 57, 78, 54, 33, 20, 88, 1, 22, 23, 88, 28, 96, 66, 67, 29, 10, 26, 81, 13], 33], 26], 45], 90], for row, row_data in enumerate(data): ws.write_row(row, 0, row_data) ws.conditional_format('A1:F5', {'type': 'criteria': 'value': 'format': 'cell', '>=', 50, high}) ws.conditional_format('A1:F5', {'type': 'criteria': 'value': 'format': 'cell', '<', 50, low}) wb.close()
  • 40. Charts import xlsxwriter workbook = xlsxwriter.Workbook('chart.xlsx') worksheet = workbook.add_worksheet() # Add the worksheet data to be plotted. data = [10, 40, 50, 20, 10, 50] worksheet.write_column('A1', data) # Create a new chart object. chart = workbook.add_chart({'type': 'area'}) # Add a series to the chart. chart.add_series({'values': '=Sheet1!$A$1:$A$6'}) # Insert the chart into the worksheet. worksheet.insert_chart('C1', chart) workbook.close()
  • 54. Autofilters import xlsxwriter workbook = xlsxwriter.Workbook('autofilter.xlsx') worksheet = workbook.add_worksheet() # Add a format for the headers. header_format = workbook.add_format({'bold': 1, 'bg_color': '#C6EFCE'}) # Populate the worksheet data. # See the xlsxwriter docs for a full example. ... # Make the columns wider. worksheet.set_column('A:D', 12) # Format the header row. worksheet.set_row(0, 20, header_format) # Set the autofilter. worksheet.autofilter('A1:D51') workbook.close()
  • 56. Tables • • • Group a range of cells into a single entity Apply a uniform formatting across the cells Refer to the table in formulas worksheet.add_table('B3:F7', {options})
  • 58. Data Validation • • • Restrict data entry to certain ranges Raise errors/warning within Excel Allow selection from drop down lists data_validation( 'B25', {'validate': 'integer', 'criteria': 'between', 'minimum': 1, 'maximum': 10})
  • 60. Cell Comments • Add comments to cells worksheet.write('A1', 'Hello') worksheet.write_comment('A1', 'This is a comment')
  • 62. Sparklines • • Mini charts within cells to show trends Invented by Edward Tufte
  • 63. Code All the Things! • Lots of features
  • 64. Code All the Things! • • • • Lots of features Useful when you need them Ignore them when you don’t Plenty of examples and documentation to get you started
  • 65. How does it work
  • 66. How does it work • 20% of a studio audience guessed Witchcraft
  • 67. How does it work • • • • 20% of a studio audience guessed Witchcraft Actually a collection of XML files in a Zip file Can be unzipped using standard utilities Even modified in-place (if you are desperate)
  • 68. How does it work $ unzip -o -d hello_world hello_world.xlsx Archive: hello_world.xlsx inflating: hello_world/[Content_Types].xml inflating: hello_world/_rels/.rels inflating: hello_world/docProps/app.xml inflating: hello_world/docProps/core.xml inflating: hello_world/xl/sharedStrings.xml inflating: hello_world/xl/styles.xml inflating: hello_world/xl/workbook.xml inflating: hello_world/xl/_rels/workbook.xml.rels inflating: hello_world/xl/theme/theme1.xml inflating: hello_world/xl/worksheets/sheet1.xml
  • 69. How does it work $ unzip -o -d hello_world hello_world.xlsx Archive: hello_world.xlsx inflating: hello_world/[Content_Types].xml inflating: hello_world/_rels/.rels inflating: hello_world/docProps/app.xml inflating: hello_world/docProps/core.xml inflating: hello_world/xl/sharedStrings.xml inflating: hello_world/xl/styles.xml inflating: hello_world/xl/workbook.xml inflating: hello_world/xl/_rels/workbook.xml.rels inflating: hello_world/xl/theme/theme1.xml inflating: hello_world/xl/worksheets/sheet1.xml
  • 70. How does it work $ unzip -o -d hello_world hello_world.xlsx Archive: hello_world.xlsx inflating: hello_world/[Content_Types].xml inflating: hello_world/_rels/.rels inflating: hello_world/docProps/app.xml inflating: hello_world/docProps/core.xml inflating: hello_world/xl/sharedStrings.xml inflating: hello_world/xl/styles.xml inflating: hello_world/xl/workbook.xml inflating: hello_world/xl/_rels/workbook.xml.rels inflating: hello_world/xl/theme/theme1.xml inflating: hello_world/xl/worksheets/sheet1.xml
  • 71. How does it work $ unzip -o -d hello_world hello_world.xlsx Archive: hello_world.xlsx inflating: hello_world/[Content_Types].xml inflating: hello_world/_rels/.rels inflating: hello_world/docProps/app.xml inflating: hello_world/docProps/core.xml inflating: hello_world/xl/sharedStrings.xml inflating: hello_world/xl/styles.xml inflating: hello_world/xl/workbook.xml inflating: hello_world/xl/_rels/workbook.xml.rels inflating: hello_world/xl/theme/theme1.xml inflating: hello_world/xl/worksheets/sheet1.xml $ xmllint --format hello_world/xl/worksheets/sheet1.xml
  • 72. How does it work $ unzip -o -d hello_world hello_world.xlsx ... $ xmllint --format hello_world/xl/worksheets/sheet1.xml
  • 73. How does it work $ unzip -o -d hello_world hello_world.xlsx ... $ xmllint --format hello_world/xl/worksheets/sheet1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="..." xmlns:r="..."> <dimension ref="A1"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:1"> <c r="A1" t="s"> <v>0</v> </c> </row> </sheetData> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> </worksheet>
  • 74. How does it work $ unzip -o -d hello_world hello_world.xlsx ... $ xmllint --format hello_world/xl/worksheets/sheet1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="..." xmlns:r="..."> <dimension ref="A1"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:1"> <c r="A1" t="s"> <v>0</v> </c> </row> </sheetData> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> </worksheet>
  • 75. How does it work $ unzip -o -d hello_world hello_world.xlsx ... $ xmllint --format hello_world/xl/worksheets/sheet1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="..." xmlns:r="..."> <dimension ref="A1"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:1"> <c r="A1" t="s"> <v>0</v> </c> </row> </sheetData> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> </worksheet>
  • 76. How does it work $ unzip -o -d hello_world hello_world.xlsx ... $ xmllint --format hello_world/xl/worksheets/sheet1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="..." xmlns:r="..."> <dimension ref="A1"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:1"> <c r="A1" t="s"> <v>0</v> </c> </row> </sheetData> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> </worksheet>
  • 77. How does it work $ unzip -o -d hello_world hello_world.xlsx ... $ xmllint --format hello_world/xl/worksheets/sheet1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="..." xmlns:r="..."> <dimension ref="A1"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:1"> <c r="A1" t="s"> <v>0</v> </c> </row> </sheetData> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> </worksheet>
  • 78. How does it work $ unzip -o -d hello_world hello_world.xlsx ... $ xmllint --format hello_world/xl/worksheets/sheet1.xml <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <worksheet xmlns="..." xmlns:r="..."> <dimension ref="A1"/> <sheetViews> <sheetView tabSelected="1" workbookViewId="0"/> </sheetViews> <sheetFormatPr defaultRowHeight="15"/> <sheetData> <row r="1" spans="1:1"> <c r="A1" t="s"> <v>0</v> </c> </row> </sheetData> <pageMargins left="0.7" right="0.7" top="0.75" bottom="0.75" header="0.3" footer="0.3"/> </worksheet>
  • 79. How does it work • • It works well XlsxWriter does the hard work so you don’t have to
  • 80. close() • Next time you need to write an Excel file with Python try XlsxWriter • Clone it on Github, submit issues, add stars http://github.com/jmcnamara/XlsxWriter • Read the documentation https://xlsxwriter.readthedocs.org PDF tutorial, cookbook and manual