欢迎光临
我们一直在努力

如何用ASP建立图表

建站超值云服务器,限时71元/月

现在我们针对excel举另外一个例子,大家都询问如何用asp建立图表的问题,以下就是解决方案

first we set the type of script

首先设定脚本类型

<%@ language="vbscript" %>

make the object, and set the object to an excelsheet

建立excelsheet对象

dim myexcelchart

set myexcelchart = createobject("excel.sheet")

show or dont show excel to user, true or false

是否让用户看到excel表格,真或假

myexcelchart.application.visible = true

populate the cells

添excel表格

myexcelchart.activesheet.range("b2:k2").value = array("week1", "week2", "week3", "week4", "week5", "week6", "week7", "week8", "week9", "week10")

myexcelchart.activesheet.range("b3:k3").value = array("67", "87", "5", "9", "7", "45", "45", "54", "54", "10")

myexcelchart.activesheet.range("b4:k4").value = array("10", "10", "8", "27", "33", "37", "50", "54", "10", "10")

myexcelchart.activesheet.range("b5:k5").value = array("23", "3", "86", "64", "60", "18", "5", "1", "36", "80")

myexcelchart.activesheet.cells(3,1).value="internet explorer"

myexcelchart.activesheet.cells(4,1).value="netscape"

myexcelchart.activesheet.cells(5,1).value="other"

select the contents that need to be in the chart

在excel表中选择要在图表(chart)中显示的数据

myexcelchart.activesheet.range("b2:k5").select

add the chart

加载图表(chart)

myexcelchart.charts.add

format the chart, set type of chart, shape of the bars, show title, get the data for the chart, show datatable, show legend

初始化图表(chart),设定图表类型,棒图的形状,要显示的标题,取得要作图的数据,显示数据表,显示图表

myexcelchart.activechart.charttype = 97

myexcelchart.activechart.barshape =3

myexcelchart.activechart.hastitle = true

myexcelchart.activechart.charttitle.text = "visitors log for each week shown in browsers percentage"

myexcelchart.activechart.setsourcedata myexcelchart.sheets("sheet1").range("a1:k5"),1

myexcelchart.activechart.location 1

myexcelchart.activechart.hasdatatable = true

myexcelchart.activechart.datatable.showlegendkey = true

save the the excelsheet to excelface

存入excel表

myexcelchart.saveas "c:\chart.xls"

%>

now lets complete the html tags.

下面是html代码

<html>

<head>

<title>myexcelchart</title>

</head>

<body>

</body>

</html>

this completes yer asp page, look below for the complete code of myexcelchart.asp

下面是源程序myexcelchart.asp的完整代码

<%@ language="vbscript" %>

<%

set myexcelchart = createobject("excel.sheet")

myexcelchart.application.visible = true

myexcelchart.activesheet.range("b2:k2").value = array("week1", "week2", "week3", "week4", "week5", "week6", "week7", "week8", "week9", "week10")

myexcelchart.activesheet.range("b3:k3").value = array("67", "87", "5", "9", "7", "45", "45", "54", "54", "10")

myexcelchart.activesheet.range("b4:k4").value = array("10", "10", "8", "27", "33", "37", "50", "54", "10", "10")

myexcelchart.activesheet.range("b5:k5").value = array("23", "3", "86", "64", "60", "18", "5", "1", "36", "80")

myexcelchart.activesheet.cells(3,1).value="internet explorer"

myexcelchart.activesheet.cells(4,1).value="netscape"

myexcelchart.activesheet.cells(5,1).value="other"

myexcelchart.activesheet.range("b2:k5").select

myexcelchart.charts.add

myexcelchart.activechart.charttype = 97

myexcelchart.activechart.barshape =3

myexcelchart.activechart.hastitle = true

myexcelchart.activechart.charttitle.text = "visitors log for each week shown in browsers percentage"

myexcelchart.activechart.setsourcedata myexcelchart.sheets("sheet1").range("a1:k5"),1

myexcelchart.activechart.location 1

myexcelchart.activechart.hasdatatable = true

myexcelchart.activechart.datatable.showlegendkey = true

myexcelchart.saveas "c:\chart.xls"

%>

<html>

<head>

<title>myexcelchart</title>

</head>

<body>

</body>

</html>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 如何用ASP建立图表
分享到: 更多 (0)