This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Saravana Kumar Arumugam
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Rancher
Pie
Posts: 42966
73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch.

Isn't that what HSSFDataFormat with a date format (like Oxe to Ox16) is supposed to do?
 
Anjana Ravindran
Ranch Hand
Posts: 76
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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);
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic