Without using Apache POI (for example, you generate the xml manually to create the spreadsheet) you can set a css class with
mso-number-format: "General Date"
or
mso-number-format: "Short Date"
Using Apache POI this doesn't seem possible, you are locked into using a single defined date format which is always reliant on the locale of the physical server or some value you hardcode, not on the clients OS locale settings like above.
Here is my code now, users hitting a server in America but live in another country want to see dates in their locale so this is not good
protected CellStyle getDateCellStyle(SXSSFWorkbook wb)
{
CellStyle style = wb.createCellStyle();
style .setDataFormat(wb.getCreationHelper().createDataFormat().getFormat("MM/dd/yyyy"));
return style;
}
Essentially I would like to replace "MM/dd/yyyy" with "Short Date" or "General Date" but these options do not work. Anyone have any ideas? I can't just get the locale based on where the server sits because another country could be hitting it (so I can't get the locale in the Java src as other answers suggested).
Anyone dealt with this before?