在ASP中調用Excel畫資料圖表

來源:互聯網
上載者:User
excel|資料|圖表 在ASP中調用Excel畫資料圖表,優勢有很多,最突出的是可以輸出多種形式的圖形(總共有72種)。以下是我寫的一個通用ASP方法調用Excel畫資料圖表。

<%
'將資料圖形化輸出
'dataArray二維數組
'virtualFilePath輸出影像檔名(虛擬路徑)
'nType顯示類型
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 = "部門員工分布圖"
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="51">二維直條圖</Option><!--xlColumnClustered
<Option value="52">xlColumnStacked</Option>
<Option value="53">xlColumnStacked100</Option>-->
<Option value="54">三維柱狀圖</Option><!--xl3DColumnClustered
<Option value="55">xl3DColumnStacked</Option>
<Option value="56">xl3DColumnStacked100</Option>-->
<Option value="57">二維橫條圖</Option><!--xlBarClustered
<Option value="58">xlBarStacked</Option>
<Option value="59">xlBarStacked100</Option>-->
<Option value="60">三維條狀圖</Option><!--xl3DBarClustered
<Option value="61">xl3DBarStacked</Option>
<Option value="62">xl3DBarStacked100</Option>-->
<Option value="63">折線圖</Option><!--xlLineStacked
<Option value="64">xlLineStacked100</Option>
<Option value="65">xlLineMarkers</Option>
<Option value="66">xlLineMarkersStacked</Option>
<Option value="67">xlLineMarkersStacked100</Option>
<Option value="68">xlPieOfPie</Option>
<Option value="69">xlPieExploded</Option>
<Option value="70">xl3DPieExploded</Option>
<Option value="71">xlBarOfPie</Option>-->
<Option value="72">曲線圖</Option><!--xlXYScatterSmooth
<Option value="73">xlXYScatterSmoothNoMarkers</Option>
<Option value="74">xlXYScatterLines</Option>
<Option value="75">xlXYScatterLinesNoMarkers</Option>-->
<Option value="76">折線面積圖</Option><!--xlAreaStacked
<Option value="77">xlAreaStacked100</Option>
<Option value="78">xl3DAreaStacked</Option>
<Option value="79">xl3DAreaStacked100</Option>
<Option value="80">xlDoughnutExploded</Option>
<Option value="81">xlRadarMarkers</Option>
<Option value="82">xlRadarFilled</Option>
<Option value="83">xlSurface</Option>
<Option value="84">xlSurfaceWireframe</Option>
<Option value="85">xlSurfaceTopView</Option>
<Option value="86">xlSurfaceTopViewWireframe</Option>
<Option value="15">xlBubble</Option>
<Option value="87">xlBubble3DEffect</Option>
<Option value="88">xlStockHLC</Option>
<Option value="89">xlStockOHLC</Option>
<Option value="90">xlStockVHLC</Option>
<Option value="91">xlStockVOHLC<



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.