Get MS Equation Object as Image (.NET)

Hi

Is it possible to get an embedded MS Equation 3.0 object as rendered image in Aspose.Cells? In this case Aspose.Cells is just used on server side to get the object from an already existing Excel document and use it somewhere else.

Thanks,

Roger

Hi Roger,

Could you post your template file containing MS Equation 3.0 object, we will check it soon.

Thank you.

Hi Amjad

The document is attached.

Thanks for your support,

Roger

Hi Roger,

Thanks for the template file.

We will check if we can support it.

Thank you.

Hi Roger,

Yes, you may extract image of the MS Equation embedded object, May the following sample code help you for your required, I used you template file to extract the image for the MS Equation object.

Sample code:

Workbook workbook = new Workbook();
workbook.Open(@"F:\test\Formula.xls");
OleObjects oles = workbook.Worksheets[0].OleObjects;

for (int i = 0; i < oles.Count; i++)
{
OleObject ole = oles[i];
if (ole.FileType == OleFileType.Xls)
{
//your code
}
else if (ole.FileType == OleFileType.Doc)
{
//your code
}
else if (ole.FileType == OleFileType.Ppt)
{
//you code
}

//..............

else
{
FileStream fs = File.Create(@"F:\test\myequ" + i + ".jpg");
fs.Write(ole.ImageData, 0, ole.ImageData.Length);
fs.Close();
}
}

Thank you.

Hi Roger,

You may try the attached version as we have added a new enumeration member i.e.., OleFileType.MSEquation for MS Equation embedded object.

Sample code:

Workbook workbook = new Workbook();
workbook.Open(@"F:\test\Formula.xls");
OleObjects oles = workbook.Worksheets[0].OleObjects;

for (int i = 0; i < oles.Count; i++)
{
OleObject ole = oles[i];
if (ole.FileType == OleFileType.MSEquation)
{
FileStream fs = File.Create(@"F:\test\myequa" + i + ".jpg");
fs.Write(ole.ImageData, 0, ole.ImageData.Length);
fs.Close();
}
}

Thank you.

Thank you very much Amjad! I implemented your suggestion today and it works alright. The image gets inserted into an Aspose.Words document.

And it will be even better with the new enumeration!

Have a nice day,

Roger