谁能帮我解决这个问题?利用OWC在服务器上生成图像输出到客户端出错!

zhjzh_zjz 2004-03-07 10:25:15
我用OWC在服务器上生成图像,输出到客服端,产生以下错误:

Microsoft VBScript 编译器错误 错误 '800a03f6'

缺少 'End'

/iisHelp/common/500-100.asp,行242

Microsoft Office Web Components 9.0 错误 '800a03ec'

无法打开文件 c:\inetpub\wwwroot\test\1078668340437.gif 以进行导出。

/test/OwcTest.asp,行14



我已经将IIS下面改制站点设置为可写了。我将代码贴出如下:



<%

function ExportChartToGIF(objCSpace, strAbsFilePath, strRelFilePath){
var date=(new Date()).getTime();
var strFileName
strFileName=date+".gif"
objCSpace.ExportPicture(strAbsFilePath+"\\"+strFileName,"gif",650,400);
return strRelFilePath+"\/"+strFileName
}

function CleanUpGIF(GIFpath){
var objFS;
var objFolder;
var gif;
objFS=Server.CreateObject("Scripting.FileSystemObject");
objFolder=objFS.GetFolder(GIFpath);
for(gif in objFolder){
if(gif.Name.indexOf(".gif")!="-1"&&((new Date()).getTime()-(gif.DateLastModified).getTime>100))
objFS.DeleteFile(GIFpath+"\\"+gif.Name,True);
}
objFolder = nothing;
objFS = nothing;
}


%>


<%

var objChartSpace;
var objChart ;
var objSeries ;
var objConn ;
var objRS ;
var c ;
var series ;
var strChartAbsPath ;
var strChartRelPath ;
var strChartFile ;
var axis ;
var fnt;
var ax;

strChartAbsPath = Server.MapPath(".")
strChartRelPath = Server.MapPath(".")
objChartSpace = Server.CreateObject("OWC.Chart")
objChart = objChartSpace.Charts.Add();
c = objChartSpace.Constants;


objChart.Border.Color="red" ;
objChart.type=1;
objChart.HasLegend = true;
objChart.HasTitle=true;
objChart.Title.Caption ="利用office web component打造精品图表" ;
fnt=objChart.title.font;
fnt.name="宋体";
fnt.size=12;
fnt.bold=true;
fnt.color="red" ;

objConn = Server.CreateObject("ADODB.Connection") ;
objConn.Open("Provider=SQLOLEDB.1;Password=sa;Persist Security Info=True;User ID=sa;Initial Catalog=Northwind;Data Source=ZHJZH;User Id=sa;");
objRS = Server.CreateObject("ADODB.Recordset")
objRS.ActiveConnection = objConn ;
objRS.CursorType = adOpenStatic ;
objRS.CursorLocation = adUseClient ;
objRS.Open("select count(products.ProductName) as col,categories.CategoryName from products,categories where products.CategoryID=categories.CategoryID group by categories.CategoryName");
objChartSpace.DataSource = objRS ;
objChart.SetData(c.chDimSeriesNames,0,"CategoryName" );


for(objSeries in objChart.SeriesCollection){
objSeries.SetData(c.chDimCategories, 0, "CategoryName")
objSeries.SetData(c.chDimvalues, 0, "col" )
}

ax=objChart.Axes(c.chAxisPositionBottom)
ax.hastitle=true
ax.Title.Caption = "种类"
fnt=ax.title.font
fnt.name="宋体"
fnt.size=15
fnt.bold=true
fnt.color="blue"


ax=objChart.Axes(c.chCategoryAxis)
ax.hastitle=true
ax.Title.Caption = "数量"
fnt=ax.title.font
fnt.name="宋体"
fnt.size=15
fnt.bold=true
fnt.color="green"



strChartFile = ExportChartToGIF(objChartSpace, strChartAbsPath, strChartRelPath)

Response.Write ("<IMG SRC='" +strChartFile+"'>" +"<P>" )

