How to convert a xls file to csv?

Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to convert a xls file to csv?
# 1  
Old 03-17-2011
How to convert a xls file to csv?

My requirement is to convert the xls to csv file with utf-8 conversion.
Is there any way please suggest me.

# 2  
Old 03-17-2011
Open in Excel, export as CSV? it may not end up in quite the right character set but you could convert that with commandline tools after.

Otherwise you're looking at doing everything with the Perl excel-loading modules and I've got no idea how character sets would be handled with that.
# 3  
Old 03-17-2011
Hi cnraja,

If you want to try with perl modules as mentioned by Corona688, take a look here:

# 4  
Old 03-18-2011
There is also a utility 'xls2csv' that does the job nicely. Its part of package 'catdoc' and should be in a repository of most popular distros.
on RH variants:
sudo yum install catdoc
xls2csv myExcelSpreadsheet.xls > converted.csv

# 5  
Old 03-18-2011
Here is the perl code to parse Excel.


use strict;
use Spreadsheet::ParseExcel;

my $sourcename = shift @ARGV or die "invocation: $0 <source file>\n";
my $source_excel = new Spreadsheet::ParseExcel;
my $source_book = $source_excel->Parse($sourcename) or die "Could not open source Excel file $sourcename: $!";
my $storage_book;

foreach my $source_sheet_number (0 .. $source_book->{SheetCount}-1)
 my $source_sheet = $source_book->{Worksheet}[$source_sheet_number];

 print "--------- SHEET:", $source_sheet->{Name}, "\n";

 next unless defined $source_sheet->{MaxRow};
 next unless $source_sheet->{MinRow} <= $source_sheet->{MaxRow};
 next unless defined $source_sheet->{MaxCol};
 next unless $source_sheet->{MinCol} <= $source_sheet->{MaxCol};

 foreach my $row_index ($source_sheet->{MinRow} .. $source_sheet->{MaxRow})
  foreach my $col_index ($source_sheet->{MinCol} .. $source_sheet->{MaxCol})
   my $source_cell = $source_sheet->{Cells}[$row_index][$col_index];
   if ($source_cell)
    #print "( $row_index , $col_index ) =>", $source_cell->Value, "\t";
    print  $source_cell->Value, "\t";
  print "\n";
print "done!\n";

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Perl script to Convert XLSX or XLS files to CSV file

Hi All, I've got in a situation where I need to convert .xlsx or .xls formatted files into simple text file or .csv file. I've found many options but doing this using PERL script is the best way I believe.I'm in AIX box. Perl code should have 2 params while running. i.e perl... (1 Reply)
Discussion started by: manab86
1 Replies

2. UNIX and Linux Applications

Tool for Convert XLS into CSV in UNIX

Hi I wanted to convert some XLS files into CSV format in my UNIX box. Unix box is handling very important data which are related to data warehouse.It is fully optimized by installing minimum packages since server need more resources to handle reports generating. Just for convert XLS files... (6 Replies)
Discussion started by: luke_devon
6 Replies

3. AIX

How to convert csv file to xls file

Hi All, I have a java program running in AIX machine which gives me the output in form of .CSV but my clients wants output in the form of .xls When I gave the command mv <filename.csv> <filename.xls> The contents of this .xls file is not exactly in seprate columns as in CSV, the contents... (1 Reply)
Discussion started by: chetu777
1 Replies

4. Shell Programming and Scripting

how to convert .xls to .csv

Hi, I have problem..How to convert .xls file to .csv.. Plz help me for this problem.. (1 Reply)
Discussion started by: varma457
1 Replies

5. Shell Programming and Scripting

how to convert XLS to CSV and DOC/RTF to TXT

Hi, i don't know anything about PERL. Can anyone help me providing PERL scripts for 1. converting XLS to CSV (and vice-versa) 2. converting DOC/RTF to TXT Thanks much Prvn (1 Reply)
Discussion started by: prvnrk
1 Replies

6. Shell Programming and Scripting

Shell convert xls to csv

Hi does anybody know how to convert xls to csv undex linux. I need only data (that is log from test, dont need any macro and so on) from xls. Any idea how to do that? Perl? shell? Could you give me any example? Thanks in advance for answer. Gracjan (4 Replies)
Discussion started by: Gracjan
4 Replies

7. Shell Programming and Scripting

converting xls file to txt file and xls to csv

I need to convert an excel file into a text file and an excel file into a CSV file.. any code to do that is appreciated thanks (6 Replies)
Discussion started by: bandar007
6 Replies

8. UNIX for Dummies Questions & Answers

Unix script to convert .csv file to.xls format

I have a .csv file in Unix box i need a UNIX script to convert the.csv files to.xls format. Its very urgent please help me. (1 Reply)
Discussion started by: moon_friend
1 Replies

9. Shell Programming and Scripting

Convert a csv file to an xls format

Hi, I have a file coming in xxx.txt(csv format) i do some work on it and i need to send out as a .xls format. Is there any way there is some code i can use in my script to convert this? I'm struggling on this. Thanks (11 Replies)
Discussion started by: Pablo_beezo
11 Replies

10. Shell Programming and Scripting

From xls to csv file

Can we convert an xls file into csv format in Unix Thanks Suresh (1 Reply)
Discussion started by: sureshg_sampat
1 Replies
Login or Register to Ask a Question

Featured Tech Videos