欢迎光临
我们一直在努力

ASP与电子表格EXCEL的交互操作

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

here we go again with another sample for excel, this time we will be using asp to create a chart. you all

asked me for it, now here is the solution. thanks again for all your nice comments 🙂

first we set the type of script

<%@ language="vbscript" %>

make the object, and set the object to an excelsheet

dim myexcelchart

set myexcelchart = createobject("excel.sheet")

now lets write the rest of the script, see the comments

show or dont show excel to user, true or false

myexcelchart.application.visible = true

populate the cells

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

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

add the 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

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

myexcelchart.saveas "c:\chart.xls"

%>

now lets complete the html tags.

<html>

<head>

<title>myexcelchart</title>

</head>

<body>

</body>

</html>

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

<%@ language="vbscript" %>

<%

create object

set myexcelchart = createobject("excel.sheet")

show or dont show excel to user, true or false

myexcelchart.application.visible = true

populate the cells

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

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

add the 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

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 chart.xls

myexcelchart.saveas "c:\chart.xls"

%>

<html>

<head>

<title>myexcelchart</title>

</head>

<body>

</body>

</html>

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