Free Support Forum -

Set Row Height in Pixels with AutoFit option is enabled for worksheet while using Aspose.Cells for Java

Row height in pixel cannot be set if autofitRows is enabled in worksheet.

Code Sample:

package test;

import com.aspose.cells.AutoFitterOptions;
import com.aspose.cells.Cell;
import com.aspose.cells.Cells;
import com.aspose.cells.Workbook;
import com.aspose.cells.Worksheet;

public class TestRowSqueeze{

public static void main(String[] args)
Workbook workbook;
try {
workbook = new Workbook(“C:\Test.xlsx”);
Worksheet worksheet = workbook.getWorksheets().get(1);
Cell cell = worksheet.getCells().get(“C3”);
cell.putValue(“Slide Title”);

Cells cells = worksheet.getCells();

//Setting the Row Height in Pixel
cells.setRowHeightPixel(10, 1);
AutoFitterOptions autoOptions = new AutoFitterOptions();

try {
} catch (Exception e) {


System.out.println(“cell.getValue” + cell.getValue());“C:\Test.xlsx”);
} catch (Exception e2) {




Sure, the setting of row heights would be useless when you perform Auto-fit rows operation. This is expected behavior. When you perform Auto-fit rows operation, then the individual setting of your row height would be ignored, this behavior is same as MS Excel and it should be.

If you have different opinion and MS Excel behaves differently than what Aspose.Cells does regarding Auto-fit rows operation, give us your input file, the output file by Aspose.Cells and your expected file that you may create when performing the Auto-fit operation in MS Excel manually. We will check it soon.

Thank you.