Java Code Examples for org.apache.poi.poifs.filesystem.POIFSFileSystem

The following examples show how to use org.apache.poi.poifs.filesystem.POIFSFileSystem. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: easyexcel   Source File: WriteContextImpl.java    License: Apache License 2.0 6 votes vote down vote up
private POIFSFileSystem openFileSystemAndEncrypt(File file) throws Exception {
    POIFSFileSystem fileSystem = new POIFSFileSystem();
    Encryptor encryptor = new EncryptionInfo(EncryptionMode.standard).getEncryptor();
    encryptor.confirmPassword(writeWorkbookHolder.getPassword());
    OPCPackage opcPackage = null;
    try {
        opcPackage = OPCPackage.open(file, PackageAccess.READ_WRITE);
        OutputStream outputStream = encryptor.getDataStream(fileSystem);
        opcPackage.save(outputStream);
    } finally {
        if (opcPackage != null) {
            opcPackage.close();
        }
    }
    return fileSystem;
}
 
Example 2
Source Project: easyexcel   Source File: Poi3Test.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void Encryption() throws Exception {
    String file = TestFileUtil.getPath() + "large" + File.separator + "large07.xlsx";
    POIFSFileSystem fs = new POIFSFileSystem();
    EncryptionInfo info = new EncryptionInfo(EncryptionMode.agile);
    Encryptor enc = info.getEncryptor();
    enc.confirmPassword("foobaa");
    OPCPackage opc = OPCPackage.open(new File(file), PackageAccess.READ_WRITE);
    OutputStream os = enc.getDataStream(fs);
    opc.save(os);
    opc.close();

    // Write out the encrypted version
    FileOutputStream fos = new FileOutputStream("D:\\test\\99999999999.xlsx");
    fs.writeFilesystem(fos);
    fos.close();
    fs.close();

}
 
Example 3
/**
 * 读取非文档类的Ole对象
 * 
 * @param poifs
 * @return
 */
private WcOleObject readOle10Native(POIFSFileSystem poifs) {
	WcOleObject oleObject = new WcOleObject();
	try {
		Ole10Native ole10 = Ole10Native.createFromEmbeddedOleObject(poifs);
		oleObject.setFileName(FilenameUtils.getName(ole10.getFileName()));

		// byte[] data = IOUtils.toByteArray(packagePart.getInputStream());
		oleObject.setDataSize(ole10.getDataSize());
		oleObject.setData(ole10.getDataBuffer());
	} catch (Exception e) {
		logger.error(e.getMessage(), e);
	}

	return oleObject;
}
 
Example 4
Source Project: mpxj   Source File: MPPReader.java    License: GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override public ProjectFile read(InputStream is) throws MPXJException
{

   try
   {

      //
      // Open the file system
      //
      POIFSFileSystem fs = new POIFSFileSystem(is);

      return read(fs);

   }
   catch (IOException ex)
   {

      throw new MPXJException(MPXJException.READ_ERROR, ex);

   }
}
 
Example 5
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 6
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 7
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 8
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 9
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 10
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 11
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 12
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem( new FileInputStream(fileName) );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 13
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
	
}
 
Example 14
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process(String fileName ) throws IOException {
	
	this.fs = new POIFSFileSystem(new FileInputStream(fileName));
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
}
 
Example 15
Source Project: o2oa   Source File: Excel2003Reader.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
/**
 * 遍历excel下所有的sheet
 * @param fileKey 
 * @throws IOException
 */
public void process( InputStream is ) throws IOException {
	this.fs = new POIFSFileSystem( is );
	MissingRecordAwareHSSFListener listener = new MissingRecordAwareHSSFListener( this);
	formatListener = new FormatTrackingHSSFListener(listener);
	HSSFEventFactory factory = new HSSFEventFactory();
	HSSFRequest request = new HSSFRequest();
	if ( outputFormulaValues ) {
		request.addListenerForAllRecords( formatListener );
	} else {
		workbookBuildingListener = new SheetRecordCollectingListener( formatListener);
		request.addListenerForAllRecords(workbookBuildingListener);
	}
	factory.processWorkbookEvents(request, fs);
	//数据读取完成
}
 
