当前位置: 首页>>代码示例>>Java>>正文


Java POIXMLDocument类代码示例

本文整理汇总了Java中org.apache.poi.POIXMLDocument的典型用法代码示例。如果您正苦于以下问题:Java POIXMLDocument类的具体用法?Java POIXMLDocument怎么用?Java POIXMLDocument使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


POIXMLDocument类属于org.apache.poi包,在下文中一共展示了POIXMLDocument类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: readContent

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
@Override
protected String readContent(final VFSLeaf leaf) throws IOException, DocumentException {
    BufferedInputStream bis = null;
    final StringBuilder buffy = new StringBuilder();
    try {
        bis = new BufferedInputStream(leaf.getInputStream());
        final POIXMLTextExtractor extractor = (POIXMLTextExtractor) ExtractorFactory.createExtractor(bis);
        final POIXMLDocument document = extractor.getDocument();

        if (document instanceof XWPFDocument) {
            final XWPFDocument xDocument = (XWPFDocument) document;
            final XWPFHeaderFooterPolicy hfPolicy = xDocument.getHeaderFooterPolicy();
            extractHeaders(buffy, hfPolicy);
            extractContent(buffy, xDocument);
            extractFooters(buffy, hfPolicy);
        }

        return buffy.toString();
    } catch (final Exception e) {
        throw new DocumentException(e.getMessage());
    } finally {
        if (bis != null) {
            bis.close();
        }
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:27,代码来源:WordOOXMLDocument.java

示例2: create

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
/**
 * @param inp
 * @param excelReader
 * @param ignoreNumFormat 是否忽略数据格式  (default=false,按照格式读取) 
 * @return  jie
 * @throws InvalidFormatException
 * @throws IOException
 * @throws SQLException
 */
public static ReadHandler create(InputStream inp,
		ExcelReadListener excelReader, boolean ignoreNumFormat)
		throws InvalidFormatException, IOException, SQLException {
	 // If clearly doesn't do mark/reset, wrap up
       if (! inp.markSupported()) {
           inp = new PushbackInputStream(inp, 8);
       }

       // Ensure that there is at least some data there
       byte[] header8 = IOUtils.peekFirst8Bytes(inp);

       // Try to create
       if (POIFSFileSystem.hasPOIFSHeader(header8)) {
           POIFSFileSystem fs = new POIFSFileSystem(inp);
           return create(fs, excelReader, ignoreNumFormat);
       }
       if (POIXMLDocument.hasOOXMLHeader(inp)) {
            OPCPackage pkg = OPCPackage.open(inp);
            return create(pkg, excelReader, ignoreNumFormat);
       }
       throw new InvalidFormatException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
   

}
 
开发者ID:bingyulei007,项目名称:bingexcel,代码行数:34,代码来源:ExcelReaderFactory.java

示例3: readContent

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
@Override
protected String readContent(final VFSLeaf leaf) throws IOException, DocumentException {
    BufferedInputStream bis = null;
    final StringBuilder buffy = new StringBuilder();
    try {
        bis = new BufferedInputStream(leaf.getInputStream());
        final POIXMLTextExtractor extractor = (POIXMLTextExtractor) ExtractorFactory.createExtractor(bis);
        final POIXMLDocument document = extractor.getDocument();

        if (document instanceof XSSFWorkbook) {
            final XSSFWorkbook xDocument = (XSSFWorkbook) document;
            extractContent(buffy, xDocument);
        }

        return buffy.toString();
    } catch (final Exception e) {
        throw new DocumentException(e.getMessage());
    } finally {
        if (bis != null) {
            bis.close();
        }
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:24,代码来源:ExcelOOXMLDocument.java

示例4: readContent

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
@Override
public String readContent(final VFSLeaf leaf) throws IOException, DocumentException {
    BufferedInputStream bis = null;
    final StringBuilder buffy = new StringBuilder();
    try {
        bis = new BufferedInputStream(leaf.getInputStream());
        final POIXMLTextExtractor extractor = (POIXMLTextExtractor) ExtractorFactory.createExtractor(bis);
        final POIXMLDocument document = extractor.getDocument();

        if (document instanceof XSLFSlideShow) {
            final XSLFSlideShow slideShow = (XSLFSlideShow) document;
            final XMLSlideShow xmlSlideShow = new XMLSlideShow(slideShow);
            extractContent(buffy, xmlSlideShow);
        }

        return buffy.toString();
    } catch (final Exception e) {
        throw new DocumentException(e.getMessage());
    } finally {
        if (bis != null) {
            bis.close();
        }
    }
}
 
开发者ID:huihoo,项目名称:olat,代码行数:25,代码来源:PowerPointOOXMLDocument.java

示例5: isNewExcelFormat

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
/**
 * Detect the excel format with only peeking at the first 8 bytes of the input stream (leaving the stream untouched).
 *
 * @param inputStream the xls input stream.
 * @return true if the given input stream is a xls new format.
 * @throws IOException if an error occurs.
 */
public static boolean isNewExcelFormat(InputStream inputStream) throws IOException {

    boolean newFormat = false;

    // Ensure that there is at least some data there
    byte[] headers = IOUtils.peekFirst8Bytes(inputStream);

    if (NPOIFSFileSystem.hasPOIFSHeader(headers)) {
        newFormat = false;
    }
    if (POIXMLDocument.hasOOXMLHeader(new ByteArrayInputStream(headers))) {
        newFormat = true;
    }

    return newFormat;

}
 
开发者ID:Talend,项目名称:data-prep,代码行数:25,代码来源:XlsUtils.java

示例6: readPackage

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
public static OPCPackage readPackage(String path){
	try {
		OPCPackage pack = POIXMLDocument.openPackage(path);
		return pack;
	} catch (IOException e) {
		throw new RuntimeException("read word file["+path+"] error:"+e.getMessage());
	}
}
 
开发者ID:wayshall,项目名称:onetwo,代码行数:9,代码来源:ExcelUtils.java

示例7: setTemplate

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
/**
 * 为文档设置模板
 * @param templatePath  模板文件名称
 */
public void setTemplate(String templatePath) {
    try {
        this.document = new XWPFDocument(POIXMLDocument.openPackage(templatePath));
        bookMarks = new BookMarks(document);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dragon-yuan,项目名称:Ins_fb_pictureSpider_WEB,代码行数:13,代码来源:MSWordTool.java

示例8: testPOI

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
@Test
public void testPOI() throws Exception {
	// setup
	InputStream inputStream = OOXMLSignatureVerifierTest.class.getResourceAsStream("/hello-world-unsigned.docx");

	// operate
	boolean result = POIXMLDocument.hasOOXMLHeader(inputStream);

	// verify
	assertTrue(result);
}
 
开发者ID:e-Contract,项目名称:eid-applet,代码行数:12,代码来源:OOXMLSignatureVerifierTest.java

示例9: getWorkbook

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
public static Workbook getWorkbook(InputStream i) throws IOException
{
  BufferedInputStream bis = new BufferedInputStream(i);

  if (POIXMLDocument.hasOOXMLHeader(bis))
  {
    return new XSSFWorkbook(bis);
  }
  else if (POIFSFileSystem.hasPOIFSHeader(bis))
  {
    return new HSSFWorkbook(bis);
  }

  throw new FileReadException("Unable to read the file because it is of the incorrect format type.", null);
}
 
开发者ID:terraframe,项目名称:Runway-SDK,代码行数:16,代码来源:ExcelUtil.java

示例10: getDocument

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
/**
 * @see mj.ocraptor.extraction.tika.parser.microsoft.ooxml.OOXMLExtractor#getDocument()
 */
public POIXMLDocument getDocument() {
    return extractor.getDocument();
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:7,代码来源:AbstractOOXMLExtractor.java

示例11: getDocument

import org.apache.poi.POIXMLDocument; //导入依赖的package包/类
/**
 * Returns the opened document.
 * 
 * @see POIXMLTextExtractor#getDocument()
 */
POIXMLDocument getDocument();
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:7,代码来源:OOXMLExtractor.java


注:本文中的org.apache.poi.POIXMLDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。