CleanUpGIF(strChartAbsPath)
objRS.Close


objRS = nothing
objConn = nothing
objSeries = nothing
objChart = nothing
objChartSpace = nothing

%>


请大侠帮我看看是哪里出物了!谢谢!
...全文
109 14 打赏 收藏 转发到动态 举报
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
qunluo 2004-07-13
  • 打赏
  • 举报
回复
在浏览器中动态显示图形(利用owc)


大家在编写ASP程序的时候,可能要对各种指标以图形的方式显示出来。如果仅仅是柱状图,可以采用画表格的方法。许多投票程序多采用这种方法。如果是饼状图或从数据库中检索数据后再显示,就有些困难了.办法也有,自己可以封装excel来完成上述功能,或者用deiphi做一个activeform传入参数,或者用php来写,java也可以。当然,用一个比较成熟的图形组件来完成更好一些。microsoft office web compoent非常不错。我在开发一个项目的时候,用到了这个组件。

CHART.ASP程序。

<% Option Explicit %>
  <!--#include file="adovbs.inc"-->
  <HTML>
  <HEAD>
  <TITLE>柱状图的例子</TITLE>
  <%
  Function ExportChartToGIF(objCSpace, strAbsFilePath, strRelFilePath)
  Dim strFileName
  Randomize
  strFileName = Timer & Rnd & ".gif"
  objCSpace.ExportPicture strAbsFilePath & "\" & strFileName, "gif", 650, 400
  ExportChartToGIF = strRelFilePath & "/" & strFileName
  End Function

Sub CleanUpGIF(GIFpath)
  Dim objFS
  Dim objFolder
  Dim gif
  set objFS = Server.CreateObject("Scripting.FileSystemObject")
  set objFolder = objFS.GetFolder(GIFpath)
  for each gif in objFolder.Files
  if instr(gif.Name, ".gif") > 0 and
  DateDiff("n", gif.DateLastModified, now) > 10 then
  objFS.DeleteFile GIFpath & "\" & gif.Name, True
  end if
  next
  set objFolder = nothing
  set objFS = nothing
  End Sub

%>
  </HEAD>
  <BODY BGCOLOR="#FFFFFF">
  <div align="center">
  <br>
  <br>
  <%
  dim sj1,sj2
  sj1=Request.QueryString("s1")
  sj2=Request.QueryString("s2")

dim objChartSpace
  dim objChart
  dim objSeries
  dim objConn
  dim objRS
  dim c
  dim series
  dim strChartAbsPath
  dim strChartRelPath
  dim strChartFile
  dim axis

strChartAbsPath = Server.MapPath("/xjsi-web/dcss/chart")
  strChartRelPath = "/xjsi-web/dcss/chart"
  '设置组件

set objChartSpace = Server.CreateObject("OWC.Chart")
  set objChart = objChartSpace.Charts.Add
  set c = objChartSpace.Constants

objChartSpace.Border.Color="red"
  '以柱状图显示
  objchart.type=1
  objChart.HasLegend = True'是否显示图例
  objChartSpace.HasChartSpaceTitle=true '显示标题
  objChartSpace.ChartSpaceTitle.Caption ="柱状图的例子使用office web组件-http://www.ourfly.com/中文技术网站"
  set objConn = Server.CreateObject("ADODB.Connection")
  objConn.Open application("strconn")
  set objRS = Server.CreateObject("ADODB.Recordset")
  set objRS.ActiveConnection = objConn
  objRS.CursorType = adOpenStatic
  objRS.CursorLocation = adUseClient
  objRS.Open "select dwsj,sum(jfrs) as jfrs
  from dcss_do_jfgcfxb where dwsj>='"&sj1&"' and dwsj<'"&sj2&"'
  group by dwsj order by dwsj asc"

set objChartSpace.DataSource = objRS
  '显示图例内容
  objChart.SetData c.chDimSeriesNames, 0, "jfrs"
  for each objSeries in objChart.SeriesCollection
  objSeries.SetData c.chDimCategories, 0, "dwsj"
  objSeries.SetData c.chDimValues, 0, "jfrs"
  next

