You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by sps <cy...@gmail.com> on 2008/08/25 11:08:17 UTC

How to set the Date in excel through Java?

now i am using

cell.setCellValue(date);
date is in format of "dd/MM/yyyy"

But when it set on excel , it sets as number.
I need the date as in same format as what i given.

Assist me. 
-- 
View this message in context: http://www.nabble.com/How-to-set-the-Date-in-excel-through-Java--tp19140264p19140264.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to set the Date in excel through Java?

Posted by Princess <he...@yahoo.com>.
HSSFDataFormat dataFormat = wb.createDataFormat();

On Mon, Aug 25, 2008 at 12:53 PM, sps <cy...@gmail.com> wrote:

>
> may i know the class of "dataFormat" object
>
>
>
> sps wrote:
> >
> > now i am using
> >
> > cell.setCellValue(date);
> > date is in format of "dd/MM/yyyy"
> >
> > But when it set on excel , it sets as number.
> > I need the date as in same format as what i given.
> >
> > Assist me.
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-set-the-Date-in-excel-through-Java--tp19140264p19141598.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>


-- 
**Hope can be ignited by a spark of encouragement *****

Re: How to set the Date in excel through Java?

Posted by sps <cy...@gmail.com>.
may i know the class of "dataFormat" object



sps wrote:
> 
> now i am using
> 
> cell.setCellValue(date);
> date is in format of "dd/MM/yyyy"
> 
> But when it set on excel , it sets as number.
> I need the date as in same format as what i given.
> 
> Assist me. 
> 

-- 
View this message in context: http://www.nabble.com/How-to-set-the-Date-in-excel-through-Java--tp19140264p19141598.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: How to set the Date in excel through Java?

Posted by Princess <he...@yahoo.com>.
try this
HSSFCellStyle styleData = wb.createCellStyle();
styleData.setDataFormat(dataFormat.getFormat("dd.MM.yy"));
cell.setCellValue(date);
cell.setCellStyle(styleData);

On Mon, Aug 25, 2008 at 11:08 AM, sps <cy...@gmail.com> wrote:

>
> now i am using
>
> cell.setCellValue(date);
> date is in format of "dd/MM/yyyy"
>
> But when it set on excel , it sets as number.
> I need the date as in same format as what i given.
>
> Assist me.
> --
> View this message in context:
> http://www.nabble.com/How-to-set-the-Date-in-excel-through-Java--tp19140264p19140264.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>


-- 
**Hope can be ignited by a spark of encouragement *****