Retrieve formula of embed object (picture) in an Excel worksheet

Hi everyone,

I am reading an Excel worksheet which contains a picture. The difference between this picture and other pictures is that by clicking on this picture I see =EMBED("Visio.Drawing.11","") in Formula bar as following screenshot:

Image_9367_1712301264910


Image_8425_1712301489739

My questions are:

Question 1: How can I get the value in Formula bar when reading this picture?

Question 2: If I call image.Save($@"[LOCAL_DIRECTORY]\test.{image.RawFormat}");​ inside above using block, then opening the extracted image in windows, the image seems to be blur/broken. How can I extract this image with good quality as it is displayed in Excel (like above screenshot):

Image_9812_1712302627783


Any suggestions?

Many thanks,


2 Replies

MM Mugil Murugan Syncfusion Team April 9, 2024 10:59 AM UTC

Hi,

Question 1: How can I get the value in Formula bar when reading this picture?

 

It is not possible to retrieve the formula bar properties as MS Excel automatically detects the OLE object type and shows it in formula bar. XlsIO does not have support for this and we suggest using name property.

Question 2: If I call image.Save($@"[LOCAL_DIRECTORY]\test.{image.RawFormat}");​ inside above using block, then opening the extracted image in windows, the image seems to be blur/broken. How can I extract this image with good quality as it is displayed in Excel.

Please use the below-mentioned code snippet.


Code Snippet:

using (ExcelEngine excelEngine = new ExcelEngine())

{

    IApplication application = excelEngine.Excel;

    application.DefaultVersion = ExcelVersion.Xlsx;

    IWorkbook workbook = application.Workbooks.Open("../../Data/OLE.xlsx");

 

    IWorksheet sheet = workbook.Worksheets[0];

 

    foreach (IOleObject oleObject in sheet.OleObjects)

    {

        //Get the image from the OLE object

        String name = oleObject.Shape.Name;

        Image image = oleObject.Picture;

        image.Save("../../Data/" + name + ".png");

    }

}


Regards,
Mugil M.



Ð? Ð?ng replied to Mugil Murugan April 17, 2024 02:03 AM UTC

Hi Mugil Murugan,


Thank you so much for your support. ;)


Loader.
Up arrow icon