for each axis in objChart.Axes
  axis.HasTitle = True
  if axis.Type = c.chCategoryAxis then
  axis.Title.Caption = "月份"
  else
  axis.Title.Caption = "人数"
  end if
  next

strChartFile = ExportChartToGIF(objChartSpace, strChartAbsPath, strChartRelPath)
  Response.Write "<IMG SRC=""" & strChartFile & """>" & "<P>"
  CleanUpGIF strChartAbsPath

objRS.Close
  set objRS = nothing
  set objConn = nothing
  set objSeries = nothing
  set objChart = nothing
  set objChartSpace = nothing
  %>
  </div>
  </BODY>
  </HTML>
  使用这个组件的注意事项:
  1。在office2000的光盘上,有一个msowc.msi的可执行文件.OK
  2。建议大家用visual interdev6.0开发,代码的自动提示功能此时会发挥出极大的作用。

**********************
我是没试过,找来的!没办法!希望能够帮助到你!
online 2004-07-13
  • 打赏
  • 举报
回复
test目录添加iuser这个用户
zhjzh_zjz 2004-07-13
  • 打赏
  • 举报
回复
我已经加分了,高手继续来帮忙。
xzhy80 2004-07-12
  • 打赏
  • 举报
回复
up
pongid2353345 2004-04-14
  • 打赏
  • 举报
回复
顶!!大家帮忙看看啊,楼主,怎么感觉这贴子是我开的啊!
哈哈,明天还是自己开一个吧,就是怕没人回答!呵呵
liuyu202 2004-04-13
  • 打赏
  • 举报
回复
internet信息服务》打开程序的目录或是文件》点击鼠标右键》目录安全性》在这个选项卡中,把匿名登录去掉(不要打勾)!
pongid2353345 2004-04-13
  • 打赏
  • 举报
回复
不明白,我是用visual interdev 建的工程(project),所以一直都没有设置过它共享的属性!
这个虚拟目录我找到了,可是查看这个文件的属性时在WEB共享时为空!
我用绝对路径做输出的文件时,没有问题可以显示图片,可是一改成虚拟路径就不行了!
这是怎么回事??这个权限怎么改???
aspnetxp 2004-04-13
  • 打赏
  • 举报
回复
c:\inetpub\wwwroot\test\1078668340437.gif
目录权限的问题

将虚拟目录设为完全共享
fkphp 2004-04-13
  • 打赏
  • 举报
回复
NTFS目录属性everyone拥有所有权限
pongid2353345 2004-04-13
  • 打赏
  • 举报
回复
完全共享???
不明白??
能否说详细点?
到底把那个设为共享啊?现在的状态是project无共享!
pongid2353345 2004-04-13
  • 打赏
  • 举报
回复
好像还是不行!
:(
online 2004-04-12
  • 打赏
  • 举报
回复
c:\inetpub\wwwroot\test\1078668340437.gif
目录权限的问题

将这个目录设为完全共享
pongid2353345 2004-04-12
  • 打赏
  • 举报
回复
对了,楼主,你那有关于mschart的属性的资料吗!
比方说输出曲线的颜色粗细啊等等!
我想参考一下,我这没有!
有的话能发给我一份吗??
^_^,谢谢你了!
pongid2353345@163.com
pongid2353345 2004-04-12
  • 打赏
  • 举报
回复
呵呵,我也有这种问题!
我的也是这样,我把IIS设置过了,也可写入!
在输出时利用虚拟目录,可就是显示不了!不明白为什么!
sFname="d:\Project1\Project1_Local\owc\chart.gif" '实际路径
vfname="/project/owc/chart.gif" '虚拟路径
chart.ExportPicture sFname, "gif",800,400
%>
<img align="center" border="0" src=<%=vFname%>>
可就是不行啊!
帮你顶!

28,391

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