如何使用 Java 使用 Apose.Slides 添加通用文件类型的附件?
我尝试以编程方式执行的手动 PowerPoint 操作是:
插入 -> 对象 -> 来自文件
Aspose.Slides 可以使用 java 将 Excel 文件插入为链接吗?
最佳答案
下面的代码可以正常使用 aspose 幻灯片附加 Excel 文件
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import com.aspose.slides.IOleEmbeddedDataInfo;
import com.aspose.slides.IOleObjectFrame;
import com.aspose.slides.OleEmbeddedDataInfo;
import com.aspose.slides.Presentation;
import com.aspose.slides.SaveFormat;
public class SetFileTypeForAnEmbeddingObject2 {
public static void main(String[] args) throws IOException {
Presentation pres = new Presentation();
try {
// Add known Ole objects
byte[] fileBytes = Files.readAllBytes(Paths.get("C:\\work\\Demo uploadt.xlsm"));
// Create Ole embedded file info
IOleEmbeddedDataInfo dataInfo = new OleEmbeddedDataInfo(fileBytes, "xls");
// Create OLE object
IOleObjectFrame oleFrame = pres.getSlides().get_Item(0).getShapes().addOleObjectFrame(150, 420, 250, 50,
dataInfo);
oleFrame.setObjectIcon(true);
pres.save("C:\\work\\" + "SetFileTypeForAnEmbeddingObject7.pptx", SaveFormat.Pptx);
} finally {
if (pres != null)
pres.dispose();
}
}
}
关于java - 如何使用 Java 使用 Aspose.Slides 添加通用文件类型的附件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59386072/