• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

POI: Read and format like Excel

 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I finally found an excuse to use POI / HSSF to read Excel. One goal is to read Excel and display the data with the similar formatting - text format only, don't care about colors, fonts, borders, etc. I'm good so far with strings and numbers but I'm having a time with date. For the predefined "m/d/yy" format in Excel ...

cell.getCellStyle().getDataFormat()

gives me decimal 166, 167 etc which are not in the documented list of formats. The format string is

[$-409]m/d/yy\ h:mm\ AM/PM;@

I played around with sanitizing this into something SimpleDateFormat could consume, but came here when I realized Excel put lower case "m" in both date and time.

Has anybody here already solved this problem?
 
I've never won anything before. Not even a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic