<object classid="clsid:0002E510-0000-0000-C000-000000000046" id="Spreadsheet1" codebase="file:D:\SoftWare_Bak\Office2000\office2000\msowc.cab" width="576" height="288">
<param name="HTMLURL" value="查询页URL地址">
<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>
<param name="HTMLURL" value="查询页URL地址">
<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>
已经将全部的查询结果用jsp取到js function里了。
<%
InventoryForm form=(InventoryForm)pageContext.findAttribute("InventoryForm");
List invList=form.getInventorySearch();
%>
<input type="button" value=" excel " class="Standard-ButtonCN" onclick="javascript:AutomateExcel('<%=invList%>');">
function AutomateExcel(invList)
{
.......
}
但是在js function里,怎样才能将List类型转换成二维数组呢,如果能转换成二位数组,直接赋值就可以了。请问,怎么做到呢?
<BODY>
点击下面的按钮,开始打开Excel并创建数据表
<SCRIPT LANGUAGE="VBScript">
Function CreateNamesArray()
' Create an array to set multiple values at once.
Dim saNames(5, 2)
saNames(0, 0) = "John" saNames(0, 1) = "Smith"
saNames(1, 0) = "Tom"
saNames(1, 1) = "Brown"
saNames(2, 0) = "Sue"
saNames(2, 1) = "Thomas"
saNames(3, 0) = "Jane"
saNames(3, 1) = "Jones"
saNames(4, 0) = "Adam"
saNames(4, 1) = "Johnson"
CreateNamesArray = saNames
End Function
</SCRIPT><SCRIPT LANGUAGE="JScript">
function AutomateExcel()
{ // Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application"); oXL.Visible = true; // Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet; // Add table headers going cell by cell.
oSheet.Cells(1, 1).Value = "First Name";
oSheet.Cells(1, 2).Value = "Last Name";
oSheet.Cells(1, 3).Value = "Full Name";
oSheet.Cells(1, 4).Value = "Salary"; // Format A1:D1 as bold, vertical alignment = center.
oSheet.Range("A1", "D1").Font.Bold = true;
oSheet.Range("A1", "D1").VerticalAlignment = -4108; //xlVAlignCenter // Create an array to set multiple values at once. // Fill A2:B6 with an array of values (from VBScript).
oSheet.Range("A2", "B6").Value = CreateNamesArray(); // Fill C2:C6 with a relative formula (=A2 & " " & B2).
var oRng = oSheet.Range("C2", "C6");
oRng.Formula = "=A2 & \" \" & B2"; // Fill D2:D6 with a formula(=RAND()*100000) and apply format.
oRng = oSheet.Range("D2", "D6");
oRng.Formula = "=RAND()*100000";
oRng.NumberFormat = "$0.00"; // AutoFit columns A:D.
oRng = oSheet.Range("A1", "D1");
oRng.EntireColumn.AutoFit(); // Manipulate a variable number of columns for Quarterly Sales Data.
DispalyQuarterlySales(oSheet); // Make sure Excel is visible and give the user control
// of Excel's lifetime.
oXL.Visible = true;
oXL.UserControl = true;
}function DispalyQuarterlySales(oWS)
{
var iNumQtrs, sMsg, iRet; // Number of quarters to display data for.
iNumQtrs = 4; // Starting at E1, fill headers for the number of columns selected.
var oResizeRange = oWS.Range("E1", "E1").Resize(1,iNumQtrs);
oResizeRange.Formula = "=\"Q\" & COLUMN()-4 & CHAR(10) & \"Sales\""; // Change the Orientation and WrapText properties for the headers.
oResizeRange.Orientation = 38;
oResizeRange.WrapText = true; // Fill the interior color of the headers.
oResizeRange.Interior.ColorIndex = 36; // Fill the columns with a formula and apply a number format.
oResizeRange = oWS.Range("E2", "E6").Resize(5,iNumQtrs);
oResizeRange.Formula = "=RAND()*100";
oResizeRange.NumberFormat = "$0.00"; // Apply borders to the Sales data and headers.
oResizeRange = oWS.Range("E1", "E6").Resize(6,iNumQtrs);
oResizeRange.Borders.Weight = 2; // xlThin // Add a Totals formula for the sales data and apply a border.
oResizeRange = oWS.Range("E8", "E8").Resize(1,iNumQtrs);
oResizeRange.Formula = "=SUM(E2:E6)";
// 9 = xlEdgeBottom
oResizeRange.Borders(9).LineStyle = -4119; //xlDouble
oResizeRange.Borders(9).Weight = 4; //xlThick // Add a Chart for the selected data. oResizeRange = oWS.Range("E2:E6").Resize(5,iNumQtrs);
var oChart = oWS.Parent.Charts.Add();
oChart.ChartWizard(oResizeRange, -4100, null, 2); // -4100 = xl3dColumn
oChart.SeriesCollection(1).XValues = oWS.Range("A2", "A6");
for (iRet = 1; iRet <= iNumQtrs; iRet++) {
oChart.SeriesCollection(iRet).Name = "=\"Q" + iRet + "\"";
}
oChart.Location(2, oWS.Name); // 2 = xlLocationAsObject // Move the chart so as not to cover your data.
oWS.Shapes("Chart 1").Top = oWS.Rows(10).Top;
oWS.Shapes("Chart 1").Left = oWS.Columns(2).Left;
}
</SCRIPT>
<P><INPUT id=button1 type=button value="创建 Excel" onclick="AutomateExcel"></P>
</BODY>
</HTML>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<!--#include file="../public/globalFunction.asp"-->
<title>数据输出</title>
<script language=javascript src="../js/common.js"></script>
</head>
<body class="dialogBody" leftmargin="5" topmargin="20" marginwidth="0" marginheight="0">
<%qrystr=request("qrystr")
set hx=server.CreateObject("hxsoft.comm")
If Request.ServerVariables("REQUEST_METHOD") = "POST" Then
set conn=server.CreateObject("Adodb.connection")
conn.Open hx.dbconnection()
sQuery=qrystr
set rst = conn.Execute(sQuery)
set session("objRS")=server.createobject("adodb.recordset")
session("objRS").CursorLocation=3
for i=1 to rst.fields.count-1
session("objRS").fields.append codename(rst.fields(i).name),rst.fields(i).type,rst.fields(i).DefinedSize, rst.fields(i).Attributes
next
session("objRS").LockType=3
session("objRS").CursorType=1
session("objRS").Open do while not rst.eof
session("objRS").AddNew
for i=1 to rst.fields.count-1
session("objRS")(i-1)=rst(i)
next
rst.movenext
loop
if not session("objRS").bof then session("objRS").movefirst
rst.close
menuName=conn.execute("select A0303 from A03 where A0302='" & menucode & "'")(0).value
hx.log "数据输出【" & menuName & "】",""&hx.info(8),""&session("uid")
response.redirect "../dts/default.asp"
end if
%>
<center><form action='DataModuleTemplateOut.asp' method=post>
<input type=hidden name="menucode" value="<%=menucode%>">
<input type=hidden name="qrystr" value="<%=qrystr%>">
<table border=1 width=340 bgcolor=#dedfde cellspacing=0 cellpadding=20 style=font-family:Verdana;font-size:8pt;border-collapse:collapse;>
<tr><td style="color:red"><center><span style="font-size:14px">警 告:</span></center><br>
数据输出功能是将您所选择的报表数据生成报表文件(*.csv,*.xls,*.mdb,*.xml)并提供下载,文件生成时间视您所选择的数据多少而定,它不仅仅消耗服务器资源,同时也消耗客户端资源,请慎用...<br><br>
<center><input type=image name="confirm" src="../images/confirm2.gif" onmouseover="confirm_over(this)" onmouseout="confirm_out(this)">
<input type=image onClick="window.close();return false;" src="../images/cancel2.gif" onmouseover="cancel_over(this)" onmouseout="cancel_out(this)" NAME="cancel">
</center></td>
</tr>
</table>
</form>
</center>
</body>
</html>