Conversione del grafico in immagine nel formato SVG

Contents
[ ]

Il codice di esempio seguente spiega come utilizzare Aspose.Cells per convertire un grafico in un’immagine in formato SVG. Il codice carica il file Excel di origine e quindi salva il primo grafico trovato nel primo foglio di lavoro in SVG.

Lo screenshot seguente mostra l’immagine del grafico convertita nel formato SVG creata con il codice di esempio.

Immagine di uscita

cose da fare:immagine_alt_testo

Poiché SVG è un formato basato su XML, puoi anche aprire l’immagine del grafico di output in un editor di testo come Blocco note, come mostrato in questa schermata.

Output SCG in un editor di testo

cose da fare:immagine_alt_testo

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(ConvertCharttoImageinSVGFormat.class);
// Create workbook object from source Excel file
Workbook workbook = new Workbook(dataDir + "sample.xlsx");
// Access the first worksheet
Worksheet worksheet = workbook.getWorksheets().get(0);
// Access the first chart inside the worksheet
Chart chart = worksheet.getCharts().get(0);
// Save the chart into image in SVG format
ImageOrPrintOptions options = new ImageOrPrintOptions();
options.setImageType(ImageType.SVG);
chart.toImage(dataDir + "ChartImage.svg", options);