AutoFit Row Height Automatically When Loading a File with Node.js via C++

Possible Usage Scenarios

The height of a row automatically matches the font of its content, but when the cached row height does not match the height of the content in the file, MS Excel will automatically adjust the row height when loading the file, whereas Aspose.Cells for Node.js via C++ will not adjust it automatically in order to improve performance. If you need Aspose.Cells to automatically match row heights when loading files, you can achieve this through the parameter setAutoFitterOptions(AutoFitterOptions) in your code.

Please refer to the following image. We can observe that the cached row height in line 11 is 15, but Excel automatically adjusted the row height when loading the file.

Adjust Row Height Using Aspose.Cells for Node.js via C++

If you load the file directly and save it to PDF, the data will not be fully displayed because the cached row height is only 15.


If you set the parameter setAutoFitterOptions(AutoFitterOptions) to true when loading the file, Aspose.Cells will automatically adjust the row height. The adjusted row height can effectively meet the text‑display requirements.

Node.js Sample Code

const path = require("path");
const AsposeCells = require("aspose.cells.node");

// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");

// Loads the workbook which contains hidden external links
const workbook = new AsposeCells.Workbook(filePath);
workbook.save(path.join(dataDir, "out.pdf"));

const loadOptions = new AsposeCells.LoadOptions();
loadOptions.setAutoFitterOptions(new AsposeCells.AutoFitterOptions());
loadOptions.getAutoFitterOptions().setOnlyAuto(true);
const book = new AsposeCells.Workbook(filePath, loadOptions);
book.save(path.join(dataDir, "out2.pdf"));