2018-06-03 22:26:41 +08:00

259 lines
9.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ page contentType="text/html; charset=GBK"%><%@
include file="/IncludeBegin.jsp"%><%
//获取组件参数
String sCustomerName = CurPage.getParameter("CustomerName");
String sCustomerID = CurPage.getParameter("CustomerID");
String sObjectType = CurPage.getParameter("ObjectType");
String sReportDate = CurPage.getParameter("ReportDate");
String sReportNo = CurPage.getParameter("ReportNo");
%>
<html>
<head>
<title>财务报表数据通过Excel文件导入</title>
<link rel="stylesheet" href="<%=sWebRootPath%>/Frame/page/resources/css/Style.css">
</head>
<script type="text/javascript">
function rtCurPage(){
self.close();
}
function DataPre(){
//文件名称:form1.btnRead.value;
alert(form1.filename.value);
}
</script>
<body bgColor="#DEDFCE">
<form name="form1" action="<%=sWebRootPath%>/Common/FinanceReport/ReportDataCommit.jsp?CompClientID=<%=CurComp.getClientID()%>" target="_self" method="post">
<table>
<tr>
<td>选择本机导入财务报表的Excel文件<input type="file" name="filename" style="font-size:9pt;padding-top:3;padding-left:5;padding-right:5; border: #DEDFCE; border-style: outset; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px" border="1"></td>
<td><input type="button" name="btnRead" value="预览" style="font-size:9pt;padding-top:3;padding-left:5;padding-right:5; border: #DEDFCE; border-style: outset; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px" border="1"></td>
<td><input type=button name=btnShow value="导入到服务器" style="font-size:9pt;padding-top:3;padding-left:5;padding-right:5; border: #DEDFCE; border-style: outset; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px" border="1"></td>
<td><input type="button" value="返回" onclick="rtCurPage();" style="font-size:9pt;padding-top:3;padding-left:5;padding-right:5; border: #DEDFCE; border-style: outset; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px" border="1"></td>
<td><input type="hidden" name="CustomerID" value="<%=sCustomerID%>"></td>
<td><input type="hidden" name="AccountMonth" value="<%=sReportDate%>"></td>
<td><input type="hidden" name="ReportNo" value="<%=sReportNo%>"></td>
<td><input type="hidden" name="excelData1" value=""></td>
<td><input type="hidden" name="excelData2" value=""></td>
<td><input type="hidden" name="iRowCount" value=""></td>
<td><input type="hidden" name="DisPlayMethod" value=""></td>
<td><input type="hidden" name=CompClientID value="<%=CurComp.getClientID()%>"></td>
</tr>
</table>
</form>
<OBJECT classid="CLSID:0002E559-0000-0000-C000-000000000046" height=80% id=Spreadsheet1
style="left: 0px; top: 0px" width="100%"
codebase="<%=sWebRootPath%>/FixStat/OWC11.DLL#version=0,0,0,0" viewastext>
<PARAM NAME="HTMLURL" VALUE="<%=sWebRootPath%>/Common/FinanceReport/html/Finance.htm">
<PARAM NAME="DataType" VALUE="HTMLURL">
<PARAM NAME="AutoFit" VALUE="0">
<PARAM NAME="DisplayColHeaders" VALUE="-1">
<PARAM NAME="DisplayGridlines" VALUE="-1">
<PARAM NAME="DisplayHorizontalScrollBar" VALUE="-1">
<PARAM NAME="DisplayRowHeaders" VALUE="-1">
<PARAM NAME="DisplayTitleBar" VALUE="-1">
<PARAM NAME="DisplayToolbar" VALUE="-1">
<PARAM NAME="DisplayVerticalScrollBar" VALUE="-1">
<PARAM NAME="EnableAutoCalculate" VALUE="-1">
<PARAM NAME="EnableEvents" VALUE="-1">
<PARAM NAME="MoveAfterReturn" VALUE="-1">
<PARAM NAME="MoveAfterReturnDirection" VALUE="0">
<PARAM NAME="RightToLeft" VALUE="0">
<PARAM NAME="ViewableRange" VALUE="1:65536">
</OBJECT>
</body>
<script type="text/javascript">
//把增加的报表数据填充到excel中
<%
//定义变量
String sReportName = "",sHeaderMethod="",sDisPlayMethod="";
String[] sTitle = new String[8];
int i =0,j=0,iRowCount=0,k=3;
String queryString = "select FR.ReportName,O.HeaderMethod,O.DisPlayMethod from O,jbo.finasys.REPORT_RECORD FR "
+" WHERE FR.ModelNo=O.ModelNo AND FR.REPORTNO=:REPORTNO and FR.ReportDate=:ReportDate and FR.ObjectNo=:ObjectNo";
List<BizObject> list = JBOFactory.createBizObjectQuery("jbo.finasys.REPORT_CATALOG", queryString)
.setParameter("REPORTNO",sReportNo).setParameter("ReportDate",sReportDate).setParameter("ObjectNo",sCustomerID).getResultList(false);
for(BizObject bo : list){
sReportName = bo.getAttribute("ReportName").getString();
sHeaderMethod = bo.getAttribute("HeaderMethod").getString();
sDisPlayMethod = bo.getAttribute("DisPlayMethod").getString();
}
StringTokenizer st = new StringTokenizer(sHeaderMethod,"&");
while (st.hasMoreTokens()){
sTitle[i++] = st.nextToken("&");
j=i;
}
%>
//第一行为报表名称
Spreadsheet1.Cells(1,1) = "<%=sReportName%>";
<%
for(i=0;i<j;i++){
%>
//第二行为标题行
Spreadsheet1.Cells(2,<%=i+1%>) = "<%=sTitle[i]%>";
<%
}
//取得报表数据
//通常Col1Value为期初值Col2Value为期末值
String sSql = " select RowName,RowNo,Col1Value,Col2Value from O WHERE REPORTNO=:ReportNo order by DisplayOrder";
BizObjectQuery bq = JBOFactory.createBizObjectQuery("jbo.finasys.REPORT_DATA", sSql).setParameter("ReportNo", sReportNo);
//先获取行数
iRowCount = bq.getTotalCount();
i=3;
j=1;
String s1="",s2="";
List<BizObject> datas = bq.getResultList(false);
for(BizObject bo : datas){
if(sDisPlayMethod.equals("1")){ //单列双值
%>
Spreadsheet1.Cells(<%=i%>,1) = '<%=DataConvert.toString(bo.getAttribute("RowName").getString())%>';
Spreadsheet1.Cells(<%=i%>,2) = '\'<%=DataConvert.toString(bo.getAttribute("RowNo").getString())%>';//格式转化,以填入单元格
Spreadsheet1.Cells(<%=i%>,3) = '<%=DataConvert.toMoney(Arith.round(bo.getAttribute("Col1Value").getDouble(),2))%>';
Spreadsheet1.Cells(<%=i%>,4) = '<%=DataConvert.toMoney(Arith.round(bo.getAttribute("Col2Value").getDouble(),2))%>';
<%
}else if(sDisPlayMethod.equals("3")){ //单列单值
%>
Spreadsheet1.Cells(<%=i%>,1) = '<%=DataConvert.toString(bo.getAttribute("RowName").getString())%>';
Spreadsheet1.Cells(<%=i%>,2) = '\'<%=DataConvert.toString(bo.getAttribute("RowNo").getString())%>';
Spreadsheet1.Cells(<%=i%>,3) = '<%=DataConvert.toMoney(Arith.round(bo.getAttribute("Col2Value").getDouble(),2))%>'; //单列单值型报表存值字段为Col2Value
<%
}
//sDisPlayMethod为2时双列双值
//目前双列双值的只有资产负债表,且在展示时,期末值在前,期初值在后
else if((sDisPlayMethod.equals("2") && j<=iRowCount/2)){
%>
Spreadsheet1.Cells(<%=i%>,1) = '<%=DataConvert.toString(bo.getAttribute("RowName").getString())%>';
Spreadsheet1.Cells(<%=i%>,2) = '\'<%=DataConvert.toString(bo.getAttribute("RowNo").getString())%>';
Spreadsheet1.Cells(<%=i%>,3) = '<%=DataConvert.toMoney(Arith.round(bo.getAttribute("Col2Value").getDouble(),2))%>'; //期末值
Spreadsheet1.Cells(<%=i%>,4) = '<%=DataConvert.toMoney(Arith.round(bo.getAttribute("Col1Value").getDouble(),2))%>'; //期初值
<%
}
//分栏显示的
//j<=iRowCount/2*2此公式除去奇数部分的数据
else if(sDisPlayMethod.equals("2") && j>iRowCount/2 && j<=iRowCount/2*2){
%>
Spreadsheet1.Cells(<%=k%>,5) = '<%=DataConvert.toString(bo.getAttribute("RowName").getString())%>';
Spreadsheet1.Cells(<%=k%>,6) = '\'<%=DataConvert.toString(bo.getAttribute("RowNo").getString())%>';
Spreadsheet1.Cells(<%=k%>,7) = '<%=DataConvert.toMoney(Arith.round(bo.getAttribute("Col2Value").getDouble(),2))%>'; //期末值
Spreadsheet1.Cells(<%=k%>,8) = '<%=DataConvert.toMoney(Arith.round(bo.getAttribute("Col1Value").getDouble(),2))%>'; //期初值
<%
k++;
}
i++;
j++;
}
%>
</script>
<script language=VBscript>
btnShowFlag = "no"
//数据预览
sub btnRead_onclick()
myFileName = form1.filename.value
if myFileName ="" then
alert "请先选一个文件!"
btnShowFlag = "no"
exit sub
end if
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.open(myFileName)
excelData1 = ""
excelData2 = ""
<%
//初始化变量
i=3;
j=1;
k=3;
for(i=1;i<=iRowCount;i++){
if((sDisPlayMethod.equals("2") && j<=iRowCount/2) || !sDisPlayMethod.equals("2")){
%>
excelData1 = xlBook.Sheets(1).Cells(<%=i+2%>,3)
Spreadsheet1.Cells(<%=i+2%>,3) = excelData1
<%
if(!sDisPlayMethod.equals("3")){
%>
excelData2 = xlBook.Sheets(1).Cells(<%=i+2%>,4)
Spreadsheet1.Cells(<%=i+2%>,4) = excelData2
<%
}
}
//分栏显示的
//j<=iRowCount/2*2此公式除去奇数部分的数据
if(sDisPlayMethod.equals("2") && j>iRowCount/2 && j<=iRowCount/2*2){
%>
excelData1 = xlBook.Sheets(1).Cells(<%=k%>,7)
excelData2 = xlBook.Sheets(1).Cells(<%=k%>,8)
Spreadsheet1.Cells(<%=k%>,7) = excelData1
Spreadsheet1.Cells(<%=k%>,8) = excelData2
<%
k++;
}
j++;
}
%>
xlApp.Application.Quit
Set xlApp = Nothing
btnShowFlag = "yes"
end sub
//导入到服务器
sub btnShow_onclick()
myFileName = form1.filename.value
if myFileName ="" then
alert "请先选一个文件!"
btnShowFlag = "no"
exit sub
end if
if btnShowFlag ="no" then
alert "请先进行预览操作!"
exit sub
end if
excelData1 = ""
excelData2 = ""
<%
//初始化变量
i=3;
j=1;
k=3;
for(i=1;i<=iRowCount;i++){
if((sDisPlayMethod.equals("2") && j<=iRowCount/2) || !sDisPlayMethod.equals("2")){
%>
excelData1 = excelData1 & "@" & Spreadsheet1.Cells(<%=i+2%>,2) & "@" & Spreadsheet1.Cells(<%=i+2%>,3)
<%
if(!sDisPlayMethod.equals("3")){
%>
excelData2 = excelData2 & "@" & Spreadsheet1.Cells(<%=i+2%>,2) & "@" & Spreadsheet1.Cells(<%=i+2%>,4)
<%
}
}
//分栏显示的
//j<=iRowCount/2*2此公式除去奇数部分的数据
if(sDisPlayMethod.equals("2") && j>iRowCount/2 && j<=iRowCount/2*2){
%>
excelData1 = excelData1 & "@" & Spreadsheet1.Cells(<%=k%>,6) & "@" & Spreadsheet1.Cells(<%=k%>,7)
excelData2 = excelData2 & "@" & Spreadsheet1.Cells(<%=k%>,6) & "@" & Spreadsheet1.Cells(<%=k%>,8)
<%
k++;
}
j++;
}
%>
form1.excelData1.value = excelData1
form1.excelData2.value = excelData2
form1.iRowCount.value = <%=iRowCount%>
form1.DisPlayMethod.value = <%=sDisPlayMethod%>
form1.submit()
end sub
</script>
</html>
<%@ include file="/IncludeEnd.jsp"%>