//往表格里面插入值或者打開(kāi)表格填寫(xiě)

<%@ 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"%>
<%
//***************************卓正PageOffice組件的使用********************************
WordDocument doc = new WordDocument();
//打開(kāi)數(shù)據(jù)區(qū)域
DataRegion dTable = doc.openDataRegion("PO_table");
//設(shè)置數(shù)據(jù)區(qū)域可編輯性
dTable.setEditing(true);
//打開(kāi)數(shù)據(jù)區(qū)域中的表格,OpenTable(index)方法中的index為word文檔中表格的下標(biāo),從1開(kāi)始
Table table1 = doc.openDataRegion("PO_Table").openTable(1);
//設(shè)置表格邊框樣式
table1.getBorder().setLineColor(Color.green);
table1.getBorder().setLineWidth(WdLineWidth.wdLineWidth050pt);
// 設(shè)置表頭單元格文本居中
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);
// 給表頭單元格賦值
table1.openCellRC(1, 2).setValue("產(chǎn)品1");
table1.openCellRC(1, 3).setValue("產(chǎn)品2");
table1.openCellRC(2, 1).setValue("A部門");
table1.openCellRC(3, 1).setValue("B部門");
PageOfficeCtrl poCtrl = new PageOfficeCtrl(request);
poCtrl.setWriter(doc);
//添加自定義按鈕
poCtrl.addCustomToolButton("保存", "Save", 1);
poCtrl.addCustomToolButton("全屏/還原", "IsFullScreen", 4);
//設(shè)置服務(wù)器頁(yè)面
poCtrl.setServerPage(request.getContextPath()+"/poserver.zz"); //此行必須
//設(shè)置保存頁(yè)
poCtrl.setSaveDataPage("SaveData.jsp");
//設(shè)置文檔打開(kāi)方式
poCtrl.webOpen("doc/test.doc", OpenModeType.docSubmitForm, "張佚名");
poCtrl.setTagId("PageOfficeCtrl1");
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>數(shù)據(jù)區(qū)域提交表格</title>
<link href="p_w_picpaths/csstg.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="content">
<div id="textcontent" >
<script type="text/javascript">
//保存頁(yè)面
function Save() {
document.getElementById("PageOfficeCtrl1").WebSave();
}
//全屏/還原
function IsFullScreen() {
document.getElementById("PageOfficeCtrl1").FullScreen = !document.getElementById("PageOfficeCtrl1").FullScreen;
}
</script>
<!--************** 卓正 PageOffice組件 ************************-->
<po:PageOfficeCtrl id="PageOfficeCtrl1">
</po:PageOfficeCtrl>
</div>
</div>
</body>
</html>
循環(huán)取出
<%@ page language="java"
import="java.util.*,com.zhuozhengsoft.pageoffice.*,com.zhuozhengsoft.pageoffice.wordreader.*"
pageEncoding="gb2312"%>
<%
//----------- PageOffice 服務(wù)器端編程開(kāi)始 -------------------//
WordDocument doc = new WordDocument(request,response);
DataRegion dataReg = doc.openDataRegion("PO_table");
Table table = dataReg.openTable(1);
//輸出提交的table中的數(shù)據(jù)
out.print("表格中的各個(gè)單元的格數(shù)據(jù)為:<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());
//向客戶端顯示提交的數(shù)據(jù)
doc.showPage(300, 300);
doc.close();
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<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">
-->
</head>
<body>
</body>
</html>
創(chuàng)新互聯(lián)www.cdcxhl.cn,專業(yè)提供香港、美國(guó)云服務(wù)器,動(dòng)態(tài)BGP最優(yōu)骨干路由自動(dòng)選擇,持續(xù)穩(wěn)定高效的網(wǎng)絡(luò)助力業(yè)務(wù)部署。公司持有工信部辦法的idc、isp許可證, 機(jī)房獨(dú)有T級(jí)流量清洗系統(tǒng)配攻擊溯源,準(zhǔn)確進(jìn)行流量調(diào)度,確保服務(wù)器高可用性。佳節(jié)活動(dòng)現(xiàn)已開(kāi)啟,新人活動(dòng)云服務(wù)器買多久送多久。
網(wǎng)站題目:java循環(huán)取出wordtable表格中所有的值-創(chuàng)新互聯(lián)
網(wǎng)站鏈接:http://chinadenli.net/article28/hphjp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、用戶體驗(yàn)、微信公眾號(hào)、Google、定制網(wǎng)站、網(wǎng)站設(shè)計(jì)公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容