Search code examples
javaexcelapache-poiexport-to-excel

How to add shape and text beside each other in excel cell


I have to generate excel in java. For some of the columns, I have to add a small coloured circle 🔵 at top left side and some text just beside the circle in the same cell. The shape is coming at top left corner but the text is at the bottom left corner. The text is dynamic so if it is a large text it comes below the circle but if it just one word the it is coming at the bottom. Expectation is: 🔴 Some text.... Current state: 🔴

Some text...

Is there a way to add text beside the circle or the text start just below the circle without any gaps irrespective of text length?


Solution

  • Instead of image, you can go with unicode characters, that will solve your problem.

    String text = "🔴" + " Some Text...";