从服务器中读取文件如何直接打开,如何用asp读取Excel文件(比较全面)

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

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.

MyExcelChart

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

' 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"

%>

MyExcelChart
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值