Imposta l’interlinea del paragrafo in una forma o casella di testo con C++
Contents
[
Hide
]
È possibile impostare lo spazio tra le righe del paragrafo, lo spazio prima e lo spazio dopo utilizzando le proprietà TextParagraph.GetLineSpace(), TextParagraph.GetSpaceBefore() e TextParagraph.GetSpaceAfter() della classe TextParagraph.
Il seguente codice di esempio spiega l’uso delle proprietà menzionate.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
using namespace Aspose::Cells::Drawing;
using namespace Aspose::Cells::Drawing::Texts;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Create a workbook
Workbook wb;
// Access first worksheet
Worksheet 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
Shape shape = ws.GetShapes().Get(0);
shape.SetText(u"Sign up for your free phone number.\nCall and text online for free.");
// Access the first paragraph
TextParagraph p = shape.GetTextBody().GetTextParagraphs().Get(1);
// Set the line space
p.SetLineSpaceSizeType(LineSpaceSizeType::Points);
p.SetLineSpace(20);
// Set the space after
p.SetSpaceAfterSizeType(LineSpaceSizeType::Points);
p.SetSpaceAfter(10);
// Set the space before
p.SetSpaceBeforeSizeType(LineSpaceSizeType::Points);
p.SetSpaceBefore(10);
// Save the workbook in xlsx format
wb.Save(outDir + u"output_out.xlsx", SaveFormat::Xlsx);
std::cout << "Workbook saved successfully!" << std::endl;
Aspose::Cells::Cleanup();
}