Export images from grid

Hello,

I have a grid tied to a database with 3 column, product description, product price and picture of the product.
Is it possible to export the picture to excel for each product?

Thanks
Arnold

Hi Arnold,

Thanks for considering Aspose.

Are pictures are saved in the database in byte array or binary format or the path of the pictures are saved in the database and pictures are saved in separate folders. If the pictures are saved in the folders, you may add pictures to your excel file. For importing data directly from a datagrid to your excel spreadsheet you may use Cells.ImportDataGrid() method in your web solutions.

For adding pictures to your excel file, please see:

Regards

Amjad Sahi

Aspose Nanjing Team

Thanks,

I did what you said, and it works pretty well.
The only problem is that my pictures are different sizes. When they are in my grid, I resize all of them to the same size. But when I export them, they appear at their original size, which might be some time way too big and some time too small.
Is there a way to make those picture fit the size of the cell?

thanks

You can try to use other Pictures.Add method to adjust images to cell :

Aspose.Cells API Reference pages.

I tried the other Picture.add method but they are good for specific picture, when you know the size of the picture or when all the picture are the same size…

I need a general solution because I loop through all the item of my grid. Therefore , sometime the picture is big and sometime the picture is small. I can not use those widthScale or heightScale because each image size is different.

This is how I insert the picture into my excel spreadsheet:

for(int i = 0; i < DG.Items.Count; i ++)
{
if(DG.ItemsIdea [I].Cells[7].Text.CompareTo(" ")==1)

{pictureIndex=sheet.Pictures.Add(2+i,6,path+"\\upload\\workinstru\\"+DG.ItemsIdea [I].Cells[7].Text,100,100);}
}

Thanks

Hi,

Would it be not working the overloaded Add() method for your task in which you set the percentage scale width and height for your pictures. Are you demanding that you may set the pictures size in the units of inches / cm?.

Well, currently this feature is not supported. we consider this feature in future.

Regards

Amjad Sahi

Aspose Nanjing Team

Please try this piece of code:

pictureIndex=sheet.Pictures.Add(2+i,6, 3 + i, 7, path+"\\upload\\workinstru\\"+DG.Items[ i ].Cells[7].Text);

Thanks to your solution, everything work.
thank you