Home > OS >  How to write dates in Apache POI which would be filtered properly
How to write dates in Apache POI which would be filtered properly

Time:11-27

I have a block of code which write data to .xlsx file. I need to write some date in "dd.MM.yy HH:MM" format. All is work properly, but when I try to open result file and test filter work, I got issue with that. Filter perceives dates just like strings, instead of dates, and I can't get filter with year and month.

Filter which I want (in Russian btw, sorry) enter image description here

CodePudding user response:

Looks like you didn't apply the style..?

if (cellValue instanceof Date) {
    cell.setCellValue((Date)cellValue);
    cell.setCellStyle(dateCellStyle);
}
  • Related