📄 asp与电子表格excel的交互操作 2.htm
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- saved from url=(0055)http://www.51base.com/article/view_article.asp?id=48604 -->
<HTML lang=zh-cn><HEAD><TITLE>NB联盟</TITLE>
<META content="text/html; charset=gb2312" http-equiv=Content-Type><LINK
href="NB联盟12.files/style.css" rel=stylesheet>
<META content="MSHTML 5.00.2614.3500" name=GENERATOR></HEAD>
<BODY><!-- start page body -->
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 class=td id=position
width=773>
<TBODY>
<TR>
<TD class=shadow colSpan=2 height=20 width=262> <A
href="http://www.51base.com/"><IMG border=0
src="NB联盟12.files/logo1.gif"></A> </TD>
<TD align=right width=505>
<P align=left></P></TD></TR></TBODY></TABLE>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=main width=770>
<TBODY>
<TR>
<TD class=tdlbr vAlign=top>
<TABLE align=center border=0 cellPadding=0 cellSpacing=0 id=welcome
style="TABLE-LAYOUT: fixed" width="98%">
<TBODY>
<TR>
<TD style="TABLE-LAYOUT: fixed; WORD-BREAK: break-all"
vAlign=top><FONT color=red><B>文章标题</B></FONT><FONT color=red><B>:
ASP与电子表格EXCEL的交互操作 </B></FONT>
<HR noShade SIZE=1>
<BR>Here we go again with another sample for Excel, this time we
will be using ASP to create a chart. You all <BR>asked me for it,
now here is the solution. Thanks again for all your nice comments
:)<BR><BR>First we set the type of script<BR><BR><%@
LANGUAGE="VBSCRIPT" %><BR><BR>Make the object, and set the object
to an Excelsheet<BR><BR>Dim MyExcelChart<BR>Set MyExcelChart =
CreateObject("Excel.Sheet")<BR><BR>Now lets write the rest of the
script, see the comments<BR><BR>' show or dont show excel to user,
TRUE or FALSE<BR>MyExcelChart.Application.Visible = True<BR><BR>'
populate the cells<BR>MyExcelChart.ActiveSheet.Range("B2:k2").Value
= Array<BR>("Week1", "Week2", "Week3", "Week4", "Week5", "Week6",
"Week7", "Week8", "Week9",
"Week10")<BR>MyExcelChart.ActiveSheet.Range("B3:k3").Value =
Array<BR>("67", "87", "5", "9", "7", "45", "45", "54", "54",
"10")<BR>MyExcelChart.ActiveSheet.Range("B4:k4").Value =
Array<BR>("10", "10", "8", "27", "33", "37", "50", "54", "10",
"10")<BR>MyExcelChart.ActiveSheet.Range("B5:k5").Value =
Array<BR>("23", "3", "86", "64", "60", "18", "5", "1", "36",
"80")<BR>MyExcelChart.ActiveSheet.Cells(3,1).Value="Internet
Explorer"<BR>MyExcelChart.ActiveSheet.Cells(4,1).Value="Netscape"<BR>MyExcelChart.ActiveSheet.Cells(5,1).Value="Other"<BR><BR>'
Select the contents that need to be in the
chart<BR>MyExcelChart.ActiveSheet.Range("b2:k5").Select<BR> <BR>'
Add the chart<BR>MyExcelChart.Charts.Add<BR>' Format the chart, set
type of chart, shape of the bars, show title, get the data for the
chart, show <BR>datatable, show legend
<BR>MyExcelChart.activechart.ChartType =
97<BR>MyExcelChart.activechart.BarShape
=3<BR>MyExcelChart.activechart.HasTitle =
True<BR>MyExcelChart.activechart.ChartTitle.Text = "Visitors log for
each week shown in browsers
percentage"<BR>MyExcelChart.activechart.SetSourceData
MyExcelChart.Sheets("Sheet1").Range("A1:k5"),1<BR>MyExcelChart.activechart.Location
1<BR>MyExcelChart.activechart.HasDataTable =
True<BR>MyExcelChart.activechart.DataTable.ShowLegendKey =
True<BR><BR>' Save the the excelsheet to
excelface<BR>MyExcelChart.SaveAs "c:\chart.xls"<BR>%><BR><BR>Now
lets complete the HTML
tags.<BR><BR><HTML><BR><HEAD><BR><TITLE>MyExcelChart</TITLE><BR></HEAD><BR><BODY><BR></BODY><BR></HTML><BR><BR>This
completes yer ASP page, look below for the complete code of
myexcelchart.asp<BR><BR><%@ LANGUAGE="VBSCRIPT"
%><BR><%<BR>' Create Object <BR>Set MyExcelChart =
CreateObject("Excel.Sheet")<BR><BR>' show or dont show excel to
user, TRUE or FALSE<BR>MyExcelChart.Application.Visible =
True<BR><BR>' populate the cells
<BR>MyExcelChart.ActiveSheet.Range("B2:k2").Value =
Array<BR>("Week1", "Week2", "Week3", "Week4", "Week5", "Week6",
"Week7", "Week8", "Week9",
"Week10")<BR>MyExcelChart.ActiveSheet.Range("B3:k3").Value =
Array<BR>("67", "87", "5", "9", "7", "45", "45", "54", "54",
"10")<BR>MyExcelChart.ActiveSheet.Range("B4:k4").Value =
Array<BR>("10", "10", "8", "27", "33", "37", "50", "54", "10",
"10")<BR>MyExcelChart.ActiveSheet.Range("B5:k5").Value =
Array<BR>("23", "3", "86", "64", "60", "18", "5", "1", "36",
"80")<BR>MyExcelChart.ActiveSheet.Cells(3,1).Value="Internet
Explorer"<BR>MyExcelChart.ActiveSheet.Cells(4,1).Value="Netscape"<BR>MyExcelChart.ActiveSheet.Cells(5,1).Value="Other"<BR><BR>'
Select the contents that need to be in the
chart<BR>MyExcelChart.ActiveSheet.Range("b2:k5").Select<BR> <BR>'
Add the chart<BR>MyExcelChart.Charts.Add<BR>' Format the chart, set
type of chart, shape of the bars, show title, get the data for the
chart, show <BR>datatable, show legend
<BR>MyExcelChart.activechart.ChartType =
97<BR>MyExcelChart.activechart.BarShape
=3<BR>MyExcelChart.activechart.HasTitle =
True<BR>MyExcelChart.activechart.ChartTitle.Text = "Visitors log for
each week shown in browsers
percentage"<BR>MyExcelChart.activechart.SetSourceData
MyExcelChart.Sheets("Sheet1").Range("A1:k5"),1<BR>MyExcelChart.activechart.Location
1<BR>MyExcelChart.activechart.HasDataTable =
True<BR>MyExcelChart.activechart.DataTable.ShowLegendKey =
True<BR><BR><BR>' Save the the excelsheet to
chart.xls<BR>MyExcelChart.SaveAs
"c:\chart.xls"<BR><BR><BR>%><BR><HTML><BR><HEAD><BR><TITLE>MyExcelChart</TITLE><BR></HEAD><BR><BODY><BR></BODY><BR></HTML>
<BR></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE><BR>
<TABLE align=center border=0 cellPadding=2 cellSpacing=0 id=footer width=770>
<TBODY>
<TR>
<TD align=middle class=tdt>
<P align=center></P></TD></TR></TBODY></TABLE><BR></BODY></HTML>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -