org.apache.poi.hssf.usermodel.HSSFWorkbook.addOlePackage()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(2.1k)|赞(0)|评价(0)|浏览(292)

本文整理了Java中org.apache.poi.hssf.usermodel.HSSFWorkbook.addOlePackage()方法的一些代码示例,展示了HSSFWorkbook.addOlePackage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFWorkbook.addOlePackage()方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFWorkbook
类名称:HSSFWorkbook
方法名:addOlePackage

HSSFWorkbook.addOlePackage介绍

[英]Adds an OLE package manager object with the given POIFS to the sheet
[中]将具有给定POIF的OLE包管理器对象添加到工作表中

代码示例

代码示例来源:origin: org.apache.poi/poi

  1. /**
  2. * Adds an OLE package manager object with the given POIFS to the sheet
  3. *
  4. * @param poiData an POIFS containing the embedded document, to be added
  5. * @param label the label of the payload
  6. * @param fileName the original filename
  7. * @param command the command to open the payload
  8. * @return the index of the added ole object
  9. * @throws IOException if the object can't be embedded
  10. */
  11. public int addOlePackage(POIFSFileSystem poiData, String label, String fileName, String command)
  12. throws IOException {
  13. DirectoryNode root = poiData.getRoot();
  14. Map<String,ClassID> olemap = getOleMap();
  15. for (Map.Entry<String,ClassID> entry : olemap.entrySet()) {
  16. if (root.hasEntry(entry.getKey())) {
  17. root.setStorageClsid(entry.getValue());
  18. break;
  19. }
  20. }
  21. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  22. poiData.writeFilesystem(bos);
  23. return addOlePackage(bos.toByteArray(), label, fileName, command);
  24. }

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

  1. /**
  2. * Adds an OLE package manager object with the given POIFS to the sheet
  3. *
  4. * @param poiData an POIFS containing the embedded document, to be added
  5. * @param label the label of the payload
  6. * @param fileName the original filename
  7. * @param command the command to open the payload
  8. * @return the index of the added ole object
  9. * @throws IOException if the object can't be embedded
  10. */
  11. public int addOlePackage(POIFSFileSystem poiData, String label, String fileName, String command)
  12. throws IOException {
  13. DirectoryNode root = poiData.getRoot();
  14. Map<String,ClassID> olemap = getOleMap();
  15. for (Map.Entry<String,ClassID> entry : olemap.entrySet()) {
  16. if (root.hasEntry(entry.getKey())) {
  17. root.setStorageClsid(entry.getValue());
  18. break;
  19. }
  20. }
  21. ByteArrayOutputStream bos = new ByteArrayOutputStream();
  22. poiData.writeFilesystem(bos);
  23. return addOlePackage(bos.toByteArray(), label, fileName, command);
  24. }

相关文章

HSSFWorkbook类方法