We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How can I put a picture in absolute position on woorksheet?


I have a image, and I want put it on woorksheet in a position that not corresponding with a row and column possitions, the position of image is in a middle of a cell.

How can I do it?

Why do you need to set an image in an absolute position?Could you elaboration your need?

You can use Pictures.Add to add an image in a position corresponding with a row and column possitions. Then you can adjust image position in a cell using Picuture.LowerDeltaX, Picuture.LowerDeltaY, Picuture.UpperDeltaX and Picuture.UpperDeltaY.

We have discontinued Aspose.Excel and replaced it with an advanced version Aspose.Cells which is far better in terms of performance and features. This new product provides rich features to work with pictures and a vast range of drawing objects. You can define the picture’s exact position on a page with this new product as demonstrated below:

// 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
int pictureIndex = worksheet.Pictures.Add(5, 5, dataDir + "logo.jpg");

// Accessing the newly added picture
Aspose.Cells.Drawing.Picture picture = worksheet.Pictures[pictureIndex];

// Absolute positioning of the picture in unit of pixels
picture.Left = 60;
picture.Top = 10;

// Saving the Excel file
workbook.Save(dataDir + "book1.out.xls");

You may follow the below link to get more details about managing pictures:
Absolute Positioning

Further details about the drawing objects are available here.

You can download the latest version of the product here for testing:
Aspose.Cells for .NET (Latest Version)

For thorough testing of the product features, we have prepared a solution which can be downloaded here.