I can export an image to Excel but the image is sized to the row/cell. How can I export the image and have it keep its original dimensions. I don't want it resized.
WorksheetImage img = new WorksheetImage(image);img.TopLeftCornerCell = worksheet.Rows[rowIndex].Cells[0];img.TopLeftCornerPosition = new PointF(0.0F, 0.0F);img.BottomRightCornerCell = worksheet.Rows[rowIndex + 8].Cells[2];img.BottomRightCornerPosition = new PointF(100.0F, 100.0F);worksheet.Shapes.Add(img);Thank you!
Mike,
I created an EndExportEventHandler and added the code to it. It's now working as it should. The issue had to do with the image being added prior to data being exported into the first column which caused the column to expand stretching the image.
Thank you for your help.
Are the column width changes occurring after the image is positioned? If so, make sure the PositioningMode of the shape is set to MoveWithCells or DontMoveOrSizeWithCells. If it is set to MoveAndSizeWithCells, the image aspect ratio can be changed when row and column extents are changed.
img.TopLeftCornerCell = worksheet.Rows[rowIndex].Cells[0];img.TopLeftCornerPosition = new PointF(0.0F, 0.0F);img.BottomRightCornerCell = worksheet.Rows[rowIndex + 4].Cells[2]img.BottomRightCornerPosition = new PointF(100.0F, 100.0F);img.SetBoundsInTwips(worksheet, img.GetBoundsInTwips(), true);worksheet.Shapes.Add(img);
The image is in png format and is 388 x 154. The image can frequently change and therefore the dimensions will change as well. Also, sometimes the columns width changes based on the data exported.
That is currently not supported. Can you provide me with the image and/or the full code being used to create and position the image and I will try it on my machine?
I added that and it still distorts/stretches the image. Can I just place the image on an anchor starting point and it will place the image their with its original dimensions floating over as many rolls/cells as needed?