Hi Michael,
Thank you for contacting Syncfusion support.
We do not have support for OnExportComplete event in the Circular Gauge. But we support returning base64 string of the exported image when the Export() method is called. The Export() method has the following parameters to pass.
1. Type of the extension for export such as PNG, JPEG, SVG and PDF. For image export, we need to enable the AllowImageExport property by setting the value as "true" in the SfCircularGauge class.
2. The name of the exported file. Since you need to get the file as base64 string, this parameter can be empty.
3. The orientation of the PDF file, if we need to export to PDF file. This parameter can be “null” for your requirement.
4. A Boolean value “allowDownload” must be passed. If the value is true, the exported file will be downloaded. If the value is false, the exported file will be returned as base64 string.
Once the exported image file is returned as base64 string, we can convert it into byte array. This byte array can be converted into stream. The stream of the image can be used to add in the Excel file. Please find the code snippet for the getting the base64 string of the exported image file of Circular Gauge below.
Code Snippet:
|
string exportString = await gauge.Export(ExportType.JPEG, string.Empty, null, false);
exportString = exportString.Split("data:image/jpeg;base64,")[1];
byte[] byteArray = Convert.FromBase64String(exportString);
using (MemoryStream memoryStream = new MemoryStream(byteArray))
{
// Excel conversion code.
} |
We can add the image to the Excel document using our Syncfusion XlsIO library. Please find the documentation link to add the images in the Excel document for your reference below.
We have created a sample application to demonstrate the same and it can be downloaded from the below link.
In the above sample application, the Circular Gauge is export as image and saved to the Excel document. The Excel document will be available in the “wwwroot” folder of the application.
Please let us know if the above sample meets your requirement.
Regards,
Sabari Anand