I am using a simple program to evaluate OLE embed functionality, and having some issues with the behavior of the embedded Excel.
Screenshot 1 demonstrates the generated docx file, which looks ok, however double clicking the embed to edit brings up an incorrectly sized OLE demonstrated by Screenshot 2. And then pressing escape or clicking out results in a messed up image in Screenshot 3.
Is there a way to fix the OLE "popup" size so it displays the correct part of the spreadsheet?
The code I am using to test below:
static void Main(string[] args)
{
using var file = System.IO.File.Open(@"C:\Projects\WordTest\sample.xlsx", FileMode.Open, FileAccess.Read);
var workbook = new Workbook();
workbook.LoadFromStream(file);
var sheet = workbook.Worksheets[0];
sheet.PageSetup.TopMargin = 0;
sheet.PageSetup.RightMargin = 0;
sheet.PageSetup.BottomMargin = 0;
sheet.PageSetup.LeftMargin = 0;
using var imgstream = new MemoryStream();
sheet.ToEMFStream(imgstream, 0, 0, sheet.LastRow, sheet.LastColumn);
var doc = new Document();
var section = doc.AddSection();
var paragraph = section.AddParagraph();
var pic = new DocPicture(doc);
pic.LoadImage(imgstream);
pic.Width = 490f;
using var outputStream = new MemoryStream();
var ole = doc.LastParagraph.AppendOleObject(file, pic, Spire.Doc.Documents.OleObjectType.ExcelWorksheet);
doc.SaveToFile(@"C:\Projects\WordTest\sample.docx", Spire.Doc.FileFormat.Docx);
}