The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to change cell background in excel sheet using perl gujrathinr Shell Programming and Scripting 0 07-10-2008 02:01 AM
Change the cell background in excel sheet using Perl gujrathinr UNIX for Dummies Questions & Answers 1 07-09-2008 09:37 AM
Adding columns to excel files using Perl dolo21taf Shell Programming and Scripting 1 02-20-2008 07:13 AM
PERL - [B]Cloning[/B] an Excel file srinivay Shell Programming and Scripting 5 01-11-2005 09:51 AM
Perl - Appending/Modifying Excel files srinivay Shell Programming and Scripting 2 01-10-2005 06:46 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-24-2008
sandeep78 sandeep78 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 6
PERL: Split Excel Workbook to Indiv Excel files

Hi,

I am trying to find a way to read an excel work book with multiple worksheets.
And write each worksheet into a new excel file using perl. My environment is Unix.

For example: I have an excel workbook TEST.xls and it has Sheet1, Sheet2, Sheet3 worksheets. I would like to create Sheet1.xls, Sheet2.xls .....

Any ideas are deeply appreciated.

Thanks for all your time.
  #2 (permalink)  
Old 09-25-2008
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,509
if you have Python, you can install excel module, eg PyExcelarator
Code:
import pyExcelerator,os
book = pyExcelerator.parse_xls("test.xls")
curpath = os.path.dirname(__file__) 
for items in book:
    sheetname=items[0]
    contents=items[1]
    workbook = pyExcelerator.Workbook()
    worksheet = workbook.add_sheet("Sheet 1")     
    for key,value in contents.iteritems():
        print "key ",key, " value: ",value
        worksheet.write(key[0],key[1], value)
        workbook.save(os.path.join(curpath, sheetname+".xls"))
you can search CPAN for Perl excel modules too.
  #3 (permalink)  
Old 09-25-2008
sandeep78 sandeep78 is offline
Registered User
  
 

Join Date: Feb 2008
Posts: 6
Thank you for the response. I dont have python installed.

I checked for the excel modules on CPAN website. I managed to find the modules.

But, I am having trouble putting it together.

use strict;
use Spreadsheet::ParseExcel;
my $Excel = new Spreadsheet::ParseExcel;
my $Book = $Excel->Parse(Test.xls);
$WkS = $Book->{Worksheet}

I got to this point, where I can read the worksheet. How can I write the worksheet to a new excel file? Any ideas please.

Thank you.
Closed Thread

Bookmarks

Tags
perl split

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:10 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0