convertion from .xls to .csv
Anonymous Monk
created: 2006-08-03 07:37:23
hi monks, how can i convert excel.xls to .CSV file in harddisk. keep pouring your ideas.......
Re: convertion from .xls to .csv
cbu
created: 2006-08-03 07:46:30
If you install Spreadsheet::ParseExcel, Text::CSV_XS, and Spreadsheet::Read, the last will use the first two in a util that will optionally be installed.
# xlscat -c book.xls > book.csv
Done!
Re: convertion from .xls to .csv
created: 2006-08-03 08:20:28

Spreadsheet::Read comes with a nice little utility xlscat for reading a few kinds of spreadsheets and writing out some text files.

⠤⠤ ⠙⠊⠕⠞⠁⠇⠑⠧⠊

Re: convertion from .xls to .csv
created: 2006-08-03 08:51:08
Hi

As the above monks said you hav to install

Spreadsheet::WriteExcel and also Text::CSV_XS . I hope this could be helpful for you. And also before posting a query do some work and just show us that u have tried out something so that we can help u in a better way.


 #!/usr/bin/perl
# Transfer The CSV File data To Xcel Sheet

use strict;
use Text::CSV_XS;
use Spreadsheet::WriteExcel;


#### Create A Xcel SpreadSheet  ####

     my $workbook  = Spreadsheet::WriteExcel->new("csv-xcel.xls") or die ("Cannot Create Xcel : $!\n ");
     my $worksheet = $workbook->add_worksheet();

#### Create The CSV Text  ####

     my $csv = Text::CSV_XS->new;
     my ( $row, $col, $fc, $comma, @fcsv, @fields );

###

     open( CSV, "data.txt") or die ("Couldn't Open The Text File : $!\n ");
     @fcsv = ;
     close(CSV);

     foreach $fc (@fcsv)
      {
        if ( $csv->parse($fc) )
         {
           $col= 0;
           @fields = $csv->fields;

           foreach $comma ( @fields )
             {
               $worksheet->write($row,$col,$comma);
                    $col++;
             }
          }
          $row++;
      }

   print "Xcel sheet xls is Created ! \n";
Re^2: convertion from .xls to .csv
created: 2006-08-03 09:29:54
Your reply gives example code for converting a CSV file to a spreadsheet file. However the OP was asking how to do the opposite; converting a spreadsheet to a CSV.

Cheers,

JohnGG

Re: convertion from .xls to .csv
created: 2006-08-03 11:55:13
This one uses tabs tsv, but you could convert it xls2tab - Simple MS Excel to TSV converter

I'm not really a human, but I play one on earth. Cogito ergo sum a bum

perlmonks.org content © perlmonks.org and Anonymous Monk, cbu, diotalevi, johngg, msk_0984, zentara

prlmnks.org © 2006 edmund von der burg (eccles & toad)

v 0.03