Skip to content

Instantly share code, notes, and snippets.

@aspose-com-kb
Last active November 24, 2023 15:34
Wrap Text in Excel using Node.js. For more details: https://kb.aspose.com/cells/nodejs/wrap-text-in-excel-using-nodejs/
var aspose = aspose || {};
aspose.cells = require("aspose.cells");
const fs = require('fs');
//Set the license
new aspose.cells.License().setLicense("License.lic");
// Create a workbook and access a sheet to fill sample text
var wb = aspose.cells.Workbook();
var ws = wb.getWorksheets().get(0);
var c11 = ws.getCells().get("C11");
c11.putValue("We will not wrap this text");
var c15 = ws.getCells().get("C15");
c15.putValue("We will wrap this text");
// Wrap text using Style object
var style = c15.getStyle();
style.setTextWrapped(true);
c15.setStyle(style);
// Call the autoFitRows() method
ws.autoFitRows();
// Save the result
wb.save("output.xlsx", aspose.cells.SaveFormat.XLSX);
console.log('Text wrapped successfully');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment