Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hi, I have one doubt. How can I convert a file in unix to MS excel format.
Suppose if I have a file named 'Studata' and it contains like:
/root # cat Studata
Roll no. Name Age Sex
1 ABC 12 M
2 DEF 13 M
3 XYZ 12 F
I want this table to be converted to .xls format and to be saved on my local server. I have perl script but I dont know perl so I want the code in shell scripting.
Is it possible? If yes, can anybody please help me out as how can this be achieved.
Thanks in advance.
Spreadsheets can be saved as xml in both MS Excel and in OpenOffice Calc. If you store the following with a .xml extension, and open it with Excel or OpenOffice, then you get it opening as a spreadsheet with the worksheet name set to Student Data. After opening it in Excel or OpenOffice, you can 'save as' in spreadsheet format.
another way, if you have Perl and can install the Spreadsheet::WriteExcel module
Code:
#!/usr/bin/perl
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new("test.xls");
my $worksheet = $workbook->add_worksheet();
open(FH,"<file") or die "Cannot open file: $!\n";
my ($x,$y) = (0,0);
while (<FH>){
chomp;
@list = split /\s+/,$_;
foreach my $c (@list){
$worksheet->write($x, $y++, $c);
}
$x++;$y=0;
}
close(FH);
$workbook->close();
Last edited by ghostdog74; 04-14-2009 at 10:19 AM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.