Writing and Parsing Excel Files

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sivaramapv
    New Member
    • Mar 2007
    • 2

    Writing and Parsing Excel Files

    I'm using perl in windows 2000 OS.i'm using perl,v5.6.0 built for MSWin32-x86-multi-thread
    i have two questions....
    1) In an old thread I've read that to do this we need parseexcel and writeexcel modules which can be downloaded from cpan.
    I've downloaded the two modules which are in zip format and unzipped them.When i tried to run the makefile, some warnings are coming that
    ->io:scalar.pm is a prerequisite it's not available
    ->storage_lite is a prerequisite it's not available
    and so on...
    what are these prerequisites?w here can i get them and how to install them?

    2) Is there any other method to parse and write to excel file without using the writeexcel and parseexcel?
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    Hi,

    For installing cpan modules read the following documentation.

    cpanfaq How to install Perl Modules

    It is possible to install then manually like you're trying to do. But as you discovered, a lot of modules have prerequisites that you'll also need to download and install. Most of the automated install methods can take care of this for you.

    As for if there are other modules that might do this functionality. Yes, there are, but those are the best that I know of. Just search cpan if you're curious. But either way you'll need to learn the more efficient methods for installing modules, so read the above documentation.

    - Miller

    Comment

    • sivaramapv
      New Member
      • Mar 2007
      • 2

      #3
      Thank u Miller for ur reply...
      Actually I've tried to install the parseexcel and write excel modules using ppm also, But I'm getting some errors there also.
      Anyway I'll read the CPAN documentation and will try it out again.

      Comment

      • miller
        Recognized Expert Top Contributor
        • Oct 2006
        • 1086

        #4
        If you're using ActiveState, I would advise that the PPM is probably the way to go. Unfortunately for y'all, I'm not really in a position to suggest how one might fix installation problems as the documentation has always worked perfectly for me on all of my systems (*knocks on wood*).

        Anyway, read on and good luck,

        - Miller

        Comment

        • dim05
          New Member
          • Apr 2007
          • 1

          #5
          Hello,

          for 2) try code below:

          Code:
          #Open file and excel application
          
          use Win32::OLE;
          $excel = Win32::OLE->GetActiveObject('Excel.Application')
          	|| Win32::OLE->new('Excel.Application', 'Quit');
          $first_xls_file = $excel->Workbooks->Open("C:/anydirectory/anyexistingexcel.xls");
          $yourfirstworksheet= $first_xls_file ->Worksheets(1);
          $anyotheralsousefulworksheet= $first_xls_file ->Worksheets(2);
          
          #Now write to any cell by ...
          $text = "hello";
          $yourfirstworksheetreport->Cells(1,1)->{Value} = $text;
          $yourfirstworksheetreport->Cells(2,1)->{Value} = "DOG";
          
          #Now save the xls
          $first_xls_file->SaveAs("C:/anydirectory/anyexistingexcel.xls");
          ############### ###
          Of course you can create a new xls or do more things like playing with cell properties. Try searching for OLE and perl.
          Of course with the code above you don't need to install anything additional
          to the original Perl distribution-installation.
          Unfortunately these interactions between Desk OLE and Perl are not documented (or don't know) but exist.

          Comment

          Working...