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

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

本文整理了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

/**
 * Adds an OLE package manager object with the given POIFS to the sheet
 *
 * @param poiData an POIFS containing the embedded document, to be added
 * @param label the label of the payload
 * @param fileName the original filename
 * @param command the command to open the payload
 * @return the index of the added ole object
 * @throws IOException if the object can't be embedded
 */
public int addOlePackage(POIFSFileSystem poiData, String label, String fileName, String command)
throws IOException {
  DirectoryNode root = poiData.getRoot();
  Map<String,ClassID> olemap = getOleMap();
  for (Map.Entry<String,ClassID> entry : olemap.entrySet()) {
    if (root.hasEntry(entry.getKey())) {
      root.setStorageClsid(entry.getValue());
      break;
    }
  }
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  poiData.writeFilesystem(bos);
  return addOlePackage(bos.toByteArray(), label, fileName, command);
}

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

/**
 * Adds an OLE package manager object with the given POIFS to the sheet
 *
 * @param poiData an POIFS containing the embedded document, to be added
 * @param label the label of the payload
 * @param fileName the original filename
 * @param command the command to open the payload
 * @return the index of the added ole object
 * @throws IOException if the object can't be embedded
 */
public int addOlePackage(POIFSFileSystem poiData, String label, String fileName, String command)
throws IOException {
  DirectoryNode root = poiData.getRoot();
  Map<String,ClassID> olemap = getOleMap();
  for (Map.Entry<String,ClassID> entry : olemap.entrySet()) {
    if (root.hasEntry(entry.getKey())) {
      root.setStorageClsid(entry.getValue());
      break;
    }
  }
  ByteArrayOutputStream bos = new ByteArrayOutputStream();
  poiData.writeFilesystem(bos);
  return addOlePackage(bos.toByteArray(), label, fileName, command);
}

相关文章

HSSFWorkbook类方法