• 2003和2007PPT解析


      2003和2007PPT解析
       演示:http://www.huiyi8.com/ppt/
     
     
    StringBuilder sb = new StringBuilder();
      if (StringUtils.equalsIgnoreCase(".pptx", ext)) {// 2007 2010
        XMLSlideShow xmlslideshow = new XMLSlideShow(new FileInputStream(file));
        // 根据xml格式的文件得到一个ppt素材
        XSLFPowerPointExtractor ppt = new XSLFPowerPointExtractor(xmlslideshow);
        sb.append(ppt.getText());
    //TODO2
    //      XMLSlideShow ppt = new XMLSlideShow( new FileInputStream(file) );
    //
    //      for( XSLFSlide slide : ppt.getSlides() ){
    //    for( XSLFShape shape : slide.getShapes() ){
    //      if ( shape instanceof XSLFTextShape ){
    //      XSLFTextShape txtshape = (XSLFTextShape)shape ;
    //      System.out.println(txtshape.getText());
    //      } else if(shape instanceof XSLFAutoShape){
    //      XSLFAutoShape autoShape = (XSLFAutoShape)shape;
    //      System.out.println(autoShape.getText());
    //      } else if(shape instanceof XSLFFreeformShape){
    //      XSLFFreeformShape shape2 = (XSLFFreeformShape)shape;
    //      System.out.println(shape2.getText());
    //      }else if ( shape instanceof XSLFConnectorShape ) {
    //      XSLFConnectorShape shape2 = (XSLFConnectorShape)shape ;
    //      System.out.println(shape2.getShapeName()) ;
    //      } else if ( shape instanceof XSLFPictureShape ){
    //      XSLFPictureShape shape2 = (XSLFPictureShape)shape ;
    //      System.out.println(shape2.getShapeName()) ;
    //      } else if ( shape instanceof XSLFGroupShape ){
    //      XSLFGroupShape shape2 = (XSLFGroupShape)shape ;
    //      System.out.println(shape2.getShapeName()) ;
    //      } else if ( shape instanceof XSLFSimpleShape ){
    //      XSLFSimpleShape shape2 = (XSLFSimpleShape)shape ;
    //      System.out.println(shape2.getShapeName()) ;
    //      }
    //    }
    //      }
      } else {// 2003 HSSFWorkbook
        SlideShow ss = new SlideShow(new HSLFSlideShow(new FileInputStream(file)));
    //      PowerPointExtractor ppt = new PowerPointExtractor(new FileInputStream(file));
    //      sb.append(ppt.getText());
        try {
        Slide[] slides = ss.getSlides();// 获得每一张幻灯片
        for (int i = 0; i < slides.length; i++) {
            TextRun[] t = slides[i].getTextRuns();// 为了取得幻灯片的文字内容,建立TextRun
            for (int j = 0; j < t.length; j++) {
          sb.append(t[j].getText());// 这里会将文字内容加到content中去
            }
            sb.append(slides[i].getTitle());
        }
        } catch (Exception ex) {
        System.err.println(ex.toString());
        }
      }
      return sb.toString();
  • 相关阅读:
    PHP 实现简易 IOC 容器
    MySQL 5.7原生JSON格式支持
    PHP 使用 array_map 替代 foreach
    深入了解PHP闭包的使用以及实现
    PHP补全固定数字位数前面有0的值
    面试技巧
    Flex 布局语法教程
    如何在phpexcel中设置自动高度(自动换行)?
    宝塔面板和wdcp有什么区别?哪个比较好用?
    linux下如何查找nginx配置文件的位置
  • 原文地址:https://www.cnblogs.com/lhrs/p/4165008.html
Copyright © 2020-2023  润新知