I'm working with Infragistics3.Documents.Excel.v11.1 (version 11.1.20111.2009)How can I insert the image of one file in a cell?Thank you in advance for your response.
THANKS ..
I already copy this code from your answer on some other questoion and it is working fine ..
private void AddWorksheetImage2(string Url, int rowIndex, int cellIndex) { Rectangle cellA1Bounds = m_ExcelWorksheet.Rows[rowIndex].Cells[cellIndex].GetBoundsInTwips(); Image image = Image.FromFile(Url); WorksheetImage imageShape = new WorksheetImage(image); imageShape.SetBoundsInTwips(m_ExcelWorksheet, cellA1Bounds); //set the WorksheetImage. PositioningMode to MoveAndSizeWithCells. imageShape.PositioningMode = ShapePositioningMode.MoveAndSizeWithCells; m_ExcelWorksheet.Shapes.Add(imageShape); }
Yes, this is supported in Infragistics35.WebUI.Excel.v9.1:
Workbook workbook = new Workbook(); Worksheet worksheet = workbook.Worksheets.Add("Sheet1"); WorksheetImage image = new WorksheetImage(Image.FromFile("image.bmp")); image.SetBoundsInTwips(worksheet, worksheet.GetCell("B2").GetBoundsInTwips(), true); image.PositioningMode = ShapePositioningMode.MoveAndSizeWithCells; worksheet.Shapes.Add(image); workbook.Save("Book1.xls");
Is it supported with this version : Infragistics35.WebUI.Excel.v9.1
and do you code example ?
Images cannot really be added to cells, as they are added as a layer on top of the worksheet, like all shapes. You can, however, place an image directly over a cell and have it move and size with the cell to give it the appearance of being in the cell.
Create a WorksheetImage instance, giving it the Image you want displayed. Use the SetBoundsInTwips method to set the image bounds to the bounds of the cell. You can get the cell's bounds by calling GetBoundsInTwips on the WorksheetCell instance for the cell. Then add the WorksheetImage to the Worksheet.Shapes collection. Also, set the WorksheetImage.PositioningMode to MoveAndSizeWithCells.