navigation
a webmaster learning community
     Home    Register     Search      Help      Login    
Sponsors

Shopping Cart Software
Ecommerce software integrated into Frontpage, Dreamweaver and Golive templates. No monthly fees and available in ASP and PHP versions.

Website Templates
We also have a wide selection of Dreamweaver, Expression Web and Frontpage templates as well as webmaster tools and CSS layouts.

Frontpage website templates
Creative Website Templates for FrontPage, Dreamweaver, Flash, SwishMax

Search Forums
 

Advanced search
Recent Posts

 Todays Posts
 Most Active posts
 Posts since last visit
 My Recent Posts
 Mark posts read

Microsoft MVP

 

Displaying an Excel Chart using ASP

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
Printable Version 

All Forums >> Web Development >> ASP and Database >> Displaying an Excel Chart using ASP
Page: [1]
 
krazyak

 

Posts: 5
Joined: 7/1/2005
Status: offline

 
Displaying an Excel Chart using ASP - 7/1/2005 9:24:32   
Hello, I am new to this forum and have not actively used one before but have found many useful ideas and answers by reading them.

My problem is that I found code to use Excel to display a chart on a Web Page using ASP ( http://www.devx.com/getHelpOn/10MinuteSolution/20506 ). I have been trying to get the sample code to work and cannot get past an error that is occurring on the line that saves the jpg chart image to a folder on the server.

The line is crt.Chart.Export Server.MapPath("/SJKTest/junk/") & "\" & mstrFileName, "jpg".

The error I am receiving is Microsoft VBScript runtime error '800a03ec' Unknown runtime error .

Any suggestions or help would be much appreciated. Thanks.
rdouglass

 

Posts: 9202
From: Biddeford, ME USA
Status: offline

 
RE: Displaying an Excel Chart using ASP - 7/1/2005 9:44:59   
Hi and Welcome to OutFront.

1. Do you have Excel installed on the server?

2. Can you post the code you're using?

_____________________________

Don't take you're eye off your final destination.

ASP Checkbox Function Tutorial.

(in reply to krazyak)
krazyak

 

Posts: 5
Joined: 7/1/2005
Status: offline

 
RE: Displaying an Excel Chart using ASP - 7/1/2005 9:49:06   
I had one of the Network guys install Office on the Server. He installed OFFICE 2003 and Excel is there and working.
My code follows:

<%@ LANGUAGE="VBSCRIPT" %>
<%
Option Explicit
'--------------- WEB SITE: YOUR WEB SITE NAME ----------------
' File Name: 10MinChart.asp
'
' Purpose:
' Genearate a Chart using Microsoft Excel in an ASP page
'
' Arguments:
' Comments
'
' Author: Rama Ramachandran
' Imperium Solutions
' http://www.imperium.com
' Internet: rama@imperium.com
'
' Date Created:
' 8/29/2000
'
' Modification History:
'
'----------------------------------------------------------------------

Dim mintPass, mstrFileName
Dim i ' misc variable
Randomize Timer

mintPass = Request("pass")
Select Case Int(mintPass)
Case 1
HandleRepeatVisit
End Select


%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
<TITLE>Create "Excel"lent Charts with ASP</TITLE>
<STYLE TYPE="text/css">
<!-- //
BODY {
font-family: Verdana, Arial, Helvetica, Sans Serif;
font-size: 10pt;
}
TH {
font-family: Verdana, Arial, Helvetica, Sans Serif;
font-size: 10pt;
font-weight: bold;
background-color: #DDDDDD;
}

TD {
font-family: Verdana, Arial, Helvetica, Sans Serif;
font-size: 10pt;
background-color: #EEEEEE;
}

// -->
</STYLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<BASEFONT FACE="Verdana, Arial, Helvetica, Sans Serif" SIZE="2">

<FORM ACTION="ExcelChart.asp" METHOD="post">
<INPUT TYPE="hidden" NAME="pass" VALUE="1">

<TABLE BORDER="0" CELLPADDING="5" CELLSPACING="2" WIDTH="750">
<TR>
<TD ALIGN="CENTER" VALIGN="TOP" COLSPAN="3"><STRONG>Create "Excel" lent Charts with ASP!</STRONG></TD></TR>
<TR>
<TD ALIGN="CENTER" VALIGN="TOP" COLSPAN="3"><STRONG>- by Rama Ramachandran</STRONG>  
<FONT FACE="ARIAL" SIZE="1"><A HREF="file:///M|/Web/ASP/ChartExample/10MinChart.Zip">Get the Code for this page here</A>.</FONT>
</TD></TR>
<TR>
<TD ALIGN="CENTER" VALIGN="TOP">Stock Price for:</TD>
<TD ALIGN="LEFT" VALIGN="TOP"><INPUT TYPE="text" NAME="co" SIZE="25" VALUE="Microsoft"></TD>
<TD ALIGN="CENTER" VALIGN="MIDDLE" ROWSPAN="13">
<% If mstrFileName <> "" Then
Response.write "<IMG SRC=""/SJKTest/junk/" & mstrFileName & """>"
Else
Response.write "<IMG SRC=""spacer.gif"" WIDTH=""100"" HEIGHT=""1"" BORDER=""0"">"
End If
%>
</TD>
</TR>
<%
For i = 1 to 12 %>
<TR>
<TD ALIGN="LEFT" VALIGN="TOP">Date: <%= FormatDateTime(i & "/01/99", 2)%></TD>
<TD ALIGN="LEFT" VALIGN="TOP">$ :<INPUT TYPE="text" NAME="v<%= i%>" VALUE="<% If mintPass=1 Then Response.Write Request("v" & i) Else Response.Write Int((100)*Rnd+1) End If %>" SIZE="10" MAXLENGTH="5"></TD>
</TR>
<%
Next %>
</TABLE>
<INPUT TYPE="submit" NAME="cmd" VALUE=" Generate Chart">
</FORM>
</BODY>
</HTML>
<%
Sub HandleRepeatVisit()
Dim xlapp ' Our Excel App
Dim wb ' Our Workbook within the Excel App
Dim ws ' Our Worksheet within the Workbook
Dim crt ' The chart object
Dim SourceRange ' The Source Range for the chart object

Const xlWorkSheet = -4167
Const xlLineMarkers = 65

' -- Create an instance of Excel Application
Set xlapp = Server.CreateObject("Excel.Application")
' -- Create a new workbook
Set wb = xlapp.Workbooks.Add(xlWorksheet)
' -- Grab the first worksheet of the new workbook
Set ws = wb.Worksheets(1)
' -- Insert the data the user requested
' -- First, the title
ws.Range("A1").Value = Request("co") ' -- defaults to "Microsoft"
' -- Then the data in two vertical columns
For i = 1 To 12
ws.Range("A" & i + 1).Value = FormatDateTime(i & "/01/99", 2)
ws.Range("B" & i + 1).Formula = "=" & Request("v" & i)
Next

' -- Set our source range
Set SourceRange = ws.Range("A2:B13")
' -- Create a new Chart Object
Set crt = ws.ChartObjects.Add(20, 20, 300, 200)
' -- Generate the Chart using the ChartWizard
' -- Syntax is:
' -- crt.Chart.ChartWizard Source:=SourceRange, gallery:=xlLine(4), PlotBy:=xlColumns(default), _
' -- categorylabels:=1, serieslabels:=0, HasLegend:=2, Title:="Company Stock Value"

crt.Chart.ChartWizard SourceRange, 4, , 2, 1, 0, 2, Request("co") & " Stock Value"
' -- Configure the Chart
crt.Chart.ChartType = xlLineMarkers
crt.Chart.SeriesCollection(1).Name = "=Sheet1!R1C1"
crt.Chart.HasTitle = True
crt.Chart.Axes(1, 1).HasTitle = True
crt.Chart.Axes(1, 1).AxisTitle.Characters.Text = "Months"
crt.Chart.Axes(2, 1).HasTitle = True
crt.Chart.Axes(2, 1).AxisTitle.Characters.Text = "Stock Price"

' -- Determine the name to save this chart as. Use the current Seconds value, overwriting previous
' -- ones
mstrFileName = "junk" & Second(Now()) & ".jpg"
' -- Save the chart on web server
Response.Write("mstrFileName = " & mstrFileName) & "<br>"
Response.Write("Server.MapPath = " & Server.MapPath("/SJKTest/junk/") & "\" & mstrFileName)
crt.Chart.Export Server.MapPath("/SJKTest/junk/") & "\" & mstrFileName, "jpg"


' -- Fool Excel into thinking the Workbook is saved
wb.Saved = True
' -- Set all objects back to nothing
Set crt = Nothing
Set wb = Nothing
' -- Quit Excel to conserve resources
xlapp.Quit
Set xlapp = Nothing

' -- Make sure the Image is not cached but is loaded fresh from the web server
Response.AddHeader "expires","0"
Response.AddHeader "pragma", "no-cache"
Response.AddHeader "cache-control","no-cache"

End Sub
%>

Thanks for the help

(in reply to rdouglass)
krazyak

 

Posts: 5
Joined: 7/1/2005
Status: offline

 
RE: Displaying an Excel Chart using ASP - 7/1/2005 10:35:44   
I did more research and found that it is a sever rights issue. The ASP account (IUSR_machinename) needs to have WRITE access to the directory that I am trying to export to. I will give this a try as soon as I can get ahold of one of the Network guys.

Thanks for the help, now I have a place to go to try and find answers to problems, and maybe answer some too.

Thanks again.:)

(in reply to krazyak)
Page:   [1]

All Forums >> Web Development >> ASP and Database >> Displaying an Excel Chart using ASP
Page: [1]
Jump to: 1





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts