import com.spire.doc.*;
import com.spire.doc.documents.OleLinkType;
import com.spire.doc.documents.Paragraph;
import com.spire.doc.fields.DocOleObject;
import com.spire.doc.fields.DocPicture;
public class AddOLE {
public static void main(String[]args){
//创建文档
Document doc = new Document();
//添加段落
Section sec = doc.addSection();
Paragraph paragraph= sec.addParagraph();
//添加图片,并添加ole对象,链接到Excel文档
DocPicture picture = new DocPicture(doc);
picture.loadImage("tp.png");
//设置OLE链接方式
DocOleObject ole1 = paragraph.appendOleObject("test.xls",picture, OleLinkType.Link);
// DocOleObject ole2 = paragraph.appendOleObject("test.docx",picture, OleLinkType.Embed);
//保存文档
doc.saveToFile("AddOLE.docx",FileFormat.Docx_2013);
}
}