Example 16
Source Project: conference-app   Source File: XlsSessionReader.java    License: MIT License 6 votes vote down vote up
private List<Session> readAllSessions(InputStream is) {
    final List<Session> result = new ArrayList<Session>();

    try {
        final POIFSFileSystem fileSystem = new POIFSFileSystem(is);
        final HSSFWorkbook workBook = new HSSFWorkbook(fileSystem);
        final HSSFSheet sheet = workBook.getSheet("Alle Tage");

        int rows = sheet.getPhysicalNumberOfRows();
        // as the row is a header we start with the second one
        for (int r = 1; r < rows; r++) {
            final HSSFRow row = sheet.getRow(r);
            if (row == null) {
                continue;
            }
            final Session session = getSessionFromRow(row, r);
            if (session != null) {
                result.add(session);
            }
        }
    } catch (Exception e) {
        throw new RuntimeException("Error while reading sessions from file", e);
    }
    return result;
}
 
Example 17
Source Project: lams   Source File: HSSFWorkbook.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 18
Source Project: DocBleach   Source File: ExcelRecordCleaner.java    License: MIT License 6 votes vote down vote up
protected static void cleanupAndSaveExcel97(POIFSFileSystem fs, OutputStream outputStream)
    throws IOException {
  Workbook wb = WorkbookFactory.create(fs);

  if (wb instanceof HSSFWorkbook) {
    HSSFWorkbook hwb = (HSSFWorkbook) wb;
    InternalWorkbook internal = hwb.getInternalWorkbook();
    if (internal != null) {
      LOGGER.trace("# of Records: {}", internal.getNumRecords());
      removeObProjRecord(internal.getRecords());
      LOGGER.trace("# of Records: {}", internal.getNumRecords());
    }
  }

  wb.write(outputStream);
}
 
Example 19
Source Project: DocBleach   Source File: OLE2Bleach.java    License: MIT License 6 votes vote down vote up
@Override
public void sanitize(InputStream inputStream, OutputStream outputStream, BleachSession session)
    throws BleachException {
  try (POIFSFileSystem fsIn = new POIFSFileSystem(inputStream);
      POIFSFileSystem fs = new POIFSFileSystem()) {
    // @TODO: Filter based on Storage Class ID - see issue #23
    sanitize(session, fsIn, fs);

    if (ClassID.EXCEL97.equals(fs.getRoot().getStorageClsid())) {
      ExcelRecordCleaner.cleanupAndSaveExcel97(fs, outputStream);
    } else {
      fs.writeFilesystem(outputStream);
    }
  } catch (IOException | IndexOutOfBoundsException e) {
    throw new BleachException(e);
  }
}
 
Example 20
Source Project: eplmp   Source File: IndexerTextExtractor.java    License: Eclipse Public License 1.0 6 votes vote down vote up
private String microsoftWordDocumentToString(InputStream inputStream) throws IOException {
    String strRet;

    try (InputStream wordStream = new BufferedInputStream(inputStream)) {
        if (POIFSFileSystem.hasPOIFSHeader(wordStream)) {
            WordExtractor wordExtractor = new WordExtractor(wordStream);
            strRet = wordExtractor.getText();
            wordExtractor.close();
        } else {
            XWPFWordExtractor wordXExtractor = new XWPFWordExtractor(new XWPFDocument(wordStream));
            strRet = wordXExtractor.getText();
            wordXExtractor.close();
        }
    }

    return strRet;
}
 
