×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

output an excel chart using ASP?

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

RE: output an excel chart using ASP?

I was having the same problem - the trick is, that you can't place a title until after the chart is made:

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources