Yash Yelmame
Yash Yelmame

Reputation: 89

How to change the column width of a Individual column in excel in excel through Apache-POI

I want to change the column width of a column I have seen many answers suggesting the use of "AutoSizeColumn(int)" but the problem with that is that all columns have different sizes and it creates kind of a mess so i want to set all columns ( except one ) to one single width how do i do this??

Upvotes: 2

Views: 162

Answers (1)

rgettman
rgettman

Reputation: 178313

You can set a default column width that controls all columns in the sheet that don't have their own custom width set. Use the setDefaultColumnWidth method.

Set the default column width for the sheet (if the columns do not define their own width) in characters

sheet.setDefaultColumnWidth(numChars);

Individual columns can override this default with the setColumnWidth method. The width here is in 1/256ths of a character, different from the default width units.

Set the width (in units of 1/256th of a character width)

Upvotes: 4

Related Questions