Example 21
Source Project: JavaWeb   Source File: FileUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void readExcel(String filePth) throws Exception {
	InputStream is = new FileInputStream(filePth);
	//创建工作薄
	//XSSFWorkbook hwb = new XSSFWorkbook(is);
	HSSFWorkbook hwb = new HSSFWorkbook(new POIFSFileSystem(is));
	//得到sheet
	for (int i = 0; i < hwb.getNumberOfSheets(); i++) {
		HSSFSheet sheet = hwb.getSheetAt(i);
		int rows = sheet.getPhysicalNumberOfRows();
		//遍历每一行
		for (int j = 0; j < rows; j++) {
			HSSFRow hr = sheet.getRow(j);
			Iterator<?> it = hr.iterator();
			while(it.hasNext()){
				String context = it.next().toString();
				System.out.println(context);
			}
		}
	}
	hwb.close();
}
 
Example 22
Source Project: JavaWeb   Source File: FileUtil.java    License: Apache License 2.0 6 votes vote down vote up
public static void readExcel(String filePth) throws Exception {
	InputStream is = new FileInputStream(filePth);
	//创建工作薄
	//XSSFWorkbook hwb = new XSSFWorkbook(is);
	HSSFWorkbook hwb = new HSSFWorkbook(new POIFSFileSystem(is));
	//得到sheet
	for (int i = 0; i < hwb.getNumberOfSheets(); i++) {
		HSSFSheet sheet = hwb.getSheetAt(i);
		int rows = sheet.getPhysicalNumberOfRows();
		//遍历每一行
		for (int j = 0; j < rows; j++) {
			HSSFRow hr = sheet.getRow(j);
			Iterator<?> it = hr.iterator();
			while(it.hasNext()){
				String context = it.next().toString();
				System.out.println(context);
			}
		}
	}
	hwb.close();
}
 
Example 23
Source Project: ExcelReads   Source File: ExcelTool.java    License: Apache License 2.0 6 votes vote down vote up
public static final Workbook newInstance(String type, boolean isSave) throws Exception {
    File f = new File(type);
    if (isSave) {
        if (type.equals("xls")) {
            return new HSSFWorkbook();
        }
        return new XSSFWorkbook();
    }
    if (!f.isFile()) {
        throw new Exception("请填写正确路径");
    }
    type = type.substring(type.lastIndexOf(".") + 1);
    if (type.equals("xls")) {
        return new HSSFWorkbook(new POIFSFileSystem(f));
    }
    return new XSSFWorkbook(f);
}
 
Example 24
Source Project: easyexcel   Source File: Default03RecordHandlerContext.java    License: Apache License 2.0 5 votes vote down vote up
public static Default03RecordHandlerContext getContext(HSSFRequest request, POIFSFileSystem fileSystem) {
	Default03RecordHandlerContext context = new Default03RecordHandlerContext();
	context.currColNum = 0;
	context.currRowList = Lists.newArrayList();
	context.rowQueue = new LinkedBlockingQueue<>();
	context.initHeadHandler();
	context.request = request;
	context.fileSystem = fileSystem;
	return context;
}
 
Example 25
Source Project: easyexcel   Source File: WriteContextImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * To encrypt
 */
private boolean doOutputStreamEncrypt07() throws Exception {
    if (StringUtils.isEmpty(writeWorkbookHolder.getPassword())
        || !ExcelTypeEnum.XLSX.equals(writeWorkbookHolder.getExcelType())) {
        return false;
    }
    if (writeWorkbookHolder.getFile() != null) {
        return false;
    }
    File tempXlsx = FileUtils.createTmpFile(UUID.randomUUID().toString() + ".xlsx");
    FileOutputStream tempFileOutputStream = new FileOutputStream(tempXlsx);
    try {
        writeWorkbookHolder.getWorkbook().write(tempFileOutputStream);
    } finally {
        try {
            writeWorkbookHolder.getWorkbook().close();
            tempFileOutputStream.close();
        } catch (Exception e) {
            if (!tempXlsx.delete()) {
                throw new ExcelGenerateException("Can not delete temp File!");
            }
            throw e;
        }
    }
    POIFSFileSystem fileSystem = null;
    try {
        fileSystem = openFileSystemAndEncrypt(tempXlsx);
        fileSystem.writeFilesystem(writeWorkbookHolder.getOutputStream());
    } finally {
        if (fileSystem != null) {
            fileSystem.close();
        }
        if (!tempXlsx.delete()) {
            throw new ExcelGenerateException("Can not delete temp File!");
        }
    }
    return true;
}
 
