Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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

Replies are listed 'Best First'.
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?
[hippo]: Marketing should not be allowed near such utilities.
[Corion]: I should tell them about the "dim+lock all monitors to show the immediate alert centered" feature of that software so they can announce the next intranet website feature even better ;)
[Eily]: This sounds like the perfect medium to send "don't let anything distract you"
[LanX]: hippo you asked about translating Asterix ?

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (14)
As of 2017-05-24 14:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?