M
mzs0923
Unregistered / Unconfirmed
GUEST, unregistred user!
rs是前面程序取得的记录集。
下面的程序在客户端还可以,但是加上RUNAT="Server"就出错,为什么?
<SCRIPT LANGUAGE="JScript" RUNAT="Server">
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
oXL.Visible = false;
// 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 = "名称";
<%
dim I
I=2
do
while not rs.eof
%>
// Add the detail date
oSheet.Cells(<%=I%>, 1).Value = "<%=Rs("cal_name")%>";
<%
Rs.MoveNext
I=I+1
Loop
%>
// Format A11 as bold, vertical alignment = center.
oSheet.Range("A1", "L1").Font.Bold = true;
oSheet.Range("A1", "L1").VerticalAlignment = -4108;
//xlVAlignCenter
// AutoFit columns A.
oRng = oSheet.Range("A1", "L2");
oRng.EntireColumn.AutoFit();
// Make sure Excel is visible and give the user control
// of Excel's lifetime.
oXL.Visible = false;
oXL.UserControl = false;
oXL.Quit;
</script>
下面的程序在客户端还可以,但是加上RUNAT="Server"就出错,为什么?
<SCRIPT LANGUAGE="JScript" RUNAT="Server">
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
oXL.Visible = false;
// 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 = "名称";
<%
dim I
I=2
do
while not rs.eof
%>
// Add the detail date
oSheet.Cells(<%=I%>, 1).Value = "<%=Rs("cal_name")%>";
<%
Rs.MoveNext
I=I+1
Loop
%>
// Format A11 as bold, vertical alignment = center.
oSheet.Range("A1", "L1").Font.Bold = true;
oSheet.Range("A1", "L1").VerticalAlignment = -4108;
//xlVAlignCenter
// AutoFit columns A.
oRng = oSheet.Range("A1", "L2");
oRng.EntireColumn.AutoFit();
// Make sure Excel is visible and give the user control
// of Excel's lifetime.
oXL.Visible = false;
oXL.UserControl = false;
oXL.Quit;
</script>