How to mimic office objects for adding pictures to excel

I have some code that i wrote using the office objects directly that i want to mimic using aspose.cells but cant quite figure out how to do it. The part I am confused on is how to get the picture's left and top to be based on the whole document and not the cell. Don't worry about how the are inserting a Drawing.Image instead of a stream like you guys have. I am only concerned about how the Left and Top properties work. it seems by default, aspose's version is relative to the cell. I need to figure out a way to set the left and top relative to the document. Is this possible?

This is just an overview of the method i am using:
`http://msdn.microsoft.com/en-us/library/bb209605(office.12).aspx`

Original Office object code:

If sLogo > "" Then
' insert a logo
img = System.Drawing.Image.FromFile(sLogo)
xlShapes = xlSheet.Shapes
xlShape = xlShapes.AddPicture(sLogo, False, True, LogoLeft, LogoTop, img.Width, img.Height)

xlShape.ScaleHeight(1, True)
xlShape.ScaleWidth(1, True)

img = Nothing
End If

Aspose code:

//add image
Worksheet sheet = wb.Worksheets[0];
int index = sheet.Pictures.Add(1, 1, new MemoryStream(logo));

Aspose.Cells.Picture picture = wb.Worksheets[0].Pictures[index];
picture.Placement = PlacementType.FreeFloating;
//picture.Left = 590;
//picture.Top = 3.75;
picture.HeightScale = 50;
picture.WidthScale = 50;

Hi,

Yes, the top and left offset of the picture can be defined with respect to the row and the column in Aspose.Cells for .NET. You can set the top offset of the picture with respect to the top left row, but not more than the height of the top left row. Similarly, the left offset can be defined with respect to the top left column, but not more than the width of the top left column.

An issue has been created on our Issue Tracking System with issue id 18036 for provision of the Top and Left margin settings of the pictures with respect to the documents instead of rows and columns. We will update you once there is progress on this issue.

Kind Regards

and just to be clear, there is no other current way to insert an image into an excel document except into a cell? just wanted to make sure there wasnt some other way I should be doing this. I'll await the fix.

Kirk

Hi Krik,

Please use Shapes.AddFreeFloatingShape() method.

Thank you.

That does seem to be a lot closer. i just need to know the best way to convert from the left and top unit that the office objects use, which is "points", to the unit of measurement you have for that method in aspose.cells. Your docs say pixels, but pixels is a screen display unit. I read that aspose.slides has a fixed pixels per inch of 576, but what is aspose.cells pixels per inch or how can i easily convert from points into the pixels that aspose.cells seems to need?

Kirk

Hi,

We will soon get back to explain you further.

Thank you.

Hi,

Well, To evaluate how many pixels are there per inch, it should be decided by the machine’s DPI settings. The normal value is 96.
And you can get it with the following code:

using (Bitmap bitmap = new Bitmap(1, 1))
{
using (Graphics graphics = Graphics.FromImage(bitmap))
{
//this.m_DPIX = (int)graphics.DpiX;
DPI = (int)graphics.DpiY;
}
}


Thank you.

The issues you have found earlier (filed as CELLSNET-18036) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.