LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 11-03-2007, 09:51 PM   #1
kshkid
Member
 
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383

Rep: Reputation: 30
Excel Module - perl scripting - specifying encoding format


Hi All,

Am writing a small tool to populate delimited records into an excel sheet
using the module Spreadsheet::WriteExcel.

I want to specify the encoding format of the input file, I don't see a way to do that currently.

Something like,

open an excel sheet
open a CSV file
while importing specify the encoding format ( utf-8 or other formats )

Is there a way to do that ?
Am trying to automate a couple of conversion work.


Your help is much appreciated.
 
Old 11-05-2007, 08:39 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,136

Rep: Reputation: 230Reputation: 230Reputation: 230
Hi

If you install libspreadsheet-writeexcel-perl on a Debian/Ubuntu system, you get a lot of examples in /usr/share/doc/libspreadsheet-writeexcel-perl/examples/

One of those is called unicode.pl

Code:
#!/usr/bin/perl -w

##############################################################################
#
# A simple example of writing some Unicode text with Spreadsheet::WriteExcel.
#
# This example shows UTF16 encoding. With perl 5.8 it is also possible to use
# utf8 without modification.
#
# reverse(''), May 2004, John McNamara, jmcnamara@cpan.org
#


use strict;
use Spreadsheet::WriteExcel;


my $workbook  = Spreadsheet::WriteExcel->new('unicode.xls');
my $worksheet = $workbook->add_worksheet();


# Write the Unicode smiley face (with increased font for legibility)
my $smiley    = pack "n", 0x263a;
my $big_font  = $workbook->add_format(size => 40);

$worksheet->write_unicode('A3', $smiley, $big_font);


# Write a phrase in Cyrillic
my $uni_str = pack "H*", "042d0442043e002004440440043004370430002004".
                         "3d043000200440044304410441043a043e043c0021";

$worksheet->write_unicode('A5', $uni_str);


$worksheet->write_unicode('A7', pack "H*", "0074006500730074");
 
Old 11-06-2007, 10:52 PM   #3
kshkid
Member
 
Registered: Dec 2005
Distribution: RHEL3, FC3
Posts: 383

Original Poster
Rep: Reputation: 30
many thanks for the reply

I will try it out and update how it goes !

Thanks once again
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
error: -1 Invalid module format when using insmod with module cross-compiled for arm AndrewShanks Linux - Embedded & Single-board computer 4 10-15-2007 03:50 AM
module.ko: make, install & used many times. Suddenly modprobe=invalid module format?? GrapefruiTgirl Linux - General 16 08-04-2007 05:40 AM
Encoding videos to ipod format hackarre Debian 3 05-16-2007 11:58 AM
insmod: error inserting 'module.o': -1 Invalid module format ksrinivas Linux - Newbie 5 10-11-2006 07:29 AM
'Invalid module format' loading simple module on Suse Linux Professional 9.1 rocketdude Linux - Distributions 3 07-27-2004 11:40 PM


All times are GMT -5. The time now is 09:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration