替换智能图中的文本

可能的使用场景

智能艺术是工作簿中的一个重要对象。许多时候需要更新智能艺术中的文本。Aspose.Cells通过设置Shape.Text属性来提供此功能。

可以从以下链接下载示例源文件:

SmartArt.xlsx

示例代码

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
Workbook wb = new Workbook(sourceDir + "SmartArt.xlsx");
foreach (Worksheet worksheet in wb.Worksheets)
{
foreach (Shape shape in worksheet.Shapes)
{
shape.AlternativeText = "ReplacedAlternativeText"; // This works fine just as the normal Shape objects do.
if (shape.IsSmartArt)
{
foreach (Shape smartart in shape.GetResultOfSmartArt().GetGroupedShapes())
{
smartart.Text = "ReplacedText"; // This doesn't update the text in Workbook which I save to the another file.
}
}
}
}
Aspose.Cells.OoxmlSaveOptions options = new Aspose.Cells.OoxmlSaveOptions();
options.UpdateSmartArt = true;
wb.Save(outputDir + "outputSmartArt.xlsx", options);