Free Support Forum - aspose.com

Insert Image into a Cell using Aspose.Cells

Hi,

How can I Insert Image into a Cell using Aspose.Cells?

Thanks in advance

Mamun

Hi Mamun,

Please check the wiki http://www.aspose.com/Wiki/default.aspx/Aspose.Cells/AddingPictures.html

Hi Mamun,

May the following code help you for your need. The picture will be inserted into a single cell i.e., G4.

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Cells.SetRowHeight(3,140);
worksheet.Cells.SetColumnWidth(6,40);
//Insert picture into G4 cell.
int index = worksheet.Pictures.Add(3,6, 4, 7,"d:\\test\\school.jpg");
.
.
.
workbook.Save("d:\\test\\output.xls");
Thank you.

Thanks Amjad,

I am facing a problem in ImageURL. The Image that i want to show in the cell is in AppThemes of my solution. I am using the path "AppThemes/Granite/Images/logo.gif". but it cant find the path.

Is there is any special way to find the path of AppThemes of my .Net Solution?

Thanks

Mamu

Hi,

Thanks for considering Aspose.

Well, you may try the following options for getting the path of your image file.

//Open template
string path = MapPath("~");
path = path.Substring(0, path.LastIndexOf("\\"));
path += @"\AppThemes\Granite\Images\logo.gif";

//Get the path of the Application folder.
string path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "..\\..");
//Get the image file path.
string imageFile = path + @"\AppThemes\Granite\Images\logo.gif";

Thank you.