it is possible to insert an OleObjects in excel, and that the object is a pdf file?
I have seen that they have examples but for an image.
I would appreciate your answer.
Thanks.
static void Main(string[] args)
{
//load Excel file
Workbook workbook = new Workbook();
Worksheet ws = workbook.Worksheets[0];
ws.Range["A1"].Text = "Here is an OLE Object.";
//insert OLE object
string pdfFile = "sample.pdf";
Image image = GenerateImage(pdfFile);
IOleObject oleObject = ws.OleObjects.Add(pdfFile, image, OleLinkType.Embed);
oleObject.Location = ws.Range["B4"];
oleObject.ObjectType = OleObjectType.AdobeAcrobatDocument;
//save the file
String result = "InsertOLEObjects_result.xlsx";
workbook.SaveToFile(result, ExcelVersion.Version2010);
}
private static Image GenerateImage(string fileName)
{
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile(fileName);
return pdf.SaveAsImage(0);
}