スマートアート内のテキストの置換
Contents
[
Hide
]
可能な使用シナリオ
スマートアートはブック内の主要なオブジェクトの1つです。スマートアート内のテキストを更新する必要がある場合があります。Aspose.Cellsは、Shape.Textプロパティを設定することでこの機能を提供します。
次のリンクからサンプルソースファイルをダウンロードできます:
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); |