Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Aspose.Cells allows you to customize the text within shapes in Excel files. The Shape class provides methods and properties to manage text options such as alignment, orientation, and formatting.
You can set the horizontal and vertical alignment of text within a shape using the GetTextHorizontalAlignment() and GetTextVerticalAlignment() methods.
#include <Aspose.Cells.h>
using namespace Aspose::Cells;
using namespace Aspose::Cells::Drawing;
void SetTextAlignment() {
// Load the Excel file
Workbook workbook("example.xlsx");
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Access the shape
Shape shape = worksheet.GetShapes().Get(0);
// Set text alignment
shape.SetTextHorizontalAlignment(TextAlignmentType::Center);
shape.SetTextVerticalAlignment(TextAlignmentType::Center);
// Save the workbook
workbook.Save("output.xlsx");
}
You can also set the orientation of the text within a shape using the SetTextOrientationType method with the TextOrientationType enumeration.
#include <Aspose.Cells.h>
using namespace Aspose::Cells;
using namespace Aspose::Cells::Drawing;
void SetTextOrientation() {
Workbook workbook("example.xlsx");
Worksheet worksheet = workbook.GetWorksheets().Get(0);
TextBox textbox = worksheet.GetTextBoxes().Get(0);
textbox.SetTextOrientationType(TextOrientationType::Clockwise);
workbook.Save("output.xlsx");
}
You can format the text within a shape using the Font class. This allows you to set properties such as font size, color, and style.
#include <Aspose.Cells.h>
using namespace Aspose::Cells;
using namespace Aspose::Cells::Drawing;
void FormatText() {
// Load the Excel file
Workbook workbook("example.xlsx");
Worksheet worksheet = workbook.GetWorksheets().Get(0);
// Access the shape
Shape shape = worksheet.GetShapes().Get(0);
// Access the font of the shape's text
Font font = shape.GetTextBody().GetParagraphEnumerator().GetCurrent().GetFont();
// Set font properties
font.SetSize(14);
font.SetColor(Color::Red());
font.SetIsBold(true);
// Save the workbook
workbook.Save("output.xlsx");
}
Aspose.Cells for C++ provides a comprehensive set of tools to manage shape text options in Excel files. By using the Shape class, you can easily customize text alignment, orientation, and formatting to meet your specific requirements.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.