Skip to main content

SetSpacing

Sets the text spacing measured in twentieths of a point.

Syntax

expression.SetSpacing(nSpacing);

expression - A variable that represents a ApiRun class.

Parameters

NameRequired/OptionalData typeDefaultDescription
nSpacingRequiredtwipsThe value of the text spacing measured in twentieths of a point (1/1440 of an inch).

Returns

ApiTextPr

Example

Control the amount of space between characters in a text run in a spreadsheet.

// How do I widen or tighten the gaps between letters in a spreadsheet?

// Stretch or compress letter spacing to fine-tune the appearance of a word or phrase in a spreadsheet.

let worksheet = Api.GetActiveSheet();
let fill = Api.CreateSolidFill(Api.RGB(255, 111, 61));
let stroke = Api.CreateStroke(0, Api.CreateNoFill());
let shape = worksheet.AddShape("flowChartOnlineStorage", 120 * 36000, 70 * 36000, fill, stroke, 0, 2 * 36000, 0, 3 * 36000);
let content = shape.GetContent();
let paragraph = content.GetElement(0);
let run = Api.CreateRun();
run.AddText("This is just a sample text. ");
paragraph.AddElement(run);
run = Api.CreateRun();
run.SetSpacing(80);
run.AddText("This is a text run with the text spacing set to 4 points (20 twentieths of a point).");
paragraph.AddElement(run);