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>
