Hi,
I'm inserted an Excel File in a Word Document with DocIo. Here's my Code:
File.WriteAllBytes(tempfile, excelStream);
ExcelEngine excelEngine = new ExcelEngine();
IApplication application = excelEngine.Excel;
application.ChartToImageConverter = new ChartToImageConverter();
application.ChartToImageConverter.ScalingMode = Syncfusion.XlsIO.ScalingMode.Best;
IWorkbook workbook = application.Workbooks.Open(tempfile, ExcelOpenType.Automatic, ExcelParseOptions.Default);
WPicture picture = new WPicture(document);
IWorksheet sheet = workbook.ActiveSheet;
picture.LoadImage(sheet.ConvertToImage(1, 1, sheet.UsedRange.LastRow, sheet.UsedRange.LastColumn));
var scale = 520 / picture.Width * 100;
picture.WidthScale = scale;
picture.HeightScale = scale;
WOleObject oleObject = selection.GetAsOneRange().OwnerParagraph.AppendOleObject(tempfile, picture, Syncfusion.DocIO.DLS.OleObjectType.ExcelWorksheet);
oleObject.DisplayAsIcon = false;
File.Delete(tempfile);
The problem is that the colors of the charts are wrong and there is a black rectangle in the top. What went wrong???
See my screens below.
Kind regards,
Carsten
Here is how it looks like in Excel:
Here is a screen in Word:
And here how it looks like, if I insert it direct in Word: