[Tutor] How to Create Webpage with Python

Chris “Kwpolska” Warrick kwpolska at gmail.com
Tue Jul 15 10:20:31 CEST 2014


On Jul 15, 2014 3:17 AM, "John Cast" <jdcast at stanford.edu> wrote:
>
> Hey everyone,
>
> I really appreciate all of the help you given me.
> I am making progress, however I have reached a problem I'm not sure how
best to tackle and would like someone with more experience with excel and
python to lend their knowledge/opinion before I dive in further.
>
> I have two questions:
> 1) I'd like to be able to do a 'save-as web page' in python for my excel
workbook.  I tried this by hand and everything looks good EXCEPT that the
header cells sometimes were too narrow (because the person who created the
workbook didn't expand out each column enough sometimes) and thus blocked
some of the text in them occasionally.
> Is it possible to do a 'save-as web page' for the workbook in python?
>
> 2)  So (assuming I can do this 'save-as webpage' in code) I need to go
through each sheet in the workbook and change each column's width so that
it can hold all of its text.  I realize that xlrd is for reading and xlwt
is for writing and there is xutils for particular combinations of both
reading and writing.  However, nothing to do quite what I've stated as far
as I can tell (so far).  I currently open the workbook I want to modify
using the open_workbook functionality in the xlrd module.  As I understand
it I need the xlwt module to write to this workbook, but since it's opened
in xlrd do I just open the same workbook in xlwt again?  If so does each
module simply have a handle to the same file?
>
> NOTE: I'm basically just trying to present my excel workbook on the web
as it's shown in excel (retaining as much formatting as possible).
>
> Thanks again,
> John

If you want to have output that's very close to Excel’s, why not just use
Excel’s save as webpage capabilities? You can automate that, with Python or
something else (like Excel macros or Windows-specific automation software).
It's much easier to do it this way, and it guarantees good output without
much effort.

-- 
Chris “Kwpolska” Warrick <http://chriswarrick.com/>
Sent from my SGS3.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140715/9906c03a/attachment-0001.html>


More information about the Tutor mailing list