Free Support Forum - aspose.com

How to get Image by namedrange from excel sheet


#1

Hi,
We can get the image from excel sheet by the index like
Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[0];
Could you please let me know how to get the image by it’s named range from excel sheet to user local drive
Thanks


#2

@rasmi.mishra,

Thanks for your query.

Do you need to render your desired range of cells (having data/formatting, etc.) in the sheet to image? If this is the case, kindly see the document for your reference:
https://docs.aspose.com/display/cellsnet/Export+Range+of+Cells+in+a+Worksheet+to+Image

If you need something different, kindly elaborate your requirements and provide some samples (Excel file, screenshots, etc.) to demonstrate your needs, we will check it soon.


#3

Images.zip (83.7 KB)
@Amjad_Sahi
I have an excel file , where one sheet contains multiple images and each image has a unique name . Please refer attached sample file named Images.xlsm , sheet1. open excel file , go to sheet1 and click on first image , you can see image name is ImagePage1 displaying at top left corner of the sheet . By click on 2nd image you can see the image name is Imagepage2.

My requirement is to export those images by name instead of index number .
By referring to index no I can read the image like Aspose.Cells.Drawing.Picture pic = worksheet.Pictures[0] , which I don’t want
Could you please tell me how can I read images referring to it’s name only using Aspose excel in .Net
Thanks


#4

@rasmi.mishra,

Thanks for the template file and details.

Well, you may try to use Picture.Name attribute for your needs, see the sample code for your reference:
e.g
Sample code:

Workbook workbook = new Workbook("e:\\test2\\Images.xlsm"); 

            Worksheet ws = workbook.Worksheets["Sheet1"];
            foreach (Aspose.Cells.Drawing.Picture shape in ws.Pictures)
            {
                MessageBox.Show(shape.GetType().ToString());  
                MessageBox.Show(shape.Name);
                if (shape.Name == "ImagePage1")
                {
                    //.....
                    //Your code goes here.
                    //......
                    MessageBox.Show(shape.Name);
                }
                else if (shape.Name == "ImagePage2")
                {

                    //Your code goes here.                    
                
                }
            } 

Hope, this helps a bit.


#5

[quote=“rasmi.mishra, post:3, topic:187520”]
@Amjad_Sahi
Thanks for your response , it works for me


#6

@rasmi.mishra,

Good to know that your issue is sorted out by the suggested code segment. Feel free to contact us any time if you need further help or have some other issue or queries, we will be happy to assist you soon.