Adjust the Excel painting data chart in the ASP

zhaozj2021-02-17  62

Adjusting the Excel painting data chart in the ASP, there are many advantages, the most prominent is to output a variety of forms of graphics (a total of 72 species). The following is a general ASP method I wrote to call the Excel painting data chart.

<% 'Graphical output data' dataArray is a two-dimensional array 'virtualFilePath output image file name (virtual path)' nType display type Dim initTypeSub ExportPicture (dataArray, virtualFilePath, nType) Dim excelapp 'As New excel.ApplicationDim excelwbk' As excel. WorkbookDim excelcht 'As excel.ChartDim excelsht' As excel.WorksheetDim idx, idy, ftype, usedData, totalcount, count: count = 1On Error Resume nextSet excelapp = Server.CreateObject ( "Excel.Application") Set excelwbk = excelapp.Workbooks. Add () set excelcht = Excelwbk.charts.add () SET Excelsht = Excelwbk.worksheets.add () = ".jpg" or ucase (Right (VirtualFilePath, 4)) = " .Jpeg "Thenftype =" jpg "Elseftype =" gif "end ifinittype = ntypefor 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) NextNextSet usedData = excelsht.usedRangeexcelcht.SeriesCollection.Add usedDataexcelcht.HasLegend = Trueexcelcht.HasTitle = True'excelcht.ChartTitle.Caption = "department employee profile" excelcht .ApplycustomType NTYPEEXCELCHT .Export Server.Mappath (virtualFilePath), ftypeexcelsht.Close Falseexcelwbk.Close FalseSet usedData = NothingSet excelcht = NothingSet excelwbk = NothingSet excelapp = NothingEnd Sub%>