This example fits the range automatically.
Range range = sheet.range("A1:B2"); range.setText("Hello World"); range.autoFit();
Related information
autoFit method