Convert Excel to CSV

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aravindforperl
    New Member
    • Jan 2007
    • 2

    Convert Excel to CSV

    Hi,

    How to convert a excel file to .csv format?

    Please provide me the Perl Module and the script to do this funcionality.


    Thank you!
  • miller
    Recognized Expert Top Contributor
    • Oct 2006
    • 1086

    #2
    You simply need two CPAN modules to accomplish this:


    Comment

    • aravindforperl
      New Member
      • Jan 2007
      • 2

      #3
      Hi,

      I have installed Spreadsheet::Pa rseExcel in my Unix Machine. When i am trying to call this Module using the below mentioned script, It is giving me a error saying that" Module cannot be found"

      Code:
      use strict;
      use Spreadsheet::ParseExcel;
      
      my $excel = Spreadsheet::ParseExcel::Workbook->Parse(Excel File1.xls);
      foreach my $sheet (@{$excel->{Worksheet}}) {
          printf("Sheet: %s\n", $sheet->{Name});
          $sheet->{MaxRow} ||= $sheet->{MinRow};
          foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) {
              $sheet->{MaxCol} ||= $sheet->{MinCol};
              foreach my $col ($sheet->{MinCol} ..  $sheet->{MaxCol}) {
                  my $cell = $sheet->{Cells}[$row][$col];
                  if ($cell) {
                      printf("( %s , %s ) => %s\n", $row, $col, $cell->{Val});
                  }
              }
          }
      }
      Could you please assist me on this and give me the correct code?

      Thanks,

      Aravind

      Comment

      • Perler
        New Member
        • Jul 2008
        • 1

        #4
        Are you sure that you included something like

        #!/usr/bin/perl

        at the top of your code? Just askin'...


        Originally posted by aravindforperl
        Hi,

        I have installed Spreadsheet::Pa rseExcel in my Unix Machine. When i am trying to call this Module using the below mentioned script, It is giving me a error saying that" Module cannot be found"

        use strict;
        use Spreadsheet::Pa rseExcel;

        my $excel = Spreadsheet::Pa rseExcel::Workb ook->Parse(Excel File1.xls);
        foreach my $sheet (@{$excel->{Worksheet}} ) {
        printf("Sheet: %s\n", $sheet->{Name});
        $sheet->{MaxRow} ||= $sheet->{MinRow};
        foreach my $row ($sheet->{MinRow} .. $sheet->{MaxRow}) {
        $sheet->{MaxCol} ||= $sheet->{MinCol};
        foreach my $col ($sheet->{MinCol} .. $sheet->{MaxCol}) {
        my $cell = $sheet->{Cells}[$row][$col];
        if ($cell) {
        printf("( %s , %s ) => %s\n", $row, $col, $cell->{Val});
        }
        }
        }
        }

        Could you please assist me on this and give me the correct code?

        Thanks,

        Aravind

        Comment

        • numberwhun
          Recognized Expert Moderator Specialist
          • May 2007
          • 3467

          #5
          Originally posted by Perler
          Are you sure that you included something like

          #!/usr/bin/perl

          at the top of your code? Just askin'...
          Perler,

          I think it would be a good idea for you to stick with the newest posts. This post is over 1 1/2 years old and I doubt that the user that posted it will even see it.

          Also, to the point in your post, since they are working with excel spreadsheets, I assume that they were working on a Windows system. The shebang line (#!/usr/bin/perll) is typically ignored on a windows system, unless of course its CGI and then it would have the -T option after it and only then would it be read.

          Regards,

          Jeff

          Comment

          • KevinADC
            Recognized Expert Specialist
            • Jan 2007
            • 4092

            #6
            pssst......Jeff ......

            I have installed Spreadsheet::Pa rseExcel in my Unix Machine

            Comment

            • numberwhun
              Recognized Expert Moderator Specialist
              • May 2007
              • 3467

              #7
              Originally posted by KevinADC
              pssst......Jeff ......
              Ok, bad assumption on my part. Long day!

              Comment

              Working...