I am having a string of X Font(like Arial font) having Y height in define value of the width in such a way that string can comes into multiple lines. I need to calculate the required height so that required string can be fit into it. Auto size of row in Apache POI can't be possible as I require height for the rich text string(any font and height) present in merge cell of the row, in this scenario auto size doesn't work.
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
Found a solution using a
JTextPane
to render the text.Sample code is at first the whole text in one font and fontsize. But since
JTextPane
provides aStyledDocument
, rich text content should also be possible to handle. (TODO).The code comments why code parts are needed.
The
JTextPane
content is nearly exact as the content in theExcel
cell. So the height will be mostly accurate.The result of a test using multiple fonts and font sizes is also not so poor.