Apache POI : How to format numeric cell values

前端 未结 4 590
青春惊慌失措
青春惊慌失措 2020-12-19 21:28

I am using Apache POI 3.9 for XLS/XLSX file processing.

In the XLS sheet, there is a column with numeric value like \"3000053406\".

When I read it with POI w

4条回答
  •  [愿得一人]
    2020-12-19 22:30

    This one comes up very often....

    Picking one of my past answers to an almost identical question

    What you want to do is use the DataFormatter class. You pass this a cell, and it does its best to return you a string containing what Excel would show you for that cell. If you pass it a string cell, you'll get the string back. If you pass it a numeric cell with formatting rules applied, it will format the number based on them and give you the string back.

    For your case, I'd assume that the numeric cells have an integer formatting rule applied to them. If you ask DataFormatter to format those cells, it'll give you back a string with the integer string in it.

提交回复
热议问题