• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Paragraph类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: saveDoc

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
/**
 * Method to save the file by parameters in doc format
 *
 * @param toSave The file where the information will be saved
 */
private void saveDoc(File toSave) {
  try {
    POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("down/empty.doc"));
    HWPFDocument doc = new HWPFDocument(fs);
    Range range = doc.getRange();
    Paragraph parContainer = range.insertAfter(new ParagraphProperties(), 0);
    for (String para : paragraphs) {
      parContainer.setSpacingAfter(200);
      parContainer.insertAfter(para);
      parContainer = range.insertAfter(new ParagraphProperties(), 0);
    }
    FileOutputStream fos = new FileOutputStream(toSave);
    doc.write(fos);
    fos.close();
  } catch (Exception e) {
    Logger.getGlobal().log(Level.SEVERE, e.getMessage() + "\n" + Arrays.toString(e.getStackTrace()));
  }
}
 
开发者ID:ames89,项目名称:clippyboard,代码行数:24,代码来源:FileExportCreator.java


示例2: handleHeaderFooter

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
private void handleHeaderFooter(Range[] ranges, String type,
    HWPFDocument document, PicturesSource pictures,
    PicturesTable pictureTable, XHTMLContentHandler xhtml)
    throws SAXException, IOException, TikaException {
  if (countParagraphs(ranges) > 0) {
    xhtml.startElement("div", "class", type);
    for (Range r : ranges) {
      if (r != null) {
        for (int i = 0; i < r.numParagraphs(); i++) {
          Paragraph p = r.getParagraph(i);

          String text = p.text();
          if (text.replaceAll("[\\r\\n\\s]+", "").isEmpty()) {
            // Skip empty header or footer paragraphs
          } else {
            i += handleParagraph(p, 0, r, document,
                FieldsDocumentPart.HEADER, pictures, pictureTable, xhtml);
          }
        }
      }
    }
    xhtml.endElement("div");
  }
}
 
开发者ID:kolbasa,项目名称:OCRaptor,代码行数:25,代码来源:WordExtractor.java


