xlhtml output to a file
  • rms
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    rms
    Posts: 602 from 2004/11/27
    Hi,

    I need to convert xls files because we still don't have a reader to something readable under MorhpOS 2.4. I found
    xlhtml. Now this works good enough for my purpose only I wasn't able to output the result directly to a file with
    an .html extension so I can then double click and OWB shows it. Could anyone help me with the command line?

    Here is what xlhtml gives:

    xlhtml converts excel files (.xls) to Html.
    Copyright (c) 1999-2001, Charles Wyble. Released under GPL.
    Usage: xlhtml [-xp:# -xc:#-# -xr:#-# -bc###### -bi???????? -tc######] <FILE>
    -a: aggressive html optimization
    -asc ascii output for -dp & -x? options
    -csv comma separated value output for -dp & -x? options
    -xml XML output
    -bc: Set default background color - default white
    -bi: Set background image path
    -c: Center justify tables
    -dp: Dumps page count and max rows & colums per page
    -v: Prints program version number
    -fw: Suppress formula warnings
    -m: No encoding for multibyte
    -nc: No Colors - black & white
    -nh: No Html Headers
    -tc: Set default text color - default black
    -te: Trims empty rows & columns at the edges of a worksheet
    -xc: Columns (separated by a dash) for extraction (zero based)
    -xp: Page extracted (zero based)
    -xr: Rows (separated by a dash) to be extracted (zero based)
  • »03.12.09 - 05:45
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Yomgui
    Posts: 348 from 2004/8/31
    From: Québec - Canada
    I've also seen that there is various Excel reader libraries for Python:

    Check this url

    [edit]
    I'm looking inside the code of PyExcelerator... seems to be compatible with python 2.5.4 mos... but I can't check now

    [ Edited by Yomgui on 2009/12/3 11:14 ]
    And now... next project!
  • »03.12.09 - 09:53
    Profile Visit Website
  • rms
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    rms
    Posts: 602 from 2004/11/27
    @ Yomgui

    great, I had a look, downloaded but dont know how to install this, neither use it.
    Does python ./setup.py install work? Woud this be enough?
  • »03.12.09 - 10:30
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Yomgui
    Posts: 348 from 2004/8/31
    From: Québec - Canada
    @RMS:
    as usual with python:

    python setup.py install

    (it's a pure python module, no C modules)
    Try yourself, I can't do anything now.

    After installation, take a look in examples directory. there is a xls2html.py script.
    And now... next project!
  • »03.12.09 - 11:08
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Yomgui
    Posts: 348 from 2004/8/31
    From: Québec - Canada
    @Christoph:

    OK, les scripts que j'ai test? dans "examples" passent sans probl?mes chez moi avec la 2.5.4.
    And now... next project!
  • »03.12.09 - 17:59
    Profile Visit Website
  • rms
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    rms
    Posts: 602 from 2004/11/27
    @ Yomgui

    thanks for feed-back! Yes after install and I tried my file and it worked fine :-) though I still have the problem
    that I don't know how to generate directly an html file instead of having the output in the shell... :-(

    Here is the command line I use:

    Ram Disk:> python System:Libs/python2.5/xls2html.py P1-Storage:Download/Badge_commande_RMS.xls

    then I have to select the text in the shell, open an editor and save it...

    In fact I'd like to install under Ambient a key to open a select window where I can select an excel file and then the
    file gets saved in ram: with the .html extension so owb will open when double click in the saved file.

    Possible?
  • »03.12.09 - 18:29
    Profile Visit Website
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    I guess ordinary redirection of output will make it:

    python System:Libs/python2.5/xls2html.py somefile.xls >ram:somefile.html
  • »03.12.09 - 20:13
    Profile Visit Website
  • rms
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    rms
    Posts: 602 from 2004/11/27
    @ Krashan

    thanks for feed-back, yes this works :-) though I didn't manage to install a hotkey to to the operation. What I would like is to press a hotkey, a file selector opens lets me select the xls file, then press ok and the script converts the xls to html and puts the converted file in the same place where the source file lies and with the same name as the source file but with .html extension instead of .xls

    I tried as AmigaDOS command:
    run python System:Libs/python2.5/xls2html.py %sp

    here I have to select the xls file 1st then I press the hotkey and this does the conversion but the output is not written do a file...

    Any idea how I can do that?
  • »04.12.09 - 05:11
    Profile Visit Website
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    You need to create a DOS script. It should take your *.xls file name as a parameter and should use 'requestfile' DOS command for getting the path to *.html to be generated. Here is an example:

    Code:
    .key spreadsheet/A
    .bra {
    .ket }
    python System:Libs/python2.5/xls2html.py {spreadsheet} >`requestfile`

    You can save the script as, let's say 'S:xls2html' (don't forget to set the 'S' flag for the file) and use following DOS action in Ambient:

    Code:
    S:xls2html %sp
  • »04.12.09 - 05:52
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Yomgui
    Posts: 348 from 2004/8/31
    From: Québec - Canada
    Just a little recommendation:

    put 'tools' scripts in C: or any other locations, but not in the 'modules' repository LIBS:pythonX.Y/

    It's more clean ;-)

    Even if all python scripts finish with .py, the usage is not the same: some act like libraries (os.py for example), some others act more like tools or end-user program, like xls2html.py.
    So it could be good to separate them also.

    The benefit of that it's when a new version comes (like between 2.4 and 2.5, moreover with 3.x), you don't have to duplicate 'tools' scripts.
    And modules are in general installed using distutils (the famous setup.py).

    FYI: my distutils port installs scripts in C: by default when given as tools scripts in setup.py!


    [ Edited by Yomgui on 2009/12/4 14:25 ]
    And now... next project!
  • »04.12.09 - 13:21
    Profile Visit Website
  • rms
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    rms
    Posts: 602 from 2004/11/27
    @ Krashan

    Great, thanks for your help :-) So if I understand it right, I need to do a script everytime I want something like this, it's not possible to do it right in e. g. Ambient...

    I just tried something else, I configured the filetype action in Ambient for .xls on double click so it uses the xls2html.py script to convert the file, the AmigaDOS command is: run python System:C/xls2html_cp1252.py %sp, this again outputs in the shell window. Now how would it be possible to output the converted to html file in the same directory as the .xls file with the same name (just extension changed)? Is an automated redirection here also possible?

    Thanks very much in advance for your help!


    @Yomgui

    thanks for the infos, I placed these "tools" scripts now in c:
  • »05.12.09 - 06:06
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    DiskDoctor
    Posts: 306 from 2009/4/17
    From: Rzeszow, place...
    Quote:


    Yomgui wrote:
    I've also seen that there is various Excel reader libraries for Python:

    Check this url

    [edit]
    I'm looking inside the code of PyExcelerator... seems to be compatible with python 2.5.4 mos... but I can't check now

    [ Edited by Yomgui on 2009/12/3 11:14 ]


    PyExcelerator was my library of choice in order to write a GUI spreadsheet for MorphOS.

    I was using it in my other python program for xls parsing/encoding.

    I plan to incorporate pyExcelerator with PyMUI and hence create an app. Regarding this scripting idea here - I managed to write a python script using pyexceleartor and PIL alone that reads out excel file and outputs a picture (a viewer kind of then). Unfortunately I couldn't make it work under MorphOS since both python2.4 and 2.5 have lacks in zlib or zipfile modules. I wrote about my problems already.

    Also I kind of await any PyMui tutorial / api / doc / samples so that I can start writting and testing the app that has GUI features.
    Was: Mac Mini PPC running MorphOS 2.4
    Now: Amiga Forever 2010 with AmiKit and AmigaSYS
    Not used: Icaros Desktop 1.2 (reason: no wifi)
    Planned soon: an OS4 system
    Shortly then: a MOS notebook (wifi is a must-have)
  • »05.12.09 - 18:56
    Profile
  • Order of the Butterfly
    Order of the Butterfly
    Yomgui
    Posts: 348 from 2004/8/31
    From: Québec - Canada
    @diskdoctor: why you always said that Python 2.5 lacks of zlib? It doesn't since the r41.

    I've replied to your email about the doc: I'll make it, but let me some time to cleanup the rest of projects (6!).
    And now... next project!
  • »06.12.09 - 14:28
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    DiskDoctor
    Posts: 306 from 2009/4/17
    From: Rzeszow, place...
    Quote:


    Yomgui wrote:
    @diskdoctor: why you always said that Python 2.5 lacks of zlib? It doesn't since the r41.



    I use PIL that you built. I also use instruction of writtint text onto a picture with a default font. See my regarding post for the traceback... It cannot be done due to zlib/zipfile missing. And I yes, mean Python-2.5.4 r42.

    Quote:


    I've replied to your email about the doc: I'll make it, but let me some time to cleanup the rest of projects (6!).



    OK Now I read your code so I think the sample should be enough to me as a manual kind of :-) Forget the manual for the time being :-) :-)
    Was: Mac Mini PPC running MorphOS 2.4
    Now: Amiga Forever 2010 with AmiKit and AmigaSYS
    Not used: Icaros Desktop 1.2 (reason: no wifi)
    Planned soon: an OS4 system
    Shortly then: a MOS notebook (wifi is a must-have)
  • »06.12.09 - 20:42
    Profile
  • rms
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    rms
    Posts: 602 from 2004/11/27
    Quote:


    I just tried something else, I configured the filetype action in Ambient for .xls on double click so it uses the xls2html.py script to convert the file, the AmigaDOS command is: run python System:C/xls2html_cp1252.py %sp, this again outputs in the shell window. Now how would it be possible to output the converted to html file in the same directory as the .xls file with the same name (just extension changed)? Is an automated redirection here also possible?



    Can nobody help me here? :-(

    I had another idea, oerhaps it's possible on double click on the xls file that it converts to .html and then directly opens OWB and shows the result. Would this be possible? If someone has an idea, please let me know, thanks in advance!
  • »08.12.09 - 06:19
    Profile Visit Website
  • MorphOS Developer
    Krashan
    Posts: 1107 from 2003/6/11
    From: Białystok...
    Would this be possible?

    Yes it can be done with an ARexx script. But don't expect me to write a script for you, while I should be fixing bugs in DigiBooster 3 ;-).
  • »08.12.09 - 06:30
    Profile Visit Website
  • Order of the Butterfly
    Order of the Butterfly
    Yomgui
    Posts: 348 from 2004/8/31
    From: Québec - Canada
    Yes! Can be done in ARexx, in Python (using arexx module also), in Shell, ...
    But I'm also overbusy :-(
    And now... next project!
  • »08.12.09 - 07:19
    Profile Visit Website
  • rms
  • Priest of the Order of the Butterfly
    Priest of the Order of the Butterfly
    rms
    Posts: 602 from 2004/11/27
    @ Krashan and Yomgui

    don't worry, no problem, thanks for your feed-back! I didn't think that a tiny functionnality like this needs so much stuff to be done...

    Bugfixing and development of your ports is much more important ;-)
  • »08.12.09 - 14:51
    Profile Visit Website