I used to have some articles here to talk about the problem of generating dynamic charts in the ASP, but some methods mentioned in those articles have certain restrictions. If you need to install Office2000 or install OWC on the client, some will It is possible that there is no problem in intranet, but when accessible through the Internet, it may have a phenomenon that cannot work properly (this is related to SQL Server security settings). So how do we avoid these problems? There is a good way to convert the charts generated in the ASP to the image file to save on the server so that the user finally see the gif picture format chart, I want to watch any browser now watch GIF picture There is no problem when it is. :) Perhaps the only possible problem is how to process the problem of these temporary picture files, about this problem in the end we will discuss. Below we will use a specific example to illustrate this method. The program's test environment is: NT4.0 (SP5) IIS4.0 SQL Server 7.0 IE5.0, to run the following ASP program, save the following code COPY to a virtual directory in your virtual directory, Create a subdirectory TMP in this virtual directory (you may modify the path in the code to match your own path), set the read permissions in IIS, pay attention, in NT you must set this TMP directory at least Changed permissions. Create a PUBS DSN point to the PUBS database of SQL Server.
Here is the code: chart.asp <% Function ExportChartToGIF (cspace) Dim fso Dim sFilePath Dim sFileName 'generates a temporary file name set fso = CreateObject ( "Scripting.FileSystemObject") sFilePath = Request.ServerVariables ( "PATH_TRANSLATED") sFilePath = LEFT (sfilepath, "/")) sfilepath = sfilepath & "tmp/" sfilename = fso.getTempName () sfilename = sfilename & ".gif" set fso = nothing 'converts Chart into GIF files Save in temporary directory m_cspace.ExportPicture sFilePath & sFileName, "gif", 200, 150 'will be generated temporary Bild exist session in order to delete session ( "TC:" & sFilePath & sFileName) = sFilePath & sFileName ExportChartToGIF = sFileNameEnd FunctionSub BindChartToDSC (cspace , Svalues DIM CHT DIM Ser SET C = CSPACE.CONSTANTS CSPACE.CLEAR 'Binding Data Source Set Cspace.DataSource = DSC CSPACE.DATAMEMBER = SrsName Set Cht = Cspace.Charts.add () CHT. Haslegend = true cht.type = c.chcharttypepie s et ser = cht.SeriesCollection.Add () ser.SetData c.chDimCategories, 0, sCategories ser.SetData c.chDimValues, 0, sValues set dls = ser.DataLabelsCollection.Add () dls.HasPercentage = True dls.HasValue = FalseEnd Sub%>