output an excel chart using ASP?
output an excel chart using ASP?
(OP)
Hi,
I have tried to create an excel chart from an asp page on my intranet. However certain methods can't be used.
unable to set the Title.
Everything else seems to work out fine.
Any idea of a cause or solution.
Thanks in advance
Dim xlApp
Dim xlBook
Dim xlSheet
Dim MyExcelChart
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
Set MyExcelChart = xlBook.Charts.Add
' show or dont show excel to user, TRUE or FALSE
'MyExcelChart.Application.Visible = True
' populate the cells
xlsheet.Range("B2:k2").Value = Array("Week1", "Week2", "Week3", "Week4", "Week5", "Week6", "Week7", "Week8", "Week9", "Week10")
xlsheet.Range("B3:k3").Value = Array("67", "87", "5", "9", "7", "45", "45", "54", "54", "10")
xlsheet.Range("B4:k4").Value = Array("10", "10", "8", "27", "33", "37", "50", "54", "10", "10")
xlsheet.Range("B5:k5").Value = Array("23", "3", "86", "64", "60", "18", "5", "1", "36", "80")
xlsheet.Cells(3,1).Value="Internet Explorer"
xlsheet.Cells(4,1).Value="Netscape"
xlsheet.Cells(5,1).Value="Other"
with MyExcelChart
' Format the chart, set type of chart, shape of the bars, show title, get the data for the chart, show datatable, show legend
.ChartType = 97
.BarShape = 0
-------------------------
' this gives an error'.HasTitle = True
'.ChartTitle.Text = "Visitors log for each week shown in browsers percentage"
-------------------
.SetSourceData xlbook.Sheets("Sheet4").Range("A1:k5"),1
.Location 1
.HasDataTable = True
.DataTable.ShowLegendKey = True
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "sDens"
end with
' Save the the excelsheet to chart.xls
xlsheet.SaveAs "c:\charts2.xls"
xlbook.close
xlapp.quit
I have tried to create an excel chart from an asp page on my intranet. However certain methods can't be used.
unable to set the Title.
Everything else seems to work out fine.
Any idea of a cause or solution.
Thanks in advance
Dim xlApp
Dim xlBook
Dim xlSheet
Dim MyExcelChart
Set xlApp = CreateObject("Excel.Application")
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Worksheets.Add
Set MyExcelChart = xlBook.Charts.Add
' show or dont show excel to user, TRUE or FALSE
'MyExcelChart.Application.Visible = True
' populate the cells
xlsheet.Range("B2:k2").Value = Array("Week1", "Week2", "Week3", "Week4", "Week5", "Week6", "Week7", "Week8", "Week9", "Week10")
xlsheet.Range("B3:k3").Value = Array("67", "87", "5", "9", "7", "45", "45", "54", "54", "10")
xlsheet.Range("B4:k4").Value = Array("10", "10", "8", "27", "33", "37", "50", "54", "10", "10")
xlsheet.Range("B5:k5").Value = Array("23", "3", "86", "64", "60", "18", "5", "1", "36", "80")
xlsheet.Cells(3,1).Value="Internet Explorer"
xlsheet.Cells(4,1).Value="Netscape"
xlsheet.Cells(5,1).Value="Other"
with MyExcelChart
' Format the chart, set type of chart, shape of the bars, show title, get the data for the chart, show datatable, show legend
.ChartType = 97
.BarShape = 0
-------------------------
' this gives an error'.HasTitle = True
'.ChartTitle.Text = "Visitors log for each week shown in browsers percentage"
-------------------
.SetSourceData xlbook.Sheets("Sheet4").Range("A1:k5"),1
.Location 1
.HasDataTable = True
.DataTable.ShowLegendKey = True
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory, xlPrimary).AxisTitle.Characters.Text = "Time"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "sDens"
end with
' Save the the excelsheet to chart.xls
xlsheet.SaveAs "c:\charts2.xls"
xlbook.close
xlapp.quit





RE: output an excel chart using ASP?
'--- Create a chart
Set Or1Chart = Charts.Add
Or1Chart.ChartType = xlColumnClustered
Or1Chart.Location xlLocationAsNewSheet
Or1Chart.Name = "Orlando 1 Chart"
'--- Insert a series
Or1Chart.SeriesCollection.NewSeries
Or1Chart.SeriesCollection(1).XValues = WeekDays
Or1Chart.SeriesCollection(1).Values = arrValues
Or1Chart.SeriesCollection(1).Name = "MENS"
Or1Chart.SeriesCollection(1).Select
With Selection.Interior
.ColorIndex = 9
.Pattern = xlSolid
End With
'--- Set the title
With Or1Chart
.HasTitle = True
.ChartTitle.Characters.Text = "Orlando"
End With