//create a new workbook var workbook = new GrapeCity.Documents.Excel.Workbook(); var fileStream = this.GetResourceStream("xlsx\\Sport sign-up sheet.xlsx"); workbook.Open(fileStream); IWorksheet worksheet = workbook.Worksheets[0]; // Get the absolute location and size of the Range["G1"] in the worksheet. IRange range = worksheet.Range["F1:G1"]; RectangleF rect = GrapeCity.Documents.Excel.CellInfo.GetAccurateRangeBoundary(range); // Add the image to the Range["G1"] System.IO.Stream stream = this.GetResourceStream("logo.png"); worksheet.Shapes.AddPictureInPixel(stream, GrapeCity.Documents.Excel.Drawing.ImageType.PNG, rect.X, rect.Y, rect.Width, rect.Height); // Save to an excel file workbook.Save("GetRangeBoundary.xlsx");
' Create a new Workbook Dim workbook As New Workbook 'Open an excel file Dim fileStream = GetResourceStream("xlsx\\Sport sign-up sheet.xlsx") workbook.Open(fileStream) Dim worksheet As IWorksheet = workbook.Worksheets(0) 'Get the absolute location And size of the Range["G1"] in the worksheet. Dim range As IRange = worksheet.Range("F1:G1") Dim rect As System.Drawing.RectangleF = Excel.CellInfo.GetAccurateRangeBoundary(range) 'Add the image to the Range["G1"] Dim stream As IO.Stream = GetResourceStream("logo.png") worksheet.Shapes.AddPictureInPixel(stream, ImageType.PNG, rect.X, rect.Y, rect.Width, rect.Height) ' save to an excel file workbook.Save("GetRangeBoundary.xlsx")