Java loops out all values in the Word table table

Source: Internet
Author: User

Insert values into the table or open the form to fill in

<%@ page language= "java" import= "java.util.*, java.awt.*" pageencoding= "gb2312"%>

<% @page import= "com.zhuozhengsoft.pageoffice.*, com.zhuozhengsoft.pageoffice.wordwriter.*"%>

<%@ taglib uri= "http://java.pageoffice.cn" prefix= "po"%>

<%

Use of Pageoffice components ********************************

Worddocument doc = new worddocument ();

Open Data region

DataRegion dtable = doc.opendataregion ("po_table");

Set data region editable

Dtable.setediting (TRUE);


Open the table in the data area, index in the OpenTable (index) method is the subscript for the table in the Word document, starting with 1

Table table1 = doc.opendataregion ("po_table"). OpenTable (1);

Set table border Style

Table1.getborder (). Setlinecolor (Color.green);

Table1.getborder (). Setlinewidth (WDLINEWIDTH.WDLINEWIDTH050PT);

Set table header Cell Text Center

TABLE1.OPENCELLRC (1, 2). Getparagraphformat (). Setalignment (Wdparagraphalignment.wdalignparagraphcenter);

TABLE1.OPENCELLRC (1, 3). Getparagraphformat (). Setalignment (Wdparagraphalignment.wdalignparagraphcenter);

TABLE1.OPENCELLRC (2, 1). Getparagraphformat (). Setalignment (Wdparagraphalignment.wdalignparagraphcenter);

TABLE1.OPENCELLRC (3, 1). Getparagraphformat (). Setalignment (Wdparagraphalignment.wdalignparagraphcenter);


Assigning a value to a table header cell

TABLE1.OPENCELLRC (1, 2). SetValue ("Product 1");

TABLE1.OPENCELLRC (1, 3). SetValue ("Product 2");

TABLE1.OPENCELLRC (2, 1). SetValue ("a department");

TABLE1.OPENCELLRC (3, 1). SetValue ("Department B");

Pageofficectrl Poctrl = new Pageofficectrl (request);

Poctrl.setwriter (DOC);


Add a custom button

Poctrl.addcustomtoolbutton ("Saving", "save", 1);

Poctrl.addcustomtoolbutton ("fullscreen/Restore", "IsFullScreen", 4);

Setting up a Server Page

Poctrl.setserverpage (Request.getcontextpath () + "/poserver.zz"); This line must

Setting up a Save page

Poctrl.setsavedatapage ("savedata.jsp");

Set how documents are opened

Poctrl.webopen ("Doc/test.doc", Openmodetype.docsubmitform, "Zhang Anonymous");

Poctrl.settagid ("PageOfficeCtrl1");

%>


<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >

<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>

<title> data region Submission Form </title>

<link href= "Images/csstg.css" rel= "stylesheet" type= "Text/css"/>

<body>


<div id= "Content" >

<div id= "textcontent" style= "width:1000px; height:800px; " >


<script type= "Text/javascript" >

Save page

function Save () {

document.getElementById ("PageOfficeCtrl1"). WeBSave ();

}


Fullscreen/restore

function IsFullScreen () {

document.getElementById ("PageOfficeCtrl1"). fullscreen =!document.getelementbyid ("PageOfficeCtrl1"). fullscreen;

}


</script>


<!--************** Zhou Zheng pageoffice Components ************************-->

<po:pageofficectrl id= "PAGEOFFICECTRL1" >

</po:PageOfficeCtrl>

</div>

</div>


</body>

Loop out

<%@ page language= "Java"

Import= "Java.util.*,com.zhuozhengsoft.pageoffice.*,com.zhuozhengsoft.pageoffice.wordreader.*"

pageencoding= "gb2312"%>

<%

-----------Pageoffice server-side programming begins-------------------//

Worddocument doc = new worddocument (request,response);

DataRegion Datareg = doc.opendataregion ("po_table");

Table table = datareg.opentable (1);

Output data from a submitted table

Out.print ("The grid data for each cell in the table is:<br/><br/>");

StringBuilder datastr = new StringBuilder ();

for (int i = 1; I <= table.getrowscount (); i++)

{

Datastr.append ("<div style= ' width:220px; > ");

for (int j = 1; J <= Table.getcolumnscount (); j + +)

{

Datastr.append ("<div style= ' float:left;width:70px;border:1px solid red; ') > "+TABLE.OPENCELLRC (i,j). GetValue () +" </div> ");

}

Datastr.append ("</div>");

}

Out.print (Datastr.tostring ());

To display the submitted data to the client

Doc.showpage (300, 300);

Doc.close ();

%>



<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en" >


<title>my JSP ' savefile.jsp ' starting page</title>


<meta http-equiv= "Pragma" content= "No-cache" >

<meta http-equiv= "Cache-control" content= "No-cache" >

<meta http-equiv= "Expires" content= "0" >

<meta http-equiv= "keywords" content= "keyword1,keyword2,keyword3" >

<meta http-equiv= "description" content= "This is my page" >

<!--

<link rel= "stylesheet" type= "Text/css" href= "Styles.css" >

-



<body>

</body>


Java loops out all values in the Word table table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.