// 新規ワークブックの作成 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]; // ワークシート内の範囲["F1:G1"]の絶対位置とサイズを取得 IRange range = worksheet.Range["F1:G1"]; RectangleF rect = GrapeCity.Documents.Excel.CellInfo.GetAccurateRangeBoundary(range); // 画像を範囲["F1: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); // xlsx ファイルに保存 workbook.Save("GetRangeBoundary.xlsx");
' 新規ワークブックの作成 Dim workbook As New Workbook Dim fileStream = GetResourceStream("xlsx\\Sport sign-up sheet.xlsx") workbook.Open(fileStream) Dim worksheet As IWorksheet = workbook.Worksheets(0) ' ワークシート内の範囲["F1:G1"]の絶対位置とサイズを取得 Dim range As IRange = worksheet.Range("F1:G1") Dim rect As System.Drawing.RectangleF = Excel.CellInfo.GetAccurateRangeBoundary(range) ' 画像を範囲["F1:G1"]に追加 Dim stream As IO.Stream = GetResourceStream("logo.png") worksheet.Shapes.AddPictureInPixel(stream, ImageType.PNG, rect.X, rect.Y, rect.Width, rect.Height) ' xlsx ファイルに保存 workbook.Save("GetRangeBoundary.xlsx")