Creating Multi-Worksheet Excel Docs with xlwt

This tutorial walks through using the xlwt library to
create a multi-worksheet Excel document in Python. We'll be using the
example of calculating our AWS server expenses, and in adition to xlwt,
we'll also use requests to download the latest EC2 pricing data
from Amazon.

I picked this example because I did exactly that earlier this week,
using the much less enjoyable search-copy-paste method. (Which sadly
means my pricing information is already outdated.)

Preparation

Before we get started, let's create a virtualenv to install our Python dependencies into.
(If you haven't used virtualenv before take a gander here to get up to speed, it's a
straightforward way to manage packages requirements for different projects.)

Now we can play around with our infrastructure costs just by changing the values
in the Num Instances column. The last piece is to add a row which sums
the total infrastructure cost across all instances.

Finally, we need to call this new write_instances function as part
of creating our workbook. Note that you must create the EC2 Pricing
worksheet before populating the Instances worksheet because xlwt
verifies existance of cross-referenced worksheets.

It only validates the worksheet exists--not whether the specific cross-referenced rows exist--so you can
still create Instances before EC2 Pricing as long as
you wait to call write_instances until after both exist.