How to export charts in worksheet to VML/OpenXml in a Html file?

We want to export excel active worksheet that contains a few charts into Html file, but one requirement we want is the charts need to be converted to images in the form of VML Shape,

<v:shape id="Chart_x0020_2" o:spid="_x0000_s1026" type="#_x0000_t75" style='position:absolute;
   visibility:visible' o:gfxdata="UEsDBBQABgAIAAAAIQD1avy5IAEAAF4CAAATAAAAW0NvbnRlbnRfVHlwZXNdLnhtbIySy07DMBBF
   <v:imagedata src="cid:image003.png@01D2E9D7.6831CBA0" o:title="" />
   <o:lock v:ext="edit" aspectratio="f" />
   <x:ClientData ObjectType="Pict">

instead of

<img src="..." >

How can I achieve this by using Aspose products?


Thanks for your posting and using Aspose.Cells.

Please use SVG instead of VML. SVG is more robust and it is also in XML format.

Please see the following sample code, its SVG image and its output Excel file for your reference. All files are attached in the form of zip file.

Please also see this documentation article for more help.

Converting Chart to Image in SVG Format|Documentation


// Create workbook object from source file
Workbook workbook = new Workbook("sampleExcel.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.SaveFormat = SaveFormat.SVG;

// Save the chart to svg format
chart.ToImage("Image_out.svg", opts); (11.9 KB)

Thanks for the prompt reply.

Actually the reason we want the VML is because we want to embed the pictures in outlook email. Simply export the worksheet to html and set the MailMessage.HtmlBody has layout issues as outlook doesn’t support the css “positon”, our purpose is not to export the charts but to turn the whole worksheet including tables, charts, into Email body in Html.

As far as I know, storing the images in VML format inside html can solve the layout issue. That’s why I want to convert the charts into VML.


Thanks for considering Aspose.Cells.

Your issue seems to be more related to Aspose.Email because Aspose.Email converts the HTML to Email format or Outlook format. Please post your issue in Aspose.Email Forum for more clarifications.

Aspose.Cells only converts the Excel to HTML. It is a generic thing while your requirement is specific to you. Mostly, we add new features when they are not difficult to add or if they are complex and many users want this.

Also, what I understood, you don’t need VML format, you only want the solution of your problem or any workaround that could solve your issue.

Regarding VML format, I researched it and found it is already outdated.

You can consider these options with Aspose.Cells.

  1. Convert your Excel file into Pdf and send it as attachment to your clients.
  2. Convert your Entire worksheet into Image(s) and create HTML which will only have images and send it to your client as an embedded HTML (containing images)
  3. Convert each of your worksheet into a separate HTML (i.e. HtmlSaveOptions.ExportActiveWorksheetOnly) and then work with them or combine them as per your needs. You will also have the option to embed images inline using HtmlSaveOptions.ExportImagesAsBase64 property.

Right, that’s what I’m thinking, to render the entire worksheet to images and put it in html.

Put excel, pdf or individual html file as attachment in email is not what we need.

Thanks a lot for the help, I think all these are helpful for me knowing better on Aspose. I think 2nd approach is our only choice for now and meanwhile I probably can raise a request to export charts as VML/OpenXML and see if it is easy for you, hopefully it is :slight_smile:

Appreciate your help again!

BTW, I think it’s more related to Aspose.Cells instead of Aspose.Email because:

  1. The problem that I have was caused by the Outlook does (actually many other email clients do) not support some css, like “position”, which makes the layout in outlook really bad.

  2. For Microsoft, their solution in Excel (and word, …) is to export the chart in both VML/OpenXml and Html img element and let the client (email client, browser) decides which one to use by checking if it supports vml.

So it’s more like add a VML format to the Aspose.Cells.Rendering.ImageOrPrintOptions.


Thanks for using Aspose.Cells.

We have logged your requirement for further evaluation in our database. Once, there is some news for you, we will update you asap.

This issue has been logged as

CELLSNET-45455 - CSS Position Property and Support for VML format to the ImageOrPrintOptions or HtmlSaveOptions

Regarding this problem, I find out a walkaround.
All I need is to have the pictures/charts cover across the columns/rows, as some css doesn’t work in outlook, I can achieve that by merge the cells and that works.

But there seems to be another issue when saving the Excel to Html into a stream of file, a null reference exception thrown out. I post it here Save Excel as Html throws null reference exception after cells merged

There occurrs in some workbooks, others don’t, but am not sure what the exactly the problem is.


Thanks for using Aspose APIs.

Please follow your other thread for the reply. Thank you.

Post Reference:


We are afraid, we will not work on this issue (i.e. CELLSNET-45455) because of its complexity and because you have also found the workaround for your problem. Thanks for your understanding and have a good day.

Okay, should be fine, merging cells before converting the excel to html would be our way to go.
But… I hope CELLSNET-45486 is still in your plan (although we have a workaround for this issue)

Anyway, appreciate very much for your time looking into these issues…


Thanks for your understanding. Your other issue (i.e. CELLSNET-45486) is still Open. Once, there is some update or any fix for you, we will let you know in your other thread.