Dealing with XLS file with multiple tabs

 
Thread Tools Search this Thread
Homework and Emergencies Emergency UNIX and Linux Support Dealing with XLS file with multiple tabs
# 1  
Old 04-21-2014
Dealing with XLS file with multiple tabs

Hey Guys ,

Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below :

1. Convert one XLS file with multiple tabs to multiple CSV files.
-- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But during this , i read lots of forum and learnt that UNIX shell scripting do not have any utility or solution for this.Is this really true?bcaz i everywhere found ppl recommending PERL or other stuff .

----------------------
Real Problem.
----------------------
2. Once Files are converted to CSV , we have to rename all CSV files with names as in different tab from XLS i.e first CSV should be named as the first tab in that XLS and so on .

Is there anyway in scripting to capture those tab names from XLS?

and if not , what alternative i should try to make this happen ?

I am eagerly looking forward for your replies.

Cheers!!!
Himanshu Sood
# 2  
Old 04-21-2014
Additional Information:-

Added attachment has 3 sheets in that and the new csv files need to have those names in it .

E.g :-
Origin File Name :- 20130430_Himanshu.xls

CSV File Name :-
20130430_DE000A0V7550_Himanshu.csv
20130430_DE000A0V7568_Himanshu.csv
20130430_DE000A0V7570 _Himanshu.csv
# 3  
Old 04-21-2014
himanshu,
One solution would be to write a VBA/macro in Excel or Open Office itself to perform the actions in your requirement. XLS files are binary, not text, files so writing scripts to read and process XLS files will not work unless you first convert them to text/csv files (or you use API's such as in Open Office or ActiveX - Windows to interact with them).
# 4  
Old 04-21-2014
mjf,

I have converted my files to csv using Applescript and now the problem is renaming themas required.
As i dont want to hard code anything so looking for some dynamic way to do so.

Any help ?

Regards,
Himansuh Sood
# 5  
Old 04-21-2014
VBA Code
Code:
Sub Splitbook()
MyPath = ThisWorkbook.Path
For Each sht In ThisWorkbook.Sheets
sht.Copy
ActiveSheet.Cells.Copy
ActiveSheet.Cells.PasteSpecial Paste:=xlPasteValues
ActiveSheet.Cells.PasteSpecial Paste:=xlPasteFormats
ActiveWorkbook.SaveAs _
Filename:=MyPath & "\" & sht.Name & ".xls"
ActiveWorkbook.Close savechanges:=False
Next sht
End Sub

---------- Post updated at 09:08 AM ---------- Previous update was at 09:02 AM ----------

This code is tested and working for me
# 6  
Old 04-21-2014
Hello Sri,

Is it possible to add this VBA stuff to Shell script ?

Anyone out there can help me on this using scripting .

Himanshu Sood
# 7  
Old 04-22-2014
I don't think that is possible with shell scripting
You will have to load some excel packages to deal with excel files and you have to go with Perl or java or some other programming code

---------- Post updated 04-22-14 at 12:53 AM ---------- Previous update was 04-21-14 at 01:42 PM ----------

Below links might help you to get started
Spreadsheet::WriteExcel
Spreadsheet::SimpleExcel - search.cpan.org
This User Gave Thanks to SriniShoo For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How to check string contain multiple tabs or spaces?

str contains tabs and multiple spaces str="hello world. How are you?" I want to check string start with hello world, and my code is: if ]world"* ]]; then echo "found" else echo "not found" fi Not work Other solution may work is to replace all tabs and... (4 Replies)
Discussion started by: cmdcmd
4 Replies

2. Shell Programming and Scripting

Merging Multiple XLS into Different tabs in xls/ xlsx

HI, I have multiple files per dept in folder for eg : In a folder File1_Dept100.xls File2_Dept100.xls File3_Dept100.xls File1_Dept200.xls File2_Dept200.xls File3_Dept200.xls Output should be : Dept100.xls which has File1, File2, File3 in different tabs Dept200.xls which has... (1 Reply)
Discussion started by: venkyzrocks
1 Replies

3. Shell Programming and Scripting

Script to launch a KDE Konsole window with multiple tabs

Gents, I found this script to to launch a KDE Konsole window with multiple tabs.. #!/bin/bash # # Create my standard konsole windows. if ]; then profile=Shell fi sessions=( sh1 $profile 'clear; bash' sh1 $profile 'clear; bash' su1 $profile 'clear; su'... (1 Reply)
Discussion started by: jiam912
1 Replies

4. UNIX for Advanced & Expert Users

Shell script for dealing with XLS file with multiple tabs/worksheets

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (2 Replies)
Discussion started by: himanshu sood
2 Replies

5. UNIX and Linux Applications

Firefox Warning message for closing with multiple tabs not working

Can anyone explain why firefox warning message for closing with multiple tabs not working. The checkbox for warning when you have multiple tabs is checked so I don't understand why its not working. (0 Replies)
Discussion started by: cokedude
0 Replies

6. Shell Programming and Scripting

Dealing with multiple files

Korn Shell I have hundreds of small files like below created every day. A midnight cron job moves them to the location /u04/temp/logs But sometimes I have to manually move these files based a certain dates or time. I have two basic requirements 1.Using mv command I want to move all .dat... (2 Replies)
Discussion started by: kraljic
2 Replies

7. Shell Programming and Scripting

dealing with dates in a text file

hi guys im trying to write a bash script that grabs expired domain names it leaves me with the following outpiut in a text file Im hoping to try to normalise all the dates to the format displayed in the first 2 lines and remove the times so the file looks unfirom can any one give me a... (9 Replies)
Discussion started by: dunryc
9 Replies

8. Shell Programming and Scripting

Converting huge xls(having multiple tabs) to csv

hello I have browsed for the similar requirement i found this https://www.unix.com/shell-programming-scripting/40163-xls-csv-conversion.html but my problem is i have multiple tabs in xls file having same metadata I want to convert it into single csv file any ways to do it pls... (5 Replies)
Discussion started by: joshiamit
5 Replies

9. 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

10. Shell Programming and Scripting

How to delete multiple space or tabs from a read only file

Hi, Actually I am want to cut the three fields of "file-nr" file. $ cat /proc/sys/fs/file-nr 638 219 52270 I want to assign these value to diffrent varibales as follow:- a=638 b=219 c=52270 I tried to use cut command for this purpose and also tried to squeeze all sapces... (6 Replies)
Discussion started by: bisla.yogender
6 Replies
Login or Register to Ask a Question