You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Javen O'Neal <ja...@gmail.com> on 2015/11/13 06:23:20 UTC
Data format
In one POI project I'm working on, I am writing a date to a cell.
I'm using
CellStyle datetStyle = workbook.createCellStyle();
dateStyle.setDataFormat(22);
Is there a POI constant that I can use instead of the number 22?
Thanks
Javen
Re: Data format
Posted by Javen O'Neal <ja...@gmail.com>.
Thanks. This is what I was looking for. I stumbled across it a few times
but didn't remember the name when I needed it.
I'm a huge fan of ISO 8601 [1] as it makes the locale problem go away. This
would be a good format for Microsoft to adopt as a built-in.
[1] https://xkcd.com/1179/
On 13 Nov 2015 2:49 a.m., "Nick Burch" <ap...@gagravarr.org> wrote:
> On Thu, 12 Nov 2015, Javen O'Neal wrote:
>
>> In one POI project I'm working on, I am writing a date to a cell.
>> I'm using
>> CellStyle datetStyle = workbook.createCellStyle();
>> dateStyle.setDataFormat(22);
>>
>> Is there a POI constant that I can use instead of the number 22?
>>
>
> org.apache.poi.ss.usermodel.BuiltinFormats ?
>
> Though it might want extending to expose some of the more common ones in a
> more helpful constant-like way... Several of those get "localised" too,
> showing up as different things depending on the locale of the Excel program
> opening it. eg Format 0xe is defined as m/d/yy, but opening it up on in a
> UK-English Excel shows as dd/mm/yyyy
>
> Maybe we could combine providing more helpful constants with also
> capturing the locale-specific localised versions too? (IIRC it's only these
> built-in formats that get magically localised like that)
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>
Re: Data format
Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 12 Nov 2015, Javen O'Neal wrote:
> In one POI project I'm working on, I am writing a date to a cell.
> I'm using
> CellStyle datetStyle = workbook.createCellStyle();
> dateStyle.setDataFormat(22);
>
> Is there a POI constant that I can use instead of the number 22?
org.apache.poi.ss.usermodel.BuiltinFormats ?
Though it might want extending to expose some of the more common ones in a
more helpful constant-like way... Several of those get "localised" too,
showing up as different things depending on the locale of the Excel
program opening it. eg Format 0xe is defined as m/d/yy, but opening it up
on in a UK-English Excel shows as dd/mm/yyyy
Maybe we could combine providing more helpful constants with also
capturing the locale-specific localised versions too? (IIRC it's only
these built-in formats that get magically localised like that)
Nick
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org