一区二区三区日韩精品-日韩经典一区二区三区-五月激情综合丁香婷婷-欧美精品中文字幕专区

分享

關(guān)于C#操作EXCEL,生成圖表的全面應(yīng)用之二(利用Microsoft.Office.In...

 冰山上的薰衣草 2010-11-29
 關(guān)于C#操作EXCEL,生成圖表的全面應(yīng)用之二(利用Microsoft.Office.Interop.OWC11) 收藏
續(xù)上篇,介紹OWC11的應(yīng)用:
        開發(fā)者:Gailzhao 
        EMail:gailzhao@sohu.com
 
        另添加引用
        using OWC = Microsoft.Office.Interop.Owc11;
 
        public void DataTableToSheet(string title, DataTable dt, Excel._Worksheet m_Sheet,
                                    Excel._Workbook m_Book,   int startrow)
        {
            。。。。。。(同上篇)。。。。。。
                //使用OWC11組件畫圖
                showChart(OWC.ChartChartTypeEnum.chChartTypeLine);  //生成圖表文件
                //將圖表文件插入到EXCEL文檔中
                m_Sheet.Shapes.AddPicture("E:\\chart.gif", MsoTriState.msoFalse, MsoTriState.msoTrue, 250, 100, 350, 250 );

        }
    private void showChart(OWC.ChartChartTypeEnum Type)
        {
            OWC.ChartChartTypeEnum _Type;
            OWC.ChartSpace axChartSpace1 = new OWC.ChartSpaceClass();
            try
            {
                axChartSpace1.Clear();
                OWC.ChChart objChart = axChartSpace1.Charts.Add(0);
                OWC.ChAxis axis = objChart.Axes[0];   //X軸
                OWC.ChAxis axis1 = objChart.Axes[1];  //Y軸
                objChart.Type = Type;
                objChart.HasLegend = true;
                objChart.Legend.Position = OWC.ChartLegendPositionEnum.chLegendPositionTop;
                //objChart.HasTitle = true;
                //objChart.Title.Caption = "凈值指數(shù)圖";
                //objChart.Axes[0].HasTitle = true ;
                //objChart.Axes[0].Title.Caption = "日期";
                //objChart.Axes[1].HasTitle = true;
                //objChart.Axes[1].Title.Caption = "數(shù)值";
                objChart.SeriesCollection.Add(0);
                objChart.SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimSeriesNames,
                 +(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, "開放式基金");
                DataSet ds = ScData.ListData("exec zb_LiCaiZhouBao " + int.Parse(txtStartDate.Text.Replace("-","") ) + ",1");
                string X_Value1 = "";
                string X_Value2 = "";
                string Y_Value = "";
                if (ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                       // Console.WriteLine(dr["日期"].ToString());
                        Y_Value = Y_Value + dr["日期"].ToString() + '\t';
                        X_Value1 = X_Value1 + dr["開放式基金"].ToString() + '\t';
                        X_Value2 = X_Value2 + dr["偏股型基金"].ToString() + '\t';
                    }
                }
                objChart.SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimCategories,
                 +(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, Y_Value);
                              objChart.SeriesCollection[0].SetData(OWC.ChartDimensionsEnum.chDimValues,
                 (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, X_Value1);
                objChart.SeriesCollection.Add(1);
                objChart.SeriesCollection[1].SetData(OWC.ChartDimensionsEnum.chDimSeriesNames,
                 +(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, "偏股型基金");
                objChart.SeriesCollection[1].SetData(OWC.ChartDimensionsEnum.chDimCategories,
                 +(int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, Y_Value);
                objChart.SeriesCollection[1].SetData(OWC.ChartDimensionsEnum.chDimValues,
                 (int)OWC.ChartSpecialDataSourcesEnum.chDataLiteral, X_Value2);
 
                objChart.SeriesCollection[0].Line.Color = "orange";
                //objChart.SeriesCollection[0].Line.Weight = OWC.ChLine.LineWeightEnum.owcLineWeightThick;   //線條加粗
                objChart.SeriesCollection[1].Line.Color = "maroon";
                //objChart.SeriesCollection[1].Line.Weight = OWC.LineWeightEnum.owcLineWeightThick;
                axis.TickMarkSpacing = 30;
                axis.HasTickLabels = true;
                axis.TickLabelSpacing =30;
                axis1.HasMajorGridlines = true;
                axis1.MajorGridlines.Line.DashStyle = OWC.ChartLineDashStyleEnum.chLineDashDotDot;//.chLineDashDot;
                //axis1.MajorGridlines.Line.Color = "orange";
                objChart.PlotArea.Interior.Color = "LightYellow";    //圖表區(qū)的背景色
             
                // objChart.Interior.Color = "green";
              
               //objChart.Interior.BackColor = "yellow";
                //axis.TickMarkSpacing = 50;
            }
            catch (Exception ex)
            {
                //timer1.Enabled = false;
                MessageBox.Show(ex.Message);
            }
            finally
            {
                _Type = Type;
                //輸出成GIF文件.  
                string strAbsolutePath = "E:\\chart.gif"; //生成圖形文件  
                axChartSpace1.ExportPicture(strAbsolutePath, "GIF", 600, 350);
            }
        }
 
本文來自CSDN博客,轉(zhuǎn)載請標(biāo)明出處:http://blog.csdn.net/gailzhao/archive/2008/09/19/2950912.aspx

    本站是提供個(gè)人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多

    国产一区一一一区麻豆| 亚洲中文字幕综合网在线| 欧美一级内射一色桃子| 久草精品视频精品视频精品| 99国产成人免费一区二区| 国产成人免费高潮激情电 | 激情综合网俺也狠狠地| 一区二区免费视频中文乱码国产| 在线视频三区日本精品| 一区二区三区人妻在线| 成人欧美精品一区二区三区| 色综合久久超碰色婷婷| 熟女乱一区二区三区四区| 福利视频一区二区在线| 亚洲男人天堂网在线视频| 精品欧美日韩一区二区三区| 激情综合网俺也狠狠地| 91精品国产品国语在线不卡| 亚洲精品高清国产一线久久| 国产原创激情一区二区三区| 嫩呦国产一区二区三区av| 欧美中文字幕一区在线| 中文字幕精品少妇人妻| 国产日产欧美精品视频| 国产对白老熟女正在播放| 亚洲综合日韩精品欧美综合区| 内用黄老外示儒术出处| 九九热在线视频精品免费| 99久久国产亚洲综合精品| 国产丝袜女优一区二区三区| 亚洲欧美日本成人在线| 国产精品午夜福利在线观看| 欧美日韩久久精品一区二区| 欧美精品久久一二三区| 男人和女人黄 色大片| 国产精品刮毛视频不卡| 高潮日韩福利在线观看| 欧美日韩精品久久第一页| 国产老女人性生活视频| 熟女白浆精品一区二区| 日本一区二区三区久久娇喘|