Conversione del grafico in immagine nel formato SVG
Scalable Vector Graphics (SVG) è un formato di immagine vettoriale basato su XML per la grafica bidimensionale che supporta anche l’interattività e l’animazione. La specifica SVG è uno standard aperto sviluppato dal World Wide Web Consortium (W3C) dal 1999.
SVG immagini e i loro comportamenti sono definiti in file di testo XML. Ciò significa che possono essere cercati, indicizzati, inseriti in script e compressi. Come file XML, le immagini SVG possono essere create e modificate con qualsiasi editor di testo, ma sono più spesso create con software di disegno.
Aspose.Cells può salvare il grafico in immagini in vari formati come BMP, JPEG, PNG, GIF, SVG ecc. Questo articolo spiega come salvare un grafico nel formato SVG.
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 Microsoft di origine e quindi salva il primo grafico trovato nel primo foglio di lavoro in SVG.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Create workbook object from source file | |
Workbook workbook = new Workbook(dataDir + "SampleChartBook.xlsx"); | |
// Access first worksheet | |
Worksheet worksheet = workbook.Worksheets[0]; | |
// Access first chart inside the worksheet | |
Aspose.Cells.Charts.Chart chart = worksheet.Charts[0]; | |
// Set image or print options | |
Aspose.Cells.Rendering.ImageOrPrintOptions opts = new Aspose.Cells.Rendering.ImageOrPrintOptions(); | |
opts.ImageType = ImageType.Svg; | |
// Save the chart to svg format | |
chart.ToImage(dataDir + "Image_out.svg", opts); |