Hey everyone, So against all of your better judgement I went ahead and implemented my server through the simpleHTTPServer in python and used win32com to hook up to excel to widen the existing excel columns and then call "SaveAs()" into .htm format (basically programmatically doing the "save as webpage format in excel" that you can do by hand) and then opening the server up in the directory that I save these output HTML files. This is a side project at work and the people that gave it to were quite pleased with how it looked. However, their enthusiasm led them to want even more functionality. This functionality includes making a couple of graphs for each sheet in the excel workbook and serving these graphs up as well as being able to store/edit comments for each row of each sheet in the workbook once it's served up (each row of each sheet is basically a work task with some information for it found in the columns).
Now the tricky part... This script will eventually be used to routinely pull down information found on some website (which it can already do), probably in a cron job. Doing this will find the most recent information for each excel sheet. I have to be able to keep track of this information over time and update the graphs for each sheet accordingly (some rows may be deleted, some rows may have edited comments (always last column) and some rows maybe completely new, maybe even whole sheets will be gone or added as well). All of the information in the excel sheets is text. I would be counting text occurrences for the graphs. Since I cheated and used win32com to access excel and have it do the dirty work of saving the excel workbook into HTML format I don't really have direct access to the HTML creation and don't have a good way of storing data pertaining to each sheet (i.e. graph information and comments for each row of each sheet). So I am thinking I am going to have to backtrack in my work and take a new approach. Here come my questions/ideas and I'd like to hear all of your thoughts on them if you have time: 1) What are your ideas on how best to accomplish all of this given where I have stated my project is at? 2) My current idea is to investigate some kind of database, probably mysql so that I can store the information for each excel sheet. Is this smart/easy/possible/efficient? I am guessing it might be possible to store each excel sheet (or instead maybe the two graphs for each sheet and the row/comment relations so as to only keep around what I really need) under a name identifier as separate entities in the mysql database. Is this smart/easy/possible/efficient to do? 3) I am guessing I have to go back and redo how I generate my HTML. Right now I generate an index.html file that simply displays some text and then has a hyperlink to the excel generated webpage version of the original excel workbook. The index.html is generated in python by printing it to a new index.html file every time the script is run. I would like to keep the look of how excel generates each sheet into HTML (basically it just looks like the exact excel sheet but on the web) while displaying two graphs for each each sheet. I was thinking I could simply insert the links for the graphs into the index.html page or insert the links for the graphs into their respective sheet's HTML page or simply display the graphs directly on their respective sheet's HTML page. What sounds reasonable/easiest here? 4) I need to somehow allows the comment cell in each row to be interactive in the sense that it needs to be editable when it is displayed as well as be persistent (stored). I am at a bit of a loss as where to begin with this. 5) Will I need to switch to a new server? e.g. Django, apache? Or can I keep doing things in the simpleHTTPServer within python? Mind you that other than this project I have very little experience with any of this. That said I am looking for a fair balance of efficiency and ease to accomplish all of this. My time frame is about 3 weeks. I welcome any help/tips/opinions that you all can offer. Thanks On Tue, Jul 15, 2014 at 12:46 PM, Alan Gauld <alan.ga...@btinternet.com> wrote: > On 15/07/14 17:48, John Cast wrote: > > 1) How does one automate the save as webpage from python? >> > > It is possible using COM objects and the pywin32 library. > However that's rarely the best way to approach things. > But if you insist... > > Here is a short example of opening a FileOpen dialog... > > import win32com.client as com > filepath = r"D:\Whatever\You\want" > fileopen = 1 # change to whatever code you need of 1-4 > app = com.Dispatch("Excel.Ap[plication") > app.Visible = True > fd - app.FileDialog(fileopen) > fd.InitialFileName = filepath > fd.Title = "Open a file" > if fd.Show() == -1: > fd.Execute() > > I'll let you use your imagination (and the MSDN web site?) to > work out how to do a SaveAs dialog and populate it with the > right values. > > The last 2 lines check if the user actually hit the Open or OK > button and then tell Excel to open the file. > > There are other direct commands so you preobably can saveAs > directly if you search the docs. > > > 2) What is the most straightforward way to adjust the column widths of >> the existing excel sheets? >> > > Again its possible by using COM to drive the workbook objects. > But again its not the best way to address this. > > > Any hints/guidance/answers are greatly appreciated. >> > > OK, Use another approach! > > Use xlrd to read the data out and insert it into an HTML page. > Use the one output by Excel as a template (although you can probably > delete most of it as unnecessary cruft produced by Microsoft.( > > That gives you control over the look independent of anything > the users of Excel may do. > > > -- > Alan G > Author of the Learn to Program web site > http://www.alan-g.me.uk/ > http://www.flickr.com/photos/alangauldphotos > > _______________________________________________ > Tutor maillist - Tutor@python.org > To unsubscribe or change subscription options: > https://mail.python.org/mailman/listinfo/tutor >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor