Call Office in ASP.NET to create a variety of (3D) charts

xiaoxiao2021-03-06  102

Author: Unknown due to the many online article to see who is the author can not be sure

1, download OWC11 COM components http://www.microsoft.com/downloads/details.aspx?familyid=7287252c-402e-4f72-9752c-402e-4f72-9752c-402e-4f72-97a5-e0fd290d4b76&displaylang=en 2, registration OWC11 Add C: / Program Files / Common OWC11.DLL reference under Files / Microsoft Shared / Web Components / 11 or Add comments as shown below

3, add USING OWC11; 4, start Coding Examples: public class chartfactory {public chartfactory () {initTyPemap (); // // Todo: Add constructor logic //} protected system.Web. UI.WebControls.Image imgHondaLineup; private string [] chartCategoriesArr; private string [] chartValuesArr; private OWC11.ChartChartTypeEnum chartType = OWC11.ChartChartTypeEnum.chChartTypeColumn3D; // default private static Hashtable chartMap = new Hashtable (); private static string chartTypeCh = "vertical histogram"; private static string chartTitle = ""; private void InitTypeMap () {chartMap.Clear (); OWC11.ChartChartTypeEnum [] chartTypes = new OWC11.ChartChartTypeEnum [] {ChartChartTypeEnum.chChartTypeColumnClustered, ChartChartTypeEnum.chChartTypeColumn3D, ChartChartTypeEnum. Chcharttypebarclustered, Chartcharttypeenum.chcharttypebar3d, Chartcharttypeenum.chcharttypearea, Chartcharttypeenum.chcharttyperea3d, ChartChartTypeEnum.chChartTypeDoughnut, ChartChartTypeEnum.chChartTypeLineStacked, ChartChartTypeEnum.chChartTypeLine3D, ChartChartTypeEnum.chChartTypeLineMarkers, ChartChartTypeEnum.chChartTypePie, ChartChartTypeEnum.chChartTypePie3D, ChartChartTypeEnum.chChartTypeRadarSmoothLine, ChartChartTypeEnum.chChartTypeSmoothLine}; string [] chartTypesCh = new string [] { "vertical bar graph" "3D vertical column statistics", "horizontal column statistics", "3D horizontal column statistics", "regional statistics", "3D regional statistics", "hollow pie chart", "folding statistics", "3D Paste statistics "," fold line strip statistics "," pie chart ","

3D pie chart "," mesh statistical "," arc statistical "}; for (int i = 0; i

Re charting a pie or a variation theref percentages make a lot // more sense Than Values ​​... // --------------------------- --------------------------------------------- if (charttype == ChartChartTypeEnum.chChartTypePie || chartType == ChartChartTypeEnum.chChartTypePie3D || chartType == ChartChartTypeEnum.chChartTypeDoughnut) {oChartSpace.Charts [0] .SeriesCollection [0] .DataLabelsCollection [0] .HasPercentage = true; oChartSpace.Charts [0] .SeriesCollection [0] .datalabelscollection [0] .haasvalue = false;} // ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------- // NOT SO for other chart Types Where Values ​​Have More Meaning tour // percentages. // ------------------------------------------ ------------------------------ Else {OchartSpace.Charts [0] .seriescollection [0] .datalabelscollection [0] .haspercentage = false; OchartSpace.Charts [0] .seriescollection [0] .datalabelscollection [0] .haasvalue = true;} // ------------ -------------------------------------------------- ---------- // Plug Your OWN Visual Bells and whistles Here // ------------------------------------------------------------------------------------------------------------------------------------------ -------------------------------------------- OchartSpace.Charts [0] .SeriesCollection [0] .Caption = String.Empty; oChartSpace.Charts [0] .SeriesCollection [0] .DataLabelsCollection [0] .Font.Name = "verdana"; oChartSpace.Charts [0] .SeriesCollection [0] .DataLabelsCollection [0] .font.size = 10; OchartSpace.Charts [0] .seriescollection [0] .datalabelscollection [0] .font.bold = true; OchartSpace.Charts [0] .seriescollection [0] .datalabelscollection [0]. Font.color = "red";

oChartSpace.Charts [0] .SeriesCollection [0] .DataLabelsCollection [0] .Position = ChartDataLabelPositionEnum.chLabelPositionCenter; if (chartType == ChartChartTypeEnum.chChartTypeBarClustered || chartType == ChartChartTypeEnum.chChartTypeBar3D || chartType == ChartChartTypeEnum.chChartTypeColumnClustered || chartType == ChartChartTypeEnum.chChartTypeColumn3D) {oChartSpace.Charts [0] .SeriesCollection [0] .DataLabelsCollection [0] .Position = ChartDataLabelPositionEnum.chLabelPositionOutsideEnd;} oChartSpace.Charts [0] .SeriesCollection [0] .SetData (OWC11.ChartDimensionsEnum.chDimCategories , Convert.ToInt32 (OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartCategoriesStr); oChartSpace.Charts [0] .SeriesCollection [0] .SetData (OWC11.ChartDimensionsEnum.chDimValues, Convert.ToInt32 (OWC11.ChartSpecialDataSourcesEnum.chDataLiteral), chartValuesStr); return OchartSpace;} #Region property set public string [] Chartcategoriesarrvalue {Get {Return Chartcategori esArr;} set {chartCategoriesArr = value;}} public string [] chartValuesArrValue {get {return chartValuesArr;} set {chartValuesArr = value;}} public string chartTypeValue {get {return chartTypeCh;} set {chartTypeCh = value;}} public string chartTitleValue {get {return chartTitle;} set {chartTitle value =;}} #endregion} // need to place a call to first page to display the Image on the chart generated public void showChart () {// initialization assignment chartFactory.chartCategoriesArrValue = Chartcategories; ChartFactory.ChartValeSarrValue = chartvalues; chartfactory.ChartTitiValue = charttitle; ChartFactory.ChartTyPEValue =

转载请注明原文地址:https://www.9cbs.com/read-100699.html

New Post(0)