Замена текста в умном изображении
Contents
[
Hide
]
Возможные сценарии использования
Smart Art - один из основных объектов в книге. Многократно возникает необходимость обновления текста в умном изображении. 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-Java | |
Workbook wb = new Workbook(srcDir + "SmartArt.xlsx"); | |
for (Object obj : wb.getWorksheets()) | |
{ | |
Worksheet worksheet = (Worksheet)obj; | |
for (Object shp : worksheet.getShapes()) | |
{ | |
Shape shape = (Shape)shp; | |
shape.setAlternativeText("ReplacedAlternativeText"); // This works fine just as the normal Shape objects do. | |
if (shape.isSmartArt()) | |
{ | |
for (Shape smartart : shape.getResultOfSmartArt().getGroupedShapes()) | |
{ | |
smartart.setText("ReplacedText"); // This doesn't update the text in Workbook which I save to the another file. | |
} | |
} | |
} | |
} | |
com.aspose.cells.OoxmlSaveOptions options = new com.aspose.cells.OoxmlSaveOptions(); | |
options.setUpdateSmartArt(true); | |
wb.save(outDir + "outputSmartArt.xlsx", options); |