Article ID: 264096
Article Last Modified on 8/23/2005
APPLIES TO
- Microsoft Office Web Components
- Microsoft Office Chart Component 9.0
- Microsoft Visual Basic 6.0 Professional Edition
This article was previously published under Q264096
SUMMARY
ChartGIF.exe is a sample file that illustrates how you can use server-side script with the Office 2000 and Office XP Web Chart Components to send a GIF representation of a chart as binary data to your client's browser. The advantage of the technique that ChartGIF.exe demonstrates is that you do not need to rely on session management for deleting temporary chart GIF files on the server. Instead, temporary chart GIF files are streamed to clients as binary data and are immediately deleted.
MORE INFORMATION
The following file is available for download from the Microsoft Download Center:
For additional information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to Obtain Microsoft Support Files from Online Services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help to prevent any unauthorized changes to the file.
How the Sample Works
ASP script generates a chart with the Office Web Component in memory (that is, Server.CreateObject("OWC.Chart").) When the chart contains all of the desired series and formatting, the ASP script calls the ExportPicture method of the ChartSpace to generate a temporary GIF representation of the chart. This GIF is then streamed to the client as binary data with Response.BinaryWrite.
BinaryWrite requires a single argument that is a variant array of unsigned one-byte characters. By using an ActiveX DLL developed with Microsoft Visual Basic, the ASP script can retrieve this array of bytes from the temporary GIF file and then pass the byte array as the argument to BinaryWrite. BinaryWrite streams the data to the client and the temporary GIF file is deleted. Please see the "References" section of this article for more information on this topic.
How to Use the Sample Files
- Create a new folder named ServerChart on your Web server. (Note: The Web server root is C:\Inetpub\wwwroot by default.)
Download and extract the contents of ChartGIF.exe to the folder you created. The following files are extracted:
File: Description: BinaryFileStream.vbp Visual Basic ActiveX DLL Project Object.cls Visual Basic Class Module BinaryFileStream.dll Compiled Visual Basic ActiveX DLL Data.mdb Access 2000 Database Containing the data that is charted Default.htm Client-side script for displaying charts ChartGif.asp Server-side script that creates charts and streams the charts to clients as binary data
- Register the Visual Basic ActiveX DLL on your Web server by using either of the following methods:
- Use Visual Basic 6.0, open the project BinaryFileStream.vbp, and then build the ActiveX DLL. -or-
Click Run on the Windows Start menu. Enter the following command line:
Regsvr32 "c:\inetpub\wwwroot\serverchart\binaryfilestream.dll"
and then click OK.
- Use Visual Basic 6.0, open the project BinaryFileStream.vbp, and then build the ActiveX DLL. -or-
- Start Internet Explorer and navigate to http://ServerName/ServerChart/Default.htm (where ServerName is the name of your Web server).
- Select a year in the drop-down box and note that a chart GIF is displayed on the Web page.
NOTE: If you want to use this sample with the Office XP Web Components, you must make a few modifications to the sample:
- Modify the ProgID in CHARTGIF.ASP from OWC.Chart to OWC10.ChartSpace.
Add the following line of code after the line that reads cht.HasLegend = True:
M_cspace.DisplayFieldButtons = False
Add the following line of code before the CreateObject("Scripting.FileSystemObject") call:
m_cspace.Charts.Delete 1
Problems with Server-Side Use
You should be aware that the Office 2000 Web Components are not designed for server-side use, and you may encounter problems if you use the components on a server with a high number of concurrent user connections. Many of these issue are addressed in the Office XP Web Components, and you should consider using the Office XP Web Components for large-scale server-side solutions.
For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
317316 INFO: Limitations of Office 2000 Web Components When Used Server-Side
REFERENCES
Programming Microsoft Office 2000 Web Components by Dave Stearns, ISBN 0-7356-0794-X
For more information about reading and displaying binary data with ASP, see the following Knowledge Base articles:
193998 HOWTO: Read and Display Binary Data in ASP
For more information, see the following Knowledge Base articles:
258187 OWebComp.exe Contains Scripting Samples for the Office Web Components
244049 HOWTO: Use Server-Side Charting to Generate Charts Dynamically
(c) Microsoft Corporation 2000, All Rights Reserved. Contributions by Dave Stearns, Microsoft Corporation.
Additional query words: ChartGIF binarywrite exportpicture webchart owc
Keywords: kbofficewebchart kbfile KB264096