I looked at http://www.aspose.com/docs/display/cellsnet/Set+Picture+as+Background+Fill+in+the+Chart and can get something implemented if I save the image I have to disk and then use the filestream to open it again. However, I don’t really want to save the image to disk and would rather use something like a MemoryStream.
See the below code snippet and attached workbook:
Workbook wb = new Workbook(“picture_as_fill.xlsx”);
Worksheet mainWS = wb.Worksheets;
Chart myChart = mainWS.Charts;
/// Setup picture saving options
Aspose.Cells.Rendering.ImageOrPrintOptions options = new Aspose.Cells.Rendering.ImageOrPrintOptions();
options.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;
options.Quality = 100;
options.VerticalResolution = 300;
options.HorizontalResolution = 300;
options.PrintingPage = PrintingPageType.IgnoreBlank;
options.IsImageFitToPage = false;
/// Get the image from the excel file
Bitmap penguinImage = mainWS.Pictures.ToImage(options);
/// Save image into a memorystream
MemoryStream memStream = new MemoryStream();
byte data = new byte[memStream.Length];
memStream.Read(data, 0, data.Length);
myChart.PlotArea.Area.FillFormat.ImageData = data;
The final line throws an exception of “Parameter is not valid”.
Is there something I need to tweak in order to add the ImageData for the fill from a MemoryStream?
Using Aspose.Cells .NET 18.104.22.168