Apache POI for Excel: Setting the cell type to “text” for an entire column

后端 未结 4 1639
无人共我
无人共我 2021-02-20 17:37

I need to generate an .xls (Excel) file, using the Java library Apache POI for spreadsheets.

The file will contain a list of phone numbers in column A, formatted as \"02

4条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-20 18:01

    Will this help?

    By creating a data format with the @ symbol and using that in a CellStyle object that is then passed to the setDefaultColumnStyle() method, it was possible to set the default data type of the column to, in this case, text. I have not experiemented further but do suspect it would be possible to do something similar with other style objects to set the default type to numeric or even a customised format such as currency.

提交回复
热议问题