0

埋め込まれたファイルの種類に関係なく、.xls (POI タイプ: HSSF) ファイルのすべての埋め込みファイルを保存したいと思います。なので、埋め込まれたファイルをすべて拡張子なしで保存できると嬉しいです。Java 7 で Apache POI ライブラリ 3.7 を使用しています。

今、createDocumentInputStream(document)の使用に問題があります。この期待されるパラメーターを取得する方法がわかりません。誰でも私を助けることができますか?

public static void saveEmbeddedXLS(InputStream fis_param, String outputfile) throws IOException, InvalidFormatException{
    //HSSF - XLS

    int i = 0;
    System.out.println("Starting Embedded Search in xls...");

    POIFSFileSystem fs = new POIFSFileSystem(fis_param);//create FileSystem using fileInputStream
    HSSFWorkbook workbook = new HSSFWorkbook(fs);

    for (HSSFObjectData obj : workbook.getAllEmbeddedObjects()) {

        System.out.println("Objects : "+ obj.getOLE2ClassName());//the OLE2 Class Name of the object
        String oleName = obj.getOLE2ClassName();//Document Type

        DirectoryNode dn = (DirectoryNode) obj.getDirectory();//get Directory Node  


//Trying to create an input Stream with the embedded document, argument of createDocumentInputStream should be: String; Where/How can I get this correct parameter for the function?
        InputStream is = dn.createDocumentInputStream(oleName);//oleName = Document Type, but not it's name (Wrong!)

        FileOutputStream fos = new FileOutputStream(outputfile + "_" + i);//Outputfilepath + Number

        IOUtils.copy(is, fos);//FileInputStream > FileOutput Stream (save File without extension)
        i++;
       } 
    }
4

0 に答える 0