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


Java ParagraphAlignment类代码示例

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


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

示例1: main

import org.apache.poi.xwpf.usermodel.ParagraphAlignment; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
	// Create a new document from scratch
       XWPFDocument doc = new XWPFDocument();
       
       // create paragraph
       XWPFParagraph para = doc.createParagraph();
       
       // create a run to contain the content
       XWPFRun rh = para.createRun();
       
       // Format as desired
   	rh.setFontSize(15);
   	rh.setFontFamily("Verdana");
       rh.setText("This is the formatted Text");
       rh.setColor("fff000");
       para.setAlignment(ParagraphAlignment.RIGHT);
       
       // write the file
       FileOutputStream out = new FileOutputStream("data/Apache_FormattedText.docx");
       doc.write(out);
       out.close();
       
       System.out.println("Process Completed Successfully");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:26,代码来源:ApacheFormattedText.java

示例2: addText

import org.apache.poi.xwpf.usermodel.ParagraphAlignment; //导入依赖的package包/类
/**
 * 텍스트 입력
 *
 * @param p
 * @param text
 * @param fontSize
 * @param bold
 * @param italic
 * @param strike
 * @return
 */
public XWPFParagraph addText(XWPFParagraph p, String text, int fontSize, boolean bold, boolean italic, boolean strike) {

	KrXWPFRun r1 = new KrXWPFRun(p.createRun());

	r1.setText(text);
	r1.setBold(bold);
	r1.setItalic(italic);
	r1.setFontFamily(fontName);
	// r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
	r1.setStrike(strike);
	r1.setFontSize(fontSize);
	p.setAlignment(ParagraphAlignment.LEFT);
	// p.setSpacingLineRule(LineSpacingRule.EXACT);

	return p;
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:28,代码来源:MSWord.java

示例3: addBlockText

import org.apache.poi.xwpf.usermodel.ParagraphAlignment; //导入依赖的package包/类
/**
 * 텍스트 입력
 *
 * @param text
 */
public void addBlockText(String text, ParagraphAlignment alignment) {
	XWPFParagraph p1 = doc.createParagraph();
	p1.setAlignment(alignment);
	p1.setBorderBottom(Borders.DOUBLE);
	p1.setBorderTop(Borders.DOUBLE);

	p1.setBorderRight(Borders.DOUBLE);
	p1.setBorderLeft(Borders.DOUBLE);
	p1.setBorderBetween(Borders.SINGLE);

	p1.setVerticalAlignment(TextAlignment.TOP);

	// p1.setSpacingBefore(5);
	// p1.setSpacingAfter(5);
	// KrXWPFRun r1 = new KrXWPFRun(p1.createRun());
	// r1.setFontSize(13);
	// r1.setText(text);
	// r1.setFontFamily(fontName);

	addText(p1, text);
}
 
开发者ID:callakrsos,项目名称:Gargoyle,代码行数:27,代码来源:MSWord.java

示例4: main

import org.apache.poi.xwpf.usermodel.ParagraphAlignment; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithdocuments/formattext/data/";
	
	// Create a new document from scratch
       XWPFDocument doc = new XWPFDocument();
       
       // create paragraph
       XWPFParagraph para = doc.createParagraph();
       
       // create a run to contain the content
       XWPFRun rh = para.createRun();
       
       // Format as desired
   	rh.setFontSize(15);
   	rh.setFontFamily("Verdana");
       rh.setText("This is the formatted Text");
       rh.setColor("fff000");
       para.setAlignment(ParagraphAlignment.RIGHT);
       
       // write the file
       FileOutputStream out = new FileOutputStream(dataPath + "Apache_FormattedText_Out.docx");
       doc.write(out);
       out.close();
       
       System.out.println("Process Completed Successfully");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_Words_for_Apache_POI,代码行数:28,代码来源:ApacheFormattedText.java

示例5: writeParagraph

import org.apache.poi.xwpf.usermodel.ParagraphAlignment; //导入依赖的package包/类
/**
 * Método que se encarga de escribir un texto en un párrafo 
 * de un documento Microsoft Word
 * @param document El documento word que se va a crear
 * @param text El texto a meter en el word
 */
private void writeParagraph(XWPFDocument document,String text){
	XWPFParagraph paragraph = document.createParagraph();
	paragraph.setAlignment(ParagraphAlignment.BOTH);
	paragraph.createRun().setText(text);
	paragraph.createRun().setFontSize(12);
	paragraph.createRun().addCarriageReturn();
}
 
开发者ID:Arquisoft,项目名称:dashboard1b,代码行数:14,代码来源:WordLetter.java

示例6: saveStylesToDocxFile

import org.apache.poi.xwpf.usermodel.ParagraphAlignment; //导入依赖的package包/类
/**
 * ����text��������ʽ��docx��ʽ�ļ�
 */
@SuppressWarnings("deprecation")
public void saveStylesToDocxFile(StyledText text, XWPFDocument document) {

	for (int i = 0; i < text.getLineCount(); ++i) {
		int lineOffset = text.getOffsetAtLine(i);
		String lineText = text.getLine(i);
		XWPFParagraph paragraph = document.createParagraph();
		paragraph.setFirstLineIndent(text.getIndent());
		int lineAlignment = text.getLineAlignment(i);
		switch (lineAlignment) {
		case SWT.RIGHT:
			paragraph.setAlignment(ParagraphAlignment.RIGHT);
			break;
		case SWT.CENTER:
			paragraph.setAlignment(ParagraphAlignment.CENTER);
			break;
		}
		// ����ÿһ�����ÿ���ַ�
		for (int a = lineOffset; a < lineOffset + lineText.length(); ++a) {
			StyleRange charStyle = text.getStyleRangeAtOffset(a);
			String charText = text.getText(a, a);
			XWPFRun run = paragraph.createRun();
			run.setText(charText);
			String fontname = null;
			int fontsize = 0;
			if (charStyle != null) {
				// Color background = charStyle.background;
				// Color foreground = charStyle.foreground;
				if (charStyle.font != null) {
					fontname = charStyle.font.getFontData()[0].getName();
					if (b.text != null && text.equals(b.text))
						fontsize = b.getFontRealSize(charStyle.font.getFontData()[0].getHeight());
					else
						fontsize = text.getFont().getFontData()[0].getHeight();
				}
				int fontstyle = charStyle.fontStyle;
				switch (fontstyle) {
				case SWT.BOLD:
					run.setBold(true);
					break;
				case SWT.ITALIC:
					run.setItalic(true);
					break;
				case SWT.BOLD | SWT.ITALIC:
					run.setBold(true);
					run.setItalic(true);
					break;
				}
				run.setStrike(charStyle.strikeout);
				if (charStyle.underline)
					run.setUnderline(UnderlinePatterns.SINGLE);

				run.setFontFamily(fontname, FontCharRange.eastAsia);
				run.setFontSize(fontsize);
			}

		}

	}

}
 
开发者ID:piiiiq,项目名称:Black,代码行数:65,代码来源:blackAction.java

示例7: alignment

import org.apache.poi.xwpf.usermodel.ParagraphAlignment; //导入依赖的package包/类
public ParagraphBuilder alignment(ParagraphAlignment _alignment) {
	this.alignment = _alignment;
	return this;
}
 
开发者ID:FraunhoferCESE,项目名称:HazardTrackingSystem,代码行数:5,代码来源:ParagraphBuilder.java


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