Example 26
@Test
public void dumpXlsInFile() throws IOException {
    paramsXls.put("file", xlsTempFile.getAbsolutePath());

    try (CurlResponse curlResponse = createRequest(node, path, paramsXls).execute()) {
        assertAcknowledged(curlResponse, xlsTempFile);
        try (InputStream is = new FileInputStream(xlsTempFile)) {
            final POIFSFileSystem fs = new POIFSFileSystem(is);
            final HSSFWorkbook book = new HSSFWorkbook(fs);
            final HSSFSheet sheet = book.getSheetAt(0);
            assertEquals(docNumber, sheet.getLastRowNum());
        }
    }
}
 
Example 27
Source Project: poiji   Source File: XSSFUnmarshallerFile.java    License: MIT License 5 votes vote down vote up
@Override
public <T> void returnFromEncryptedFile(Class<T> type, Consumer<? super T> consumer) {

    try (POIFSFileSystem fs = new POIFSFileSystem(poijiFile.file(), true)) {

        listOfEncryptedItems(type, consumer, fs);

    } catch (IOException e) {
        throw new PoijiException("Problem occurred while reading data", e);
    }
}
 
Example 28
Source Project: poiji   Source File: XSSFUnmarshallerStream.java    License: MIT License 5 votes vote down vote up
@Override
public <T> void returnFromEncryptedFile(Class<T> type, Consumer<? super T> consumer) {

    try (POIFSFileSystem fs = new POIFSFileSystem(poijiInputStream.stream())) {

        listOfEncryptedItems(type, consumer, fs);

    } catch (IOException e) {
        throw new PoijiException("Problem occurred while reading data", e);
    }
}
 
Example 29
Source Project: poiji   Source File: XSSFUnmarshaller.java    License: MIT License 5 votes vote down vote up
<T> void listOfEncryptedItems(Class<T> type, Consumer<? super T> consumer, POIFSFileSystem fs) throws IOException {
    InputStream stream = DocumentFactoryHelper.getDecryptedStream(fs, options.getPassword());

    try (OPCPackage open = OPCPackage.open(stream)) {
        unmarshal0(type, consumer, open);

    } catch (ParserConfigurationException | SAXException | IOException | OpenXML4JException e) {
        IOUtils.closeQuietly(fs);
        throw new PoijiException("Problem occurred while reading data", e);
    }
}
 
Example 30
/**
 * 读取Ole对象
 * 
 * @param embedId
 * @param xdoc
 * @return
 */
private WcOleObject readOleObject(String embedId, final XWPFDocument xdoc) {
	if (StringUtils.isBlank(embedId)) {
		return null;
	}
	WcOleObject oleObject = null;
	List<POIXMLDocumentPart> parts = xdoc.getRelations();
	for (POIXMLDocumentPart poixmlDocumentPart : parts) {
		String id = poixmlDocumentPart.getPackageRelationship().getId();
		if (embedId.equals(id)) {
			PackagePart packagePart = poixmlDocumentPart.getPackagePart();

			oleObject = new WcOleObject();
			// oleObjectContent.setFileName(packagePart.getPartName().getName());

			// 解析Ole对象中的文件,参考:http://poi.apache.org/poifs/how-to.html
			try (InputStream is = packagePart.getInputStream();) {
				POIFSFileSystem poifs = new POIFSFileSystem(is);

				if (isOle10NativeObject(poifs.getRoot())) {
					oleObject = readOle10Native(poifs);
				} else {
					oleObject = readDocumentOle(poifs, is);
				}
			} catch (Exception e) {
				logger.error(e.getMessage(), e);
			}
		}
	}

	return oleObject;
}