Call Excel to draw data graphs in ASP

Source: Internet
Author: User
Tags count
excel| Data | Charts in ASP to call Excel to draw data graphs, the advantages are many, the most prominent is that can output many forms of graphics (a total of 72 kinds). Here's a generic ASP method I wrote to call Excel to draw a data graph.

<%
' Graphical output of the data
' DataArray two dimensional array
' Virtualfilepath output image filename (virtual path)
' Ntype Display Type
Dim Inittype
Sub ExportPicture (Dataarray,virtualfilepath,ntype)
Dim excelapp ' as New Excel. Application
Dim excelwbk ' as Excel. Workbook
Dim Excelcht ' as Excel. Chart
Dim Excelsht ' as Excel. Worksheet
Dim Idx,idy,ftype,useddata,totalcount,count:count = 1
On Error Resume Next

Set excelapp = Server.CreateObject ("Excel.Application")
Set excelwbk = excelapp. Workbooks.Add ()
Set Excelcht = excelwbk. Charts.add ()
Set Excelsht = excelwbk. Worksheets.add ()
If UCase (Right (virtualfilepath,4) = ". JPG "Or UCase (Right (virtualfilepath,4)) =". JPEG "Then
ftype = "JPG"
Else
ftype = "gif"
End If
Inittype = Ntype
For Idx=lbound (dataarray,1) to UBound (dataarray,1)
For Idy=lbound (dataarray,2) to UBound (dataarray,2)
Excelsht. Cells (idx+1,idy+1) = DataArray (Idx,idy)
Next
Next

Set Useddata = Excelsht.usedrange
Excelcht. SeriesCollection.Add Useddata

Excelcht. HasLegend = True
Excelcht. HasTitle = True
' Excelcht. Charttitle.caption = "Departmental Staff distribution map"
Excelcht. ApplyCustomType ntype
Excelcht. Export Server.MapPath (Virtualfilepath), ftype
Excelsht. Close False
EXCELWBK. Close False
Set Useddata = Nothing
Set Excelcht = Nothing
Set excelwbk = Nothing
Set excelapp = Nothing
End Sub
%>
<select name= "sel" onchange= "changepict ()" >
<option value= "Wuyi" > Two-dimensional column chart </Option><!--xlcolumnclustered
<option value= ">xlColumnStacked</Option>"
<option value= ">xlColumnStacked100</Option>-->"
<option value= "Si" > three-dimensional columnar chart </Option><!--xl3dcolumnclustered
<option value= ">xl3DColumnStacked</Option>"
<option value= ">xl3DColumnStacked100</Option>-->"
<option value= > Two-dimensional bar chart </Option><!--xlbarclustered
<option value= ">xlBarStacked</Option>"
<option value= ">xlBarStacked100</Option>-->"
<option value= > three-dimensional bar chart </Option><!--xl3dbarclustered
<option value= ">xl3DBarStacked</Option>"
<option value= ">xl3DBarStacked100</Option>-->"
<option value= > Line chart </Option><!--xllinestacked
<option value= ">xlLineStacked100</Option>"
<option value= ">xlLineMarkers</Option>"
<option value= ">xlLineMarkersStacked</Option>"
<option value= ">xlLineMarkersStacked100</Option>"
<option value= ">xlPieOfPie</Option>"
<option value= ">xlPieExploded</Option>"
<option value= ">xl3DPieExploded</Option>"
<option value= ">xlBarOfPie</Option>-->"
<option value= > Graph </Option><!--xlxyscattersmooth
<option value= ">xlXYScatterSmoothNoMarkers</Option>"
Value= "<option" >xlXYScatterLines</Option>
<option value= ">xlXYScatterLinesNoMarkers</Option>-->"
Value= "<option" > Line area chart </Option><!--xlareastacked
<option value= ">xlAreaStacked100</Option>"
<option value= ">xl3DAreaStacked</Option>"
<option value= ">xl3DAreaStacked100</Option>"
<option value= ">xlDoughnutExploded</Option>"
<option value= "Bayi" >xlRadarMarkers</Option>
<option value= ">xlRadarFilled</Option>"
<option value= ">xlSurface</Option>"
<option value= ">xlSurfaceWireframe</Option>"
<option value= ">xlSurfaceTopView</Option>"
<option value= ">xlSurfaceTopViewWireframe</Option>"
<option value= ">xlBubble</Option>"
<option value= ">xlBubble3DEffect</Option>"
<option value= ">xlStockHLC</Option>"
<option value= ">xlStockOHLC</Option>"
<option value= ">xlStockVHLC</Option>"
<option value= ">xlStockVOHLC<"



Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.