Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How can I use Spreadsheet::WriteExcel to write a url label without formatting it (turning ints to floats)

by jmcnamara (Monsignor)
on May 25, 2011 at 22:35 UTC ( #906724=note: print w/ replies, xml ) Need Help??


in reply to How can I use Spreadsheet::WriteExcel to write a url label without formatting it (turning ints to floats)

As chilledham points out it is Excel that is converting the number to a floating point format.

The way to avoid this (in Excel and Spreadsheet::WriteExcel) is to specify a cell format to ensure that the number is displayed in the way you want. You will also need to add some link style formatting to ensure it also looks like a link. Here is a working example:

#!/usr/bin/perl use warnings; use strict; use Spreadsheet::WriteExcel; my $workbook = Spreadsheet::WriteExcel->new( 'example.xls' ); my $worksheet = $workbook->add_worksheet(); my $link_format = $workbook->add_format( color => 'blue', underline => 1, num_format => 1, ); $worksheet->set_column( 'B:B', 20 ); $worksheet->write_url( 'A1', 'www.perl.com', 270751343164, $link_forma +t ); $worksheet->write_url( 'B1', 'www.perl.com', 270751343164, $link_forma +t ); __END__

The set_column() method call is there to show how to display the number since it is now larger than the cell.

--
John.


Comment on Re: How can I use Spreadsheet::WriteExcel to write a url label without formatting it (turning ints to floats)
Download Code
Re^2: How can I use Spreadsheet::WriteExcel to write a url label without formatting it (turning ints to floats)
by uG (Scribe) on May 26, 2011 at 02:11 UTC
    Thanks everyone. I've always been able to avoid Excel for a regular ol' CSV, so this was my first experience. I assumed it was WriteExcel because in the docs it mentioned that it will format things how it thinks they should be formatted, in addition to my inexperience with Excel.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://906724]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (9)
As of 2014-10-22 08:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (114 votes), past polls