您好,登錄后才能下訂單哦!
//往表格里面插入值或者打開表格填寫
<%@ 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();
//打開數據區域
DataRegion dTable = doc.openDataRegion("PO_table");
//設置數據區域可編輯性
dTable.setEditing(true);
//打開數據區域中的表格,OpenTable(index)方法中的index為word文檔中表格的下標,從1開始
Table table1 = doc.openDataRegion("PO_Table").openTable(1);
//設置表格邊框樣式
table1.getBorder().setLineColor(Color.green);
table1.getBorder().setLineWidth(WdLineWidth.wdLineWidth050pt);
// 設置表頭單元格文本居中
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("產品1");
table1.openCellRC(1, 3).setValue("產品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);
//設置服務器頁面
poCtrl.setServerPage(request.getContextPath()+"/poserver.zz"); //此行必須
//設置保存頁
poCtrl.setSaveDataPage("SaveData.jsp");
//設置文檔打開方式
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>數據區域提交表格</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">
//保存頁面
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>
循環取出
<%@ page language="java"
import="java.util.*,com.zhuozhengsoft.pageoffice.*,com.zhuozhengsoft.pageoffice.wordreader.*"
pageEncoding="gb2312"%>
<%
//----------- PageOffice 服務器端編程開始 -------------------//
WordDocument doc = new WordDocument(request,response);
DataRegion dataReg = doc.openDataRegion("PO_table");
Table table = dataReg.openTable(1);
//輸出提交的table中的數據
out.print("表格中的各個單元的格數據為:<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());
//向客戶端顯示提交的數據
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>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。