static void InsertShapeValue(IWorkbook workbook) { #region #insertshape Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SpreadsheetControl_WPF_API_Part02.Pictures.chart.png"); SpreadsheetImageSource imageSource = SpreadsheetImageSource.FromStream(imageStream); workbook.BeginUpdate(); // Set the measurement unit to Millimeter. workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter; try { Worksheet worksheet = workbook.Worksheets[0]; // Insert a picture from a file so that its top left corner is in the specified cell. // By default the picture is named Picture1.. PictureNN. worksheet.Pictures.AddPicture("Pictures\\chart.png", worksheet.Cells["D5"]); // Insert a picture to fit in the specified range. worksheet.Pictures.AddPicture("Pictures\\chart.png", worksheet.Range["B2"]); // Insert a picture from the SpreadsheetImageSource at 120 mm from the left, 80 mm from the top, // and resize it to a width of 70 mm and a height of 20 mm, locking the aspect ratio. worksheet.Pictures.AddPicture(imageSource, 120, 80, 70, 20, true); // Insert the picture to be removed. worksheet.Pictures.AddPicture("Pictures\\chart.png", 0, 0); // Remove the last inserted picture. // Find the shape by its name. The method returns a collection of shapes with the same name. Shape picShape = worksheet.Shapes.GetShapesByName("Picture 4")[0]; picShape.Delete(); } finally { workbook.EndUpdate(); } #endregion #insertshape }
static void InsertPictureFromUriValue(IWorkbook workbook) { #region #insertpicturefromuri string imageUri = "http://www.devexpress.com/Products/NET/Document-Server/i/Unit-Conversion.png"; // Create an image from Uri. SpreadsheetImageSource imageSource = SpreadsheetImageSource.FromUri(imageUri, workbook); // Set the measurement unit to point. workbook.Unit = DevExpress.Office.DocumentUnit.Point; workbook.BeginUpdate(); try { Worksheet worksheet = workbook.Worksheets[0]; // Insert a picture from the SpreadsheetImageSource at 100 pt from the left, 40 pt from the top, // and resize it to a width of 200 pt and a height of 180 pt. worksheet.Pictures.AddPicture(imageSource, 100, 40, 200, 180); } finally { workbook.EndUpdate(); } #endregion #insertpicturefromuri }