Problem Inserting Images in Excel

I am having trouble embedding images to Excel. We’ve built a generic export class that when passed a data set into it, it dynamically generates the Excel report. That works just fine. However, since we need to embed the company logo on all reports, the logo is not always set right. Depending on the number of columns, the image/logo may be stretched or shrunk. This should not happen since the image is embedded into a single cell, not merged. Could you please shed light on this? Thanks.

This message was posted using Email2Forum by sheliah.


Thank you for considering Aspose.

Please try Picture.Placement = PlacementType.FreeFloating; option and see if it works fine for you. Please see the sample code in this regard:

//Instantiating a Workbook object

Workbook workbook = new Workbook();

//Adding a new worksheet to the Workbook object

int sheetIndex = workbook.Worksheets.Add();

//Obtaining the reference of the newly added worksheet by passing its sheet index

Worksheet worksheet = workbook.Worksheets[sheetIndex];

//Adding a picture at the location of a cell whose row and column indices

//are 5 in the worksheet. It is "F6" cell

Aspose.Cells.Picture pic = worksheet.Pictures[worksheet.Pictures.Add(5, 5, "C:\\Templates\\school.jpg")];

pic.Placement = PlacementType.FreeFloating;

//Saving the Excel file

workbook.Save("C:\\book_pic.xls", FileFormatType.Default);

If you still face the issue, please create a sample application and post it here (with your template & generated files) to show the issue and we will check it soon.

Thank You & Best Regards,