This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Other JSE/JEE APIs and the fly likes Populate a date field in excel as dateformat instead of string using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Populate a date field in excel as dateformat instead of string using Java" Watch "Populate a date field in excel as dateformat instead of string using Java" New topic
Author

Populate a date field in excel as dateformat instead of string using Java

Saravana Kumar Arumugam
Greenhorn

Joined: Mar 29, 2007
Posts: 1
I need to populate a date field in excel as date format instead of string using Java. I tried using POI API & HSSF date style, but the date is getting populated as general format only. Please help me out to populate the data as a date field as I�m using the value to manipulate many other fields in the sheet to generate charts in Excel.



Thanks and Regards,

Saravana
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41089
    
  44
Welcome to JavaRanch.

Isn't that what HSSFDataFormat with a date format (like Oxe to Ox16) is supposed to do?


Ping & DNS - my free Android networking tools app
Anjana Ravindran
Ranch Hand

Joined: Aug 22, 2005
Posts: 76
Hi,
I am also trying to help him in solving the issue.

It is the code he tried...
To create a new style for date


HSSFCellStyle dateStyle = null;

dateStyle = workbook.createCellStyle();

dateStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("mm/dd/yy"));


and then for populating �Created Date� cell I used the below code,


cell = row.createCell((short) 3);
cell.setCellValue(new Date());
cell.setCellStyle(dateStyle);
 
 
subject: Populate a date field in excel as dateformat instead of string using Java
 
Similar Threads
How can we know the date format when we get the data from EXCEL using JXL package
Read Excel values and store in to Database
. reading data from MS EXcel using apache poi api
how to make different date format validation ?
servlets and sql