當前位置: 首頁>>代碼示例>>Java>>正文


Java XWPFDocument.createTable方法代碼示例

本文整理匯總了Java中org.apache.poi.xwpf.usermodel.XWPFDocument.createTable方法的典型用法代碼示例。如果您正苦於以下問題:Java XWPFDocument.createTable方法的具體用法?Java XWPFDocument.createTable怎麽用?Java XWPFDocument.createTable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.poi.xwpf.usermodel.XWPFDocument的用法示例。


在下文中一共展示了XWPFDocument.createTable方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: main

import org.apache.poi.xwpf.usermodel.XWPFDocument; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception
{
	XWPFDocument document = new XWPFDocument();
	
	// New 2x2 table
	XWPFTable tableOne = document.createTable();
	XWPFTableRow tableOneRowOne = tableOne.getRow(0);
	tableOneRowOne.getCell(0).setText("Hello");
	tableOneRowOne.addNewTableCell().setText("World");
	
	XWPFTableRow tableOneRowTwo = tableOne.createRow();
	tableOneRowTwo.getCell(0).setText("This is");
	tableOneRowTwo.getCell(1).setText("a table");
	
	// Add a break between the tables
	document.createParagraph().createRun().addBreak();
	
	// New 3x3 table
	XWPFTable tableTwo = document.createTable();
	XWPFTableRow tableTwoRowOne = tableTwo.getRow(0);
	tableTwoRowOne.getCell(0).setText("col one, row one");
	tableTwoRowOne.addNewTableCell().setText("col two, row one");
	tableTwoRowOne.addNewTableCell().setText("col three, row one");
	
	XWPFTableRow tableTwoRowTwo = tableTwo.createRow();
	tableTwoRowTwo.getCell(0).setText("col one, row two");
	tableTwoRowTwo.getCell(1).setText("col two, row two");
	tableTwoRowTwo.getCell(2).setText("col three, row two");
	
	XWPFTableRow tableTwoRowThree = tableTwo.createRow();
	tableTwoRowThree.getCell(0).setText("col one, row three");
	tableTwoRowThree.getCell(1).setText("col two, row three");
	tableTwoRowThree.getCell(2).setText("col three, row three");
	
	FileOutputStream outStream = new FileOutputStream("data/Apache_CreateTable.doc");
	document.write(outStream);
	outStream.close();
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_for_Apache_POI,代碼行數:39,代碼來源:ApacheCreateTable.java

示例2: createSimpleTable

import org.apache.poi.xwpf.usermodel.XWPFDocument; //導入方法依賴的package包/類
public static void createSimpleTable() throws Exception {
    @SuppressWarnings("resource")
XWPFDocument doc = new XWPFDocument();

    XWPFTable table = doc.createTable(3, 3);

    table.getRow(1).getCell(1).setText("EXAMPLE OF TABLE");

    // table cells have a list of paragraphs; there is an initial
    // paragraph created when the cell is created. If you create a
    // paragraph in the document to put in the cell, it will also
    // appear in the document following the table, which is probably
    // not the desired result.
    XWPFParagraph p1 = table.getRow(0).getCell(0).getParagraphs().get(0);

    XWPFRun r1 = p1.createRun();
    r1.setBold(true);
    r1.setText("The quick brown fox");
    r1.setItalic(true);
    r1.setFontFamily("Courier");
    r1.setUnderline(UnderlinePatterns.DOT_DOT_DASH);
    r1.setTextPosition(100);

    table.getRow(2).getCell(2).setText("only text");

    FileOutputStream out = new FileOutputStream("simpleTable.docx");
    doc.write(out);
    out.close();
}
 
開發者ID:Sayi,項目名稱:poi-tl,代碼行數:30,代碼來源:SimpleTable.java

示例3: createTable

import org.apache.poi.xwpf.usermodel.XWPFDocument; //導入方法依賴的package包/類
public XWPFTable createTable(XWPFDocument doc) {
	XWPFTable table = doc.createTable(rows, cols);
	table.setCellMargins(0, 0, 0, 0);

	table.setInsideHBorder(innerHBorder, 1, 0, "000000");

	return table;
}
 
開發者ID:FraunhoferCESE,項目名稱:HazardTrackingSystem,代碼行數:9,代碼來源:TableBuilder.java

示例4: main

import org.apache.poi.xwpf.usermodel.XWPFDocument; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception
{
	String dataPath = "src/featurescomparison/workingwithtables/createtables/data/";
	
	XWPFDocument document = new XWPFDocument();
	
	// New 2x2 table
	XWPFTable tableOne = document.createTable();
	XWPFTableRow tableOneRowOne = tableOne.getRow(0);
	tableOneRowOne.getCell(0).setText("Hello");
	tableOneRowOne.addNewTableCell().setText("World");
	
	XWPFTableRow tableOneRowTwo = tableOne.createRow();
	tableOneRowTwo.getCell(0).setText("This is");
	tableOneRowTwo.getCell(1).setText("a table");
	
	// Add a break between the tables
	document.createParagraph().createRun().addBreak();
	
	// New 3x3 table
	XWPFTable tableTwo = document.createTable();
	XWPFTableRow tableTwoRowOne = tableTwo.getRow(0);
	tableTwoRowOne.getCell(0).setText("col one, row one");
	tableTwoRowOne.addNewTableCell().setText("col two, row one");
	tableTwoRowOne.addNewTableCell().setText("col three, row one");
	
	XWPFTableRow tableTwoRowTwo = tableTwo.createRow();
	tableTwoRowTwo.getCell(0).setText("col one, row two");
	tableTwoRowTwo.getCell(1).setText("col two, row two");
	tableTwoRowTwo.getCell(2).setText("col three, row two");
	
	XWPFTableRow tableTwoRowThree = tableTwo.createRow();
	tableTwoRowThree.getCell(0).setText("col one, row three");
	tableTwoRowThree.getCell(1).setText("col two, row three");
	tableTwoRowThree.getCell(2).setText("col three, row three");
	
	FileOutputStream outStream = new FileOutputStream(dataPath + "Apache_CreateTable_Out.doc");
	document.write(outStream);
	outStream.close();
	
	System.out.println("Process Completed Successfully");
}
 
開發者ID:asposemarketplace,項目名稱:Aspose_Words_for_Apache_POI,代碼行數:43,代碼來源:ApacheCreateTable.java


注:本文中的org.apache.poi.xwpf.usermodel.XWPFDocument.createTable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。