示例3: getParagraphText

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
protected static String[] getParagraphText( Range r )
{
    String[] ret;
    ret = new String[r.numParagraphs()];
    for ( int i = 0; i < ret.length; i++ )
    {
        Paragraph p = r.getParagraph( i );
        ret[i] = p.text();

        // Fix the line ending
        if ( ret[i].endsWith( "\r" ) )
        {
            ret[i] = ret[i] + "\n";
        }
    }
    return ret;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:18,代码来源:WordExtractor.java


示例4: processParagraphRequest

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
/**
 * Processing of text requests.
 * 
 * @param doc word document
 * @param paragraphRef reference to paragraphs
 * @return list of text values as {@code LinkedList<Value>}
 */
private LinkedList<Value> processParagraphRequest(HWPFDocument doc, String paraRef) {
    LinkedList<Value> valList = new LinkedList<Value>();
    Range docRange = doc.getRange();

    setStartEndParagraph(paraRef, "*");
    if (this.startPara == -1 || this.endPara == -1) {
        this.startPara = 0;
        this.endPara = docRange.numParagraphs() - 1;
    }

    // -1 => all paragraphs requested
    if (this.startPara < docRange.numParagraphs()) {
        if (!(this.endPara < docRange.numParagraphs())) {
            this.endPara = docRange.numParagraphs() - 1;
        }

        for (Integer pPos = this.startPara; pPos <= this.endPara; pPos++) {
            Paragraph p = docRange.getParagraph(pPos);
            Integer subURI = pPos + 1;
            valList.add(getParagraph(p, subURI.toString()));
        }
    }

    return valList;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:33,代码来源:DataWordResource.java


示例5: getParagraph

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
/**
 * Get a single paragraph of Word 97 - 2003 document
 * 
 * @param paragraph HWPF paragraph to process
 * @param paragraphRef position of paragraph
 * @return value of paragraph as {@code Value}
 */
private Value getParagraph(Paragraph paragraph, String paragraphRef) {
    Value singleVal = new Value();

    // Word 97-2003 does not separate between text paragraphs and tables,
    // ignore paragraphs which are part of a table
    if (!paragraph.isInTable()) {
        String value = paragraph.text();
        // remove XML incompatible control sequences used by old word 97
        // format
        value = value.replaceAll("[\u0000-\u0009]", "");
        value = value.replaceAll("\u000B", "\n");
        value = value.replaceAll("[\u000C-\u001f]", "");

        singleVal.setValue(value.trim());
        singleVal.setSubURI(paragraphRef);
        singleVal.setType("xs:string");
    }

    return singleVal;
}
 
开发者ID:chsatgithub,项目名称:PANDA-DEEPLINKING,代码行数:28,代码来源:DataWordResource.java


示例6: read

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public  ArrayList<TableData> read(String path) throws IOException {
		FileInputStream in = new FileInputStream(new File(path));  
        HWPFDocument hwpf = new HWPFDocument(in);  
        Range range = hwpf.getRange();// 得到文档的读取范围  
        TableIterator it = new TableIterator(range);  
        ArrayList<TableData> list=new ArrayList<TableData>();
        int count=0;
        // 迭代文档中的表格  
        while (it.hasNext()) {  
            Table tb = (Table) it.next();  
            TableData data=new TableData();
            // 迭代行,默认从0开始  
            for (int i = 0; i < tb.numRows(); i++) {  
                TableRow tr = tb.getRow(i);  
                // 迭代列,默认从0开始  
                for (int j = 0; j < tr.numCells(); j++) {  
                    TableCell td = tr.getCell(j);// 取得单元格  
                    // 取得单元格的内容  
                    StringBuffer sb=new StringBuffer();
                    for (int k = 0; k < td.numParagraphs(); k++) {  
                        Paragraph para = td.getParagraph(k);  
                        sb.append(para.text());  
                    } 
                    String string=sb.toString().trim();
                    if(i==0&&j==1)
                    {
                    	data.setClazz(string);
                    }
                    else if(i==1&&j==1)
                    {
                    	data.setName(string);
                    }
                    else if(i==2&&j==1)
                    {
                    	data.setLifeCircle(string);
                    }
                    else if(i==2&&j==3)
                    {
                    	data.setTheme(string);
                    }
                    else if(i==3&&j==3)
                    {
                    	data.setForm(string);
                    }
                    else if(i==4&&j==1)
                    {
                    	data.setKeywords(string);
                    }
                    else if(i==9&&j==1)
                    {
                    	data.setContent(string);
                    }
                }  
            }
//            show("第"+count+"条:"+data.toString());
            count+=1;
            list.add(data);
        }
		return list;
	}
 
开发者ID:wanxu,项目名称:ReadTableFromWord,代码行数:61,代码来源:TableReader.java


示例7: readList

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
/**
 * 读列表
 * 
 * @param range
 */
private void readList(Range range) {
	int num = range.numParagraphs();
	Paragraph para;
	for (int i = 0; i < num; i++) {
		para = range.getParagraph(i);
		if (para.isInList()) {
			System.out.println("list: " + para.text());
		}
	}
}
 
开发者ID:East196,项目名称:maker,代码行数:16,代码来源:HwpfTest.java


示例8: cellText

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public static String cellText(final TableCell cell) {
  String s = "";
  for (int k = 0; (k < cell.numParagraphs()); k++) {
    {
      final Paragraph para = cell.getParagraph(k);
      String _s = s;
      String _text = para.text();
      String _trim = _text.trim();
      s = (_s + _trim);
    }
  }
  return s;
}
 
开发者ID:East196,项目名称:maker,代码行数:14,代码来源:PoiUtils.java


示例9: getWordParagraphText

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
/**
 * Get the text from the word file, as an array with one String
 *  per paragraph
 */
public static String[] getWordParagraphText(HWPFDocument doc) {
	String[] ret;
	
	// Extract using the model code
	try {
    	Range r = doc.getRange();

		ret = new String[r.numParagraphs()];
		for(int i=0; i<ret.length; i++) {
			Paragraph p = r.getParagraph(i);
			ret[i] = p.text();
			
			// Fix the line ending
			if(ret[i].endsWith("\r")) {
				ret[i] = ret[i] + "\n";
			}
		}
	}
               catch(Exception e) {
		// Something's up with turning the text pieces into paragraphs
		// Fall back to ripping out the text pieces
		ret = new String[1];
		ret[0] = getWordTextFromPieces(doc);
	}
	
	return ret;
}
 
开发者ID:wandora-team,项目名称:wandora,代码行数:32,代码来源:MSOfficeBox.java


示例10: setIndent

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public static void setIndent( Paragraph paragraph, Element block )
{
    if ( paragraph.getFirstLineIndent() != 0 )
    {
        block.setAttribute(
                "text-indent",
                String.valueOf( paragraph.getFirstLineIndent()
                        / TWIPS_PER_PT )
                        + "pt" );
    }
    if ( paragraph.getIndentFromLeft() != 0 )
    {
        block.setAttribute(
                "start-indent",
                String.valueOf( paragraph.getIndentFromLeft()
                        / TWIPS_PER_PT )
                        + "pt" );
    }
    if ( paragraph.getIndentFromRight() != 0 )
    {
        block.setAttribute(
                "end-indent",
                String.valueOf( paragraph.getIndentFromRight()
                        / TWIPS_PER_PT )
                        + "pt" );
    }
    if ( paragraph.getSpacingBefore() != 0 )
    {
        block.setAttribute(
                "space-before",
                String.valueOf( paragraph.getSpacingBefore() / TWIPS_PER_PT )
                        + "pt" );
    }
    if ( paragraph.getSpacingAfter() != 0 )
    {
        block.setAttribute( "space-after",
                String.valueOf( paragraph.getSpacingAfter() / TWIPS_PER_PT )
                        + "pt" );
    }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:41,代码来源:WordToFoUtils.java


示例11: setJustification

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public static void setJustification( Paragraph paragraph,
        final Element element )
{
    String justification = getJustification( paragraph.getJustification() );
    if ( isNotEmpty( justification ) )
        element.setAttribute( "text-align", justification );
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:8,代码来源:WordToFoUtils.java


示例12: setParagraphProperties

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public static void setParagraphProperties( Paragraph paragraph,
        Element block )
{
    setIndent( paragraph, block );
    setJustification( paragraph, block );

    setBorder( block, paragraph.getBottomBorder(), "bottom" );
    setBorder( block, paragraph.getLeftBorder(), "left" );
    setBorder( block, paragraph.getRightBorder(), "right" );
    setBorder( block, paragraph.getTopBorder(), "top" );

    if ( paragraph.pageBreakBefore() )
    {
        block.setAttribute( "break-before", "page" );
    }

    block.setAttribute( "hyphenate",
            String.valueOf( paragraph.isAutoHyphenated() ) );

    if ( paragraph.keepOnPage() )
    {
        block.setAttribute( "keep-together.within-page", "always" );
    }

    if ( paragraph.keepWithNext() )
    {
        block.setAttribute( "keep-with-next.within-page", "always" );
    }

    block.setAttribute( "linefeed-treatment", "preserve" );
    block.setAttribute( "white-space-collapse", "false" );
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:33,代码来源:WordToFoUtils.java


示例13: addIndent

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public static void addIndent( Paragraph paragraph, StringBuilder style )
{
    addIndent( style, "text-indent", paragraph.getFirstLineIndent() );

    addIndent( style, "margin-left", paragraph.getIndentFromLeft() );
    addIndent( style, "margin-right", paragraph.getIndentFromRight() );

    addIndent( style, "margin-top", paragraph.getSpacingBefore() );
    addIndent( style, "margin-bottom", paragraph.getSpacingAfter() );
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:11,代码来源:WordToHtmlUtils.java


示例14: addJustification

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public static void addJustification( Paragraph paragraph,
        final StringBuilder style )
{
    String justification = getJustification( paragraph.getJustification() );
    if ( isNotEmpty( justification ) )
        style.append( "text-align:" + justification + ";" );
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:8,代码来源:WordToHtmlUtils.java


示例15: addParagraphProperties

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public static void addParagraphProperties( Paragraph paragraph,
        StringBuilder style )
{
    addIndent( paragraph, style );
    addJustification( paragraph, style );

    addBorder( paragraph.getBottomBorder(), "bottom", style );
    addBorder( paragraph.getLeftBorder(), "left", style );
    addBorder( paragraph.getRightBorder(), "right", style );
    addBorder( paragraph.getTopBorder(), "top", style );

    if ( paragraph.pageBreakBefore() )
    {
        style.append( "break-before:page;" );
    }

    style.append( "hyphenate:"
            + ( paragraph.isAutoHyphenated() ? "auto" : "none" ) + ";" );

    if ( paragraph.keepOnPage() )
    {
        style.append( "keep-together.within-page:always;" );
    }

    if ( paragraph.keepWithNext() )
    {
        style.append( "keep-with-next.within-page:always;" );
    }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:30,代码来源:WordToHtmlUtils.java


示例16: processParagraph

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
@Override
protected void processParagraph( HWPFDocumentCore wordDocument,
        Element parentElement, int currentTableLevel, Paragraph paragraph,
        String bulletText )
{
    Element pElement = textDocumentFacade.createParagraph();
    pElement.appendChild( textDocumentFacade.createText( bulletText ) );
    processCharacters( wordDocument, currentTableLevel, paragraph, pElement );
    pElement.appendChild( textDocumentFacade.createText( "\n" ) );
    parentElement.appendChild( pElement );
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:12,代码来源:WordToTextConverter.java


示例17: dumpParagraphsDom

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
public void dumpParagraphsDom( boolean withText )
{
    Range range = _doc.getOverallRange();
    for ( int p = 0; p < range.numParagraphs(); p++ )
    {
        Paragraph paragraph = range.getParagraph( p );
        System.out.println( p + ":\t" + paragraph.toString() );

        if ( withText )
            System.out.println( paragraph.text() );
    }
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:13,代码来源:HWPFLister.java


示例18: processParagraph

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
protected abstract void processParagraph( HWPFDocumentCore wordDocument,
Element parentElement, int currentTableLevel, Paragraph paragraph,
String bulletText );
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:4,代码来源:AbstractWordConverter.java


示例19: processParagraphes

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
protected void processParagraphes( HWPFDocumentCore wordDocument,
        Element flow, Range range, int currentTableLevel )
{
    final int paragraphs = range.numParagraphs();
    for ( int p = 0; p < paragraphs; p++ )
    {
        Paragraph paragraph = range.getParagraph( p );

        if ( paragraph.isInTable()
                && paragraph.getTableLevel() != currentTableLevel )
        {
            if ( paragraph.getTableLevel() < currentTableLevel )
                throw new IllegalStateException(
                        "Trying to process table cell with higher level ("
                                + paragraph.getTableLevel()
                                + ") than current table level ("
                                + currentTableLevel
                                + ") as inner table part" );

            Table table = range.getTable( paragraph );
            processTable( wordDocument, flow, table );

            p += table.numParagraphs();
            p--;
            continue;
        }

        if ( paragraph.text().equals( "\u000c" ) )
        {
            processPageBreak( wordDocument, flow );
        }

        boolean processed = false;
        if ( paragraph.isInList() )
        {
            try
            {
                HWPFList hwpfList = paragraph.getList();

                String label = AbstractWordUtils.getBulletText(
                        numberingState, hwpfList,
                        (char) paragraph.getIlvl() );

                processParagraph( wordDocument, flow, currentTableLevel,
                        paragraph, label );
                processed = true;
            }
            catch ( Exception exc )
            {
                log.log(
                        POILogger.WARN,
                        "Can't process paragraph as list entry, will be processed without list information",
                        exc );
            }
        }

        if ( processed == false )
        {
            processParagraph( wordDocument, flow, currentTableLevel,
                    paragraph, AbstractWordUtils.EMPTY );
        }
    }

}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:65,代码来源:AbstractWordConverter.java


示例20: processParagraph

import org.apache.poi.hwpf.usermodel.Paragraph; //导入依赖的package包/类
protected void processParagraph( HWPFDocumentCore hwpfDocument,
        Element parentFopElement, int currentTableLevel,
        Paragraph paragraph, String bulletText )
{
    final Element block = foDocumentFacade.createBlock();
    parentFopElement.appendChild( block );

    WordToFoUtils.setParagraphProperties( paragraph, block );

    final int charRuns = paragraph.numCharacterRuns();

    if ( charRuns == 0 )
    {
        return;
    }

    boolean haveAnyText = false;

    if ( WordToFoUtils.isNotEmpty( bulletText ) )
    {
        Element inline = foDocumentFacade.createInline();
        block.appendChild( inline );

        Text textNode = foDocumentFacade.createText( bulletText );
        inline.appendChild( textNode );

        haveAnyText |= bulletText.trim().length() != 0;
    }

    haveAnyText = processCharacters( hwpfDocument, currentTableLevel,
            paragraph, block );

    if ( !haveAnyText )
    {
        Element leader = foDocumentFacade.createLeader();
        block.appendChild( leader );
    }

    WordToFoUtils.compactInlines( block );
    return;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:42,代码来源:WordToFoConverter.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java KMSClientProvider类代码示例发布时间:2022-05-23
下一篇:
Java ServiceRecord类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap