[Tutor] How to Create Webpage with Python
John Cast
jdcast at stanford.edu
Tue Jul 15 18:48:37 CEST 2014
Yes, that's exactly what I'm trying to do. However, when testing this out
manually like I pointed to above, the output of the save as feature freezes
the column widths. This would be fine except that not all of the column
widths are expanded so that all of the text can be seen (at the moment I
don't have any control over how the sheets are made, just access to them),
so when the save as feature does its thing, some text is blocked.
That's why I need a way to go through each sheet and adjust the widths and
then programmatically do a save as webpage for all of them from python.
So I guess this brings me back to my previous post's questions:
1) How does one automate the save as webpage from python?
2) What is the most straightforward way to adjust the column widths of the
existing excel sheets?
Any hints/guidance/answers are greatly appreciated.
Thanks again
On Tue, Jul 15, 2014 at 1:20 AM, Chris “Kwpolska” Warrick <
kwpolska at gmail.com> wrote:
>
> 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/cbfcfe5c/attachment.html>
More information about the Tutor
mailing list