I have a java program which takes header and data as the input and produces an excel file.
However, sometimes when the header values are long and the number of columns are more, my excel sheet tends to be unnecessarily wide.
Because of the headers, I will have to scroll down to right to see the content of the tail end columns.
Is there a way I can resolve this such that if the content in the cell is bigger then say value x, then auto wrap occurrs and automatically the row height gets adjusted and the column width gets fixed.
The rough algorithm for what I am looking for is:
if(content.size is more then 50 chars){
- apply auto wrap with centred text
- adjust the row height accordingly
- adjust all the cells in the column accordingly
}
If someone could point me to some example available online.
Thanks for reading!
You should be able to achieve this with a Cell style, I have tried to put together an example to show:
Good Luck!