Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Date column in excel

by hakkr (Chaplain)
on Jun 08, 2004 at 11:39 UTC ( [id://362285]=note: print w/replies, xml ) Need Help??


in reply to Date column in excel

It depends what module you are using to write the excel file with. For the excellent Spreadsheet::WriteExcel module you would say
$format->set_num_format('mmm d yyyy hh:mm AM/PM'); $worksheet->write( $date , $format);

Replies are listed 'Best First'.
Re^2: Date column in excel
by Anonymous Monk on Jun 08, 2004 at 12:00 UTC
    I am not using any module as such i am using this code in html
    xmlns:x='urn:schemas-microsoft-com:office:excel' xmlns:ss='urn:schemas-microsoft-com:office:spreadsheet
    and using x:str to convert into string is there anyway without using any module where i could specify a date cell.
    Is there any way where i could do that without changing much of my code.
    Thanks

      If I ever need to figure out how to do this, I start by creating a simple Excel sheet, do "Save as HTML" or whatever, and see how Excel has saved it.

      Just did a quick test and it looks like the HTML format is:

      <td height=17 class=xl24 align=right style='height:12.75pt' x:num="38018">01/02/2004</td>

      So you probably need to convert the date into numeric form (shouldn't be too difficult - but you'll need to check Excel's documentation to find its epoch, as that will most likely not be the same as perl's) for the x:num attribute...

      Update: I should add that if you're doing lots of this and you want it to be robust, you ought to look into a ready-made solution, such as Spreadsheet::WriteExcel. I've only ever needed to do this very occasionally, and so I've never actually looked properly at what modules are available...

      s^^unp(;75N=&9I<V@`ack(u,^;s|\(.+\`|"$`$'\"$&\"\)"|ee;/m.+h/&&print$&;
      well I'd say a date is more a number than a string at least it will be to excel internally

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-16 07:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found