Your First Aspose.Diagram Application - Hello World
Creating the Hello World Application
To create the Hello World application using Aspose.Diagram API:
- Créez une instance de la classe Workbook.
- Appliquer la licence :
- Si vous avez acheté une licence, utilisez la licence dans votre application pour accéder à toutes les fonctionnalités de Aspose.Diagram.
- Si vous utilisez la version d’évaluation du composant (si vous utilisez Aspose.Diagram sans licence), ignorez cette étape.
- Créez un nouveau fichier Microsoft Visio ou ouvrez un fichier existant dans lequel vous souhaitez ajouter/mettre à jour du texte.
- Insérez les motsHello World! dans la page consultée.
- Générez le fichier Microsoft Visio modifié.
Les exemples ci-dessous illustrent les étapes ci-dessus.
Création d’un Diagram
The following example creates a new diagram from scratch, writes the words “Hello World!” on the first page, and saves the file.
Créer un nouveau fichier visio
import aspose.diagram | |
from aspose.diagram import * | |
#// Initialize a Diagram class | |
diagram = Diagram() | |
#// Save diagram in the VSDX format | |
diagram.save("CreateNewVisio_out.vsdx", SaveFileFormat.VSDX) |
Ouvrir un fichier existant
The following example opens an existing Microsoft Visio template file, writes the words “Hello World!” in the first page, and saves the diagram as a new file.
import aspose.diagram | |
from aspose.diagram import * | |
diagram = Diagram(os.path.join(sourceDir, "Basic Shapes.vss")) | |
#// Add a new hello world rectangle shape | |
shapeId = diagram.add_shape(4.25, 5.5, 2, 1, "Rectangle", 0) | |
shape = diagram.pages[0].shapes.get_shape(shapeId) | |
shape.text.value.add(Txt("Hello World")) | |
#// Save diagram in the VSDX format | |
diagram.save("CreateHelloWorldVisio_out.vsdx", SaveFileFormat.VSDX) |