使用Node.js通过C++设置形状或文本框段落的行间距
Contents
[
Hide
]
你可以使用TextParagraph.getLineSpace()、TextParagraph.getSpaceBefore()和TextParagraph.getSpaceAfter()属性设置段落的行间距、前间距和后间距,这些都属于TextParagraph类。
以下示例代码解释了所述属性的用法。
const AsposeCells = require("aspose.cells.node");
const path = require("path");
// The path to the documents directory.
const dataDir = path.join(__dirname, "data");
const filePath = path.join(dataDir, "sample.xlsx");
// Create a workbook
const wb = new AsposeCells.Workbook();
// Access first worksheet
const ws = wb.getWorksheets().get(0);
// Add text box inside the sheet
ws.getShapes().addTextBox(2, 0, 2, 0, 100, 200);
// Access first shape which is a text box and set its text
const shape = ws.getShapes().get(0);
shape.setText("Sign up for your free phone number.\nCall and text online for free.");
// Access the first paragraph
const p = shape.getTextBody().getTextParagraphs().get(1);
// Set the line space
p.setLineSpaceSizeType(AsposeCells.LineSpaceSizeType.Points);
p.setLineSpace(20);
// Set the space after
p.setSpaceAfterSizeType(AsposeCells.LineSpaceSizeType.Points);
p.setSpaceAfter(10);
// Set the space before
p.setSpaceBeforeSizeType(AsposeCells.LineSpaceSizeType.Points);
p.setSpaceBefore(10);
// Save the workbook in xlsx format
wb.save(path.join(dataDir, "output_out.xlsx"), AsposeCells.SaveFormat.Xlsx);