Excel module for Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sam

    #1

    Excel module for Python

    Hi group,

    I m wondering which Excel module is good to be used by Python?

    Thanks
    Sam
  • Peter Hansen

    #2
    Re: Excel module for Python

    sam wrote:[color=blue]
    > I m wondering which Excel module is good to be used by Python?[/color]

    Just use Excel's COM interface.

    See also this helpful page to improve future responses:


    -Peter

    Comment

    • Simon Brunning

      #3
      Re: Excel module for Python

      On Wed, 12 Jan 2005 15:18:09 +0800, sam <sam.wun@authte c.com> wrote:[color=blue]
      > I m wondering which Excel module is good to be used by Python?[/color]

      If you are on Windows, and you have Excel, then the Python for Windows
      extensions[1] are all you need to drive Excel via COM. O'Reilly's
      "Python Programming on Win32" covers COM scripting extensively - and
      by good fortune, driving Excel is the example they use, and the COM
      scripting chapter is on-line[2].

      You'll also need to know the objects and methods that Excel exposes.
      These are documented on Microsoft's web site[3], or in the Excel VBA
      help, which is an optional part of they Office installation.

      --
      Cheers,
      Simon B,
      simon@brunningo nline.net,


      [1] http://starship.python.net/crew/mhammond/
      [2] http://www.oreilly.com/catalog/pytho...pter/ch12.html
      [3] http://msdn.microsoft.com/library/en...celObjects.asp

      Comment

      • sam

        #4
        Re: Excel module for Python

        Simon Brunning wrote:
        [color=blue]
        > On Wed, 12 Jan 2005 15:18:09 +0800, sam <sam.wun@authte c.com> wrote:
        >[color=green]
        >>I m wondering which Excel module is good to be used by Python?[/color]
        >
        >
        > If you are on Windows, and you have Excel, then the Python for Windows
        > extensions[1] are all you need to drive Excel via COM. O'Reilly's
        > "Python Programming on Win32" covers COM scripting extensively - and
        > by good fortune, driving Excel is the example they use, and the COM
        > scripting chapter is on-line[2].
        >
        > You'll also need to know the objects and methods that Excel exposes.
        > These are documented on Microsoft's web site[3], or in the Excel VBA
        > help, which is an optional part of they Office installation.
        >[/color]

        No, I don't use MS windows. I need to generate Excel file by printing
        data to it, just like Perl module Spreadsheet::Wr iteExcel.

        thanks
        Sam

        Comment

        • sp1d3rx@gmail.com

          #5
          Re: Excel module for Python

          that's easy. Just make an html file of your data, using tables and save
          it as a "*.xls" and excel will think it's an excel file.

          Comment

          • Peter Hansen

            #6
            Re: Excel module for Python

            sam wrote:[color=blue][color=green]
            >> On Wed, 12 Jan 2005 15:18:09 +0800, sam <sam.wun@authte c.com> wrote:[color=darkred]
            >>> I m wondering which Excel module is good to be used by Python?[/color][/color][/color]
            [snip][color=blue]
            > No, I don't use MS windows. I need to generate Excel file by printing
            > data to it, just like Perl module Spreadsheet::Wr iteExcel.[/color]

            Excel can read CSV files, so just use the standard Python module "csv"
            and write your files that way.

            -Peter

            Comment

            • Simon Brunning

              #7
              Re: Excel module for Python

              On Wed, 12 Jan 2005 23:19:44 +0800, sam <sam.wun@authte c.com> wrote:[color=blue]
              >
              > No, I don't use MS windows. I need to generate Excel file by printing
              > data to it, just like Perl module Spreadsheet::Wr iteExcel.[/color]

              If it's just data that needs to go into your spreadsheet, then I'd
              just build a CSV file if I were you. Excel opens them perfectly
              happily.

              If you need to write out formulae, formratting, that kind of thing,
              then I think you'll need to write a 'real' Excel file. I don't have a
              clue how to do that - sorry.

              --
              Cheers,
              Simon B,
              simon@brunningo nline.net,

              Comment

              • Neil Benn

                #8
                Re: Excel module for Python

                sam wrote:
                [color=blue]
                > Simon Brunning wrote:
                >[color=green]
                >> On Wed, 12 Jan 2005 15:18:09 +0800, sam <sam.wun@authte c.com> wrote:
                >>[color=darkred]
                >>> I m wondering which Excel module is good to be used by Python?[/color]
                >>
                >>
                >>
                >> If you are on Windows, and you have Excel, then the Python for Windows
                >> extensions[1] are all you need to drive Excel via COM. O'Reilly's
                >> "Python Programming on Win32" covers COM scripting extensively - and
                >> by good fortune, driving Excel is the example they use, and the COM
                >> scripting chapter is on-line[2].
                >>
                >> You'll also need to know the objects and methods that Excel exposes.
                >> These are documented on Microsoft's web site[3], or in the Excel VBA
                >> help, which is an optional part of they Office installation.
                >>[/color]
                >
                > No, I don't use MS windows. I need to generate Excel file by printing
                > data to it, just like Perl module Spreadsheet::Wr iteExcel.
                >
                > thanks
                > Sam[/color]

                Hello,

                If you can use jython then there is something that does this
                in java - it's called POI (search for POI HSSF Excel) in google. If you
                can't use jython and are desperate then you could set up a
                WebService/cgi/<insert your favourite cross language client/server
                architecture> and send the information back and forth. I spose you can
                do this with perl as well (don't know any perl so this bit is only a
                guess!).

                However the last time I looked (about a year ago) POI does have
                limitations with excel graphs.

                Cheers,

                Neil

                Comment

                • Erwin S. Andreasen

                  #9
                  Re: Excel module for Python

                  Simon Brunning <simon.brunning @gmail.com> writes:
                  [color=blue]
                  > On Wed, 12 Jan 2005 23:19:44 +0800, sam <sam.wun@authte c.com> wrote:[color=green]
                  >>
                  >> No, I don't use MS windows. I need to generate Excel file by printing
                  >> data to it, just like Perl module Spreadsheet::Wr iteExcel.[/color][/color]
                  [color=blue]
                  > If you need to write out formulae, formratting, that kind of thing,
                  > then I think you'll need to write a 'real' Excel file. I don't have a
                  > clue how to do that - sorry.[/color]

                  There's actually an ancient open spreadsheet format called SYLK which
                  is a step above CSV: it allows formatting of data, formulas etc.

                  Google for SYLK to get the rather sparse specification (and skip over
                  the first few links!)

                  If you want to generate "real" Office files from UNIX, another
                  alternative is to automate OpenOffice (which has a COM-like interface
                  too) or generate OO XML files and feed them to OO asking to conver
                  them with a bit of OO macro magic.



                  --
                  =============== =============== =============== =============== ===
                  <erwin+usenet@a ndreasen.org> Herlev, Denmark
                  <URL:http://www.andreasen.o rg/> <*>
                  =============== =============== =============== =============== ===

                  Comment

                  • Stefan Eischet

                    #10
                    Re: Excel module for Python

                    Hi,

                    I didn't catch older mails in this thread, so excuse me if this has
                    already been pointed out:

                    python xls excel spreadsheet workbook database table


                    "It's a port of John McNamara's Perl Spreadsheet::Wr iteExcel module"
                    and it's really easy to use.
                    I'm not sure if it does formulae, but it handles formatting fine.

                    Putting together a file with complicated layout can be a lot of work,
                    so for large prebuilt files (which I sometimes have to "fill in"
                    programmaticall y), I just use COM with Excel. You'll have to run on
                    Windows for that, of course. ;-)

                    Cheers
                    Stefan

                    On 16.01.2005, at 22:19, Erwin S. Andreasen wrote:
                    [color=blue]
                    > Simon Brunning <simon.brunning @gmail.com> writes:
                    >[color=green]
                    >> On Wed, 12 Jan 2005 23:19:44 +0800, sam <sam.wun@authte c.com> wrote:[color=darkred]
                    >>>
                    >>> No, I don't use MS windows. I need to generate Excel file by printing
                    >>> data to it, just like Perl module Spreadsheet::Wr iteExcel.[/color][/color]
                    >[color=green]
                    >> If you need to write out formulae, formratting, that kind of thing,
                    >> then I think you'll need to write a 'real' Excel file. I don't have a
                    >> clue how to do that - sorry.[/color]
                    >
                    > There's actually an ancient open spreadsheet format called SYLK which
                    > is a step above CSV: it allows formatting of data, formulas etc.
                    >
                    > Google for SYLK to get the rather sparse specification (and skip over
                    > the first few links!)
                    >
                    > If you want to generate "real" Office files from UNIX, another
                    > alternative is to automate OpenOffice (which has a COM-like interface
                    > too) or generate OO XML files and feed them to OO asking to conver
                    > them with a bit of OO macro magic.
                    >[/color]

                    Comment

                    • jean-paul

                      #11
                      Re: Excel module for Python

                      I generate a lot pseudo excel file. Just write row by row on file and
                      separate every cell of a row by a tab and put an .xls extension on the
                      file name. When you double click. It opens directly EXCEL and you have
                      directly the column and the row. It is easier than the CSV or SYLK
                      files. If you want to format it automatically you can either define a
                      VBA macro or use python com.

                      Cheers,

                      Jean-Paul

                      Comment

                      Working...