c# - Embed object in Excel programmatically -
i've tried several libraries, including epplus, npoi , can insert images, couldn't find how insert objects(pdf's, text files, images) as files. there way or library in .net? thanks!
using code able embed pdf file, txt file , , png file excel using c#.
public static class excelreaderfunctions { public static void excelinsertole(string path) { microsoft.office.interop.excel.application excel = new application(); excel.workbooks.add(); microsoft.office.interop.excel.workbook workbook = excel.activeworkbook; microsoft.office.interop.excel.worksheet sheet = workbook.activesheet; oleobjects oleobjects = (microsoft.office.interop.excel.oleobjects) sheet.oleobjects(type.missing); oleobjects.add( type.missing, // classtype path, // filename true, // link false, // displayasicon type.missing, // iconfilename type.missing, // iconindex type.missing, // iconlabel type.missing, // left type.missing, // top type.missing, // width type.missing // height ); excel.visible = true; workbook.close(true); excel.quit(); } }
then call function path of object want embed:
excelreaderfunctions.excelinsertole(@"c:\my.pdf"); excelreaderfunctions.excelinsertole(@"c:\my.txt"); excelreaderfunctions.excelinsertole(@"c:\my.png");
resource:
Comments
Post a Comment