Pārlūkot izejas kodu

处理 因现有 npoi 版本低导出 输出 execl折线图x,y轴不显示的问题前的备份

CXS 3 gadi atpakaļ
vecāks
revīzija
f4976ace38

+ 287 - 48
OTSIncAReportApp/1-UI/Control_Grids/ParticlesGridDevidePage.cs

@@ -1,5 +1,8 @@
 using NPOI.HSSF.UserModel;
 using NPOI.SS.UserModel;
+using NPOI.SS.UserModel.Charts;
+using NPOI.SS.Util;
+using NPOI.XSSF.UserModel;
 using OTSIncAReportApp;
 using OTSIncAReportApp.DataOperation.DataAccess;
 using OTSIncAReportApp.DataOperation.Model;
@@ -21,6 +24,7 @@ using System.Reflection;
 using System.Threading;
 using System.Windows.Forms;
 
+
 namespace OTSIncAReportGrids
 {
     public partial class ParticlesGridDevidePage : UserControl
@@ -82,11 +86,12 @@ namespace OTSIncAReportGrids
         string str_SysType = "";//当前启动模式(夹杂物、清洁度)
         frmReportConditionChoose m_condition;
         FieldData fieldData;
-		DataTable particlesAll;
+        DataTable particlesAll;
+        DataTable particles;
         ParticleData Particledata;
         UserLibraryData userLibrary;
         DataTable userLibraryData;
-        NLog.Logger log= NLog.LogManager.GetCurrentClassLogger();
+        NLog.Logger log = NLog.LogManager.GetCurrentClassLogger();
 
         #region 分页器相关
 
@@ -173,15 +178,15 @@ namespace OTSIncAReportGrids
             resultFile = ReportApp.m_rstDataMgr.CurResultFile;
             ReportFun = new OTSImageDisHelp(resultFile);
 
-            string sou=m_condition.m_CurrentConditions[OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE].itemDisplayVal.ToString();
+            string sou = m_condition.m_CurrentConditions[OTSIncAReportApp.OTSSampleReportInfo.OTS_REPORT_PROP_GRID_ITEMS.DATA_SOURCE].itemDisplayVal.ToString();
             if (sou.Contains("+"))
             {
-                result=m_ReportApp.m_rstDataMgr.ResultFilesList[0];
-            }else
+                result = m_ReportApp.m_rstDataMgr.ResultFilesList[0];
+            } else
             {
-                for(int i=0;i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count;i++)
+                for (int i = 0; i < m_ReportApp.m_rstDataMgr.ResultFilesList.Count; i++)
                 {
-                    if (sou== m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName.ToString())
+                    if (sou == m_ReportApp.m_rstDataMgr.ResultFilesList[i].FileName.ToString())
                     {
                         result = m_ReportApp.m_rstDataMgr.ResultFilesList[i];
                     }
@@ -209,14 +214,14 @@ namespace OTSIncAReportGrids
                 lan = new Language(this);
                 table = lan.GetNameTable(this.Name);
 
-            
+
                 m_mythread_state = false;
                 m_mythread = new Thread(new ParameterizedThreadStart(Thread_GO));
                 //m_frm_userprogress = new Frm_UserProgress();
                 fieldData = new FieldData(result.FilePath);
                 Particledata = new ParticleData(result.FilePath);
                 str_SysType = ((Dictionary<string, object>)((Dictionary<string, object>)((Dictionary<string, object>)result.ResultInfo["Sample"])["Members"])["MsrParams"])["SysType"].ToString();
-                if (str_SysType== "0:IncA")
+                if (str_SysType == "0:IncA")
                 {
                     userLibraryData = null;
                 }
@@ -237,12 +242,12 @@ namespace OTSIncAReportGrids
                 m_OTSIncAReportGridsFun = new OTSReportGridsFun(m_ReportApp, this);
                 return true;
             }
-            catch(Exception ex)
+            catch (Exception ex)
             {
                 log.Error(ex.ToString());
                 return false;
             }
-            
+
         }
         private void ParticlesGridDevidePage_Load(object sender, EventArgs e)
         {
@@ -261,7 +266,7 @@ namespace OTSIncAReportGrids
             {
                 return;
             }
-           
+
             cbB_PageSize.Items.Add("20");
             cbB_PageSize.Items.Add("100");
             cbB_PageSize.Items.Add("500");
@@ -311,10 +316,10 @@ namespace OTSIncAReportGrids
                 dtUelect.Columns.Add("Hardness");
                 dtUelect.Columns.Add("Density");
                 dtUelect.Columns.Add("Electrical_conductivity");
-                for (int i=0;i< selectParticles.Count;i++)
+                for (int i = 0; i < selectParticles.Count; i++)
                 {
                     dtUelect.Rows.Add(selectParticles[i].FieldId, selectParticles[i].ParticleId, selectParticles[i].AveGray, selectParticles[i].RectLeft, selectParticles[i].RectTop, selectParticles[i].RectWidth, selectParticles[i].RectHeight, selectParticles[i].Area, selectParticles[i].PosX, selectParticles[i].PosX, selectParticles[i].TypeId, /*selectParticles[i].ElementNum,*/ selectParticles[i].SegmentNum, selectParticles[i].SEMPosX, selectParticles[i].SEMPosY, selectParticles[i].ParticleId, selectParticles[i].DMAX, selectParticles[i].DMIN, selectParticles[i].DPERP, selectParticles[i].PERIMETER, selectParticles[i].ORIENTATION, selectParticles[i].DINSCR, selectParticles[i].DMEAN, selectParticles[i].DELONG, selectParticles[i].DFERET, selectParticles[i].TypeName, selectParticles[i].TypeColor, "", "", "", "", "");
-                 }
+                }
                 if (userLibraryData != null)
                 {
                     for (int i = 0; i < dtUelect.Rows.Count; i++)
@@ -355,12 +360,12 @@ namespace OTSIncAReportGrids
                 particlesAll.Columns.Add("Hardness");
                 particlesAll.Columns.Add("Density");
                 particlesAll.Columns.Add("Electrical_conductivity");
-                if(userLibraryData != null)
+                if (userLibraryData != null)
                 {
-                    for(int i=0;i< particlesAll.Rows.Count;i++)
+                    for (int i = 0; i < particlesAll.Rows.Count; i++)
                     {
                         DataRow[] dr = userLibraryData.Select("STDId=" + particlesAll.Rows[i]["TypeId"].ToString());
-                        if (dr.Length>0)
+                        if (dr.Length > 0)
                         {
                             particlesAll.Rows[i]["Hardness"] = System.Text.RegularExpressions.Regex.Replace(dr[0]["Hardness"].ToString(), @"[^\d.\d]", "");
                             particlesAll.Rows[i]["Density"] = System.Text.RegularExpressions.Regex.Replace(dr[0]["Density"].ToString(), @"[^\d.\d]", "");
@@ -395,7 +400,7 @@ namespace OTSIncAReportGrids
                 }
                 btn_Sel.Enabled = true;
             }
-            if(particlesAll==null)
+            if (particlesAll == null)
             {
                 log.Error("There is an exception in the data of the database!");
                 #region 加载进度条进度部份结束
@@ -726,7 +731,7 @@ namespace OTSIncAReportGrids
 
                 }
             }
-            if(PageSize==-1)
+            if (PageSize == -1)
             {
                 PageSize = particlesAll.Rows.Count;
             }
@@ -736,7 +741,7 @@ namespace OTSIncAReportGrids
                 return;
             }
             RecordCount = particlesAll.Rows.Count;
-            DataTable particles = particlesAll.Clone();
+            particles = particlesAll.Clone();
             for (int fi = (PageIndex - 1) * pageSize; fi < PageIndex * pageSize; fi++)
             {
                 if (fi > RecordCount - 1)
@@ -875,7 +880,7 @@ namespace OTSIncAReportGrids
                     }
                 }
             }
-            
+
 
             #region 加载进度条进度部份结束
             //加载完成设置鼠标为默认
@@ -1102,7 +1107,7 @@ namespace OTSIncAReportGrids
                 if (m_OTSIncAReportGridsFun.m_SEMConnectionState == true)
                 {
                     m_OTSIncAReportGridsFun.MoveSemToPointXY_ForParticlesGrid(sem_point.X, sem_point.Y);
-                
+
                 }
 
                 Thread.Sleep(1500);
@@ -1314,7 +1319,7 @@ namespace OTSIncAReportGrids
         /// <param name="min"></param>
         /// <param name="max"></param>
         /// <returns></returns>
-        bool CompareInput(string min,string max)
+        bool CompareInput(string min, string max)
         {
             int imax = 0;
             int imin = 0;
@@ -1336,7 +1341,7 @@ namespace OTSIncAReportGrids
             {
                 dmin = Convert.ToDouble(min);
             }
-            if(dmin<=dmax)
+            if (dmin <= dmax)
             {
                 return true;
             }
@@ -1357,7 +1362,7 @@ namespace OTSIncAReportGrids
                 {
                     condition += " and Area" + " > " + tBx_AreaMin.Text;
                 }
-                else if(int.TryParse(tBx_AreaMin.Text, out inum) && inum >= 0)
+                else if (int.TryParse(tBx_AreaMin.Text, out inum) && inum >= 0)
                 {
                     condition += " and Area" + " > " + tBx_AreaMin.Text;
                 }
@@ -1395,7 +1400,7 @@ namespace OTSIncAReportGrids
                     return;
                 }
             }
-            
+
 
             if (!string.IsNullOrWhiteSpace(tbx_DmaxMin.Text))
             {
@@ -1405,7 +1410,7 @@ namespace OTSIncAReportGrids
                 {
                     condition += " and DMAX" + " > " + tbx_DmaxMin.Text;
                 }
-                else if(int.TryParse(tbx_DmaxMin.Text, out inum)&& inum >= 0)
+                else if (int.TryParse(tbx_DmaxMin.Text, out inum) && inum >= 0)
                 {
                     condition += " and DMAX" + " > " + tbx_DmaxMin.Text;
                 }
@@ -1424,7 +1429,7 @@ namespace OTSIncAReportGrids
                 {
                     condition += " and DMAX" + "<" + tbx_DmaxMax.Text;
                 }
-                else if(int.TryParse(tbx_DmaxMax.Text, out inum)&& inum >= 0)
+                else if (int.TryParse(tbx_DmaxMax.Text, out inum) && inum >= 0)
                 {
                     condition += " and DMAX" + "<" + tbx_DmaxMax.Text;
                 }
@@ -1543,7 +1548,7 @@ namespace OTSIncAReportGrids
                 lnkNext.Enabled = false;
                 lnkLast.Enabled = false;
             }
-            
+
         }
         private void SetFormCtrEnabled()
         {
@@ -1632,16 +1637,16 @@ namespace OTSIncAReportGrids
         /// <summary>
         /// 在帧图上标记颗粒的位置矩形,并保存到FIELD_FILES_MARK文件夹中
         /// </summary>
-        public void SaveMarkParticleRectangleOnFieldFile(string str_resultPath, DataTable dataTable ,out List<string> vs , out DataTable dt_FIeld)
+        public void SaveMarkParticleRectangleOnFieldFile(string str_resultPath, DataTable dataTable, out List<string> vs, out DataTable dt_FIeld)
         {
             Init();
 
             List<string> maxlength = new List<string>();
-            for (int i=0;i< dataTable.Rows.Count;i++)
+            for (int i = 0; i < dataTable.Rows.Count; i++)
             {
-                if (dataTable.Rows[i]["TypeName"].ToString()!= "Not Identified")
+                if (dataTable.Rows[i]["TypeName"].ToString() != "Not Identified")
                 {
-                    if (maxlength.Count<10)
+                    if (maxlength.Count < 10)
                     {
                         maxlength.Add(dataTable.Rows[i]["Fieldid"].ToString());
                     }
@@ -1686,7 +1691,7 @@ namespace OTSIncAReportGrids
                 dt.Columns.Add("fieldid");
                 dt.Columns.Add("id");
                 dt.Columns.Add("fieldName");
-                dt.Columns.Add("cunt",typeof(int));
+                dt.Columns.Add("cunt", typeof(int));
                 dt.Columns.Add("fieldFullName");
                 for (int i = 0; i < max_list.Count; i++)
                 {
@@ -1722,7 +1727,7 @@ namespace OTSIncAReportGrids
                 //dv.Sort = "cunt DESC";
                 dt_FIeld = dt.Copy();
 
-                for (int i=0;i< dt_FIeld.Rows.Count; i++)
+                for (int i = 0; i < dt_FIeld.Rows.Count; i++)
                 {
                     if (dataTable.Select(dt_FIeld.Rows[i]["fieldid"].ToString()).Count() > 0)
                     {
@@ -1742,7 +1747,7 @@ namespace OTSIncAReportGrids
                         img.Dispose();
                         img = null;
 
-                       
+
                         //循环将颗粒,进行标记到bitmap图上
                         DataRow[] drlist = dt_AllParticle.Select(dt_FIeld.Rows[i]["fieldid"].ToString());
                         if (drlist.Count() > 0)
@@ -1771,7 +1776,7 @@ namespace OTSIncAReportGrids
                             {
                                 ls_offsetx = offset_rect.X - 10;
                             }
-                           
+
                             g.DrawString(dt_FIeld.Rows[i]["id"].ToString() + "" + str_particleid.ToString(),
                                 new Font("黑体", 8), new SolidBrush(Color.Aqua), new PointF(ls_offsetx, offset_rect.Y));
 
@@ -1799,7 +1804,7 @@ namespace OTSIncAReportGrids
         {
             //将所有的数据导出到EXCEL中
             SaveFileDialog sfd = new SaveFileDialog();
-            sfd.Filter = "Excel File(*.xls)|*.xls";
+            sfd.Filter = "Excel File(*.xlsx)|*.xlsx";
             //设置默认文件类型显示顺序
             sfd.FilterIndex = 1;
 
@@ -1808,8 +1813,8 @@ namespace OTSIncAReportGrids
 
             if (sfd.ShowDialog() == DialogResult.OK)
             {
-                IWorkbook workbook = new HSSFWorkbook();   //用于创建.xls  office2003开始以前的
-                //IWorkbook workbook = new XSSFWorkbook();        //用于创建.xlsx office2007开始以后的
+                //IWorkbook workbook = new HSSFWorkbook();   //用于创建.xls  office2003开始以前的
+                IWorkbook workbook = new NPOI.XSSF.UserModel.XSSFWorkbook();        //用于创建.xlsx office2007开始以后的
                 ISheet sheet;
 
                 //创建Excel文件
@@ -1892,7 +1897,7 @@ namespace OTSIncAReportGrids
                         {
                             //非图像列
                             double dbl = 0;
-                            if(double.TryParse(dgV_ParticlesDevidePage[i_cell, i_row].Value.ToString(),out dbl))
+                            if (double.TryParse(dgV_ParticlesDevidePage[i_cell, i_row].Value.ToString(), out dbl))
                             {
                                 cell.SetCellValue(dbl);
                             }
@@ -1906,9 +1911,78 @@ namespace OTSIncAReportGrids
                 }
 
                 ISheet sheet2;
-                sheet2 = workbook.CreateSheet("Peak spectrum");//创建工作表
-                //设置颗粒名列宽
-                sheet.SetColumnWidth(1, 30 * 256);//夹杂物名列宽
+                sheet2 = workbook.CreateSheet("Peak spectrum Data");//创建工作表
+                //插入表头
+                row = sheet2.CreateRow(1);
+                row.Height = 30 * 20;
+                cell = row.CreateCell(0);
+                cell.CellStyle = cellStyle;
+                cell.SetCellValue("rowid");
+
+                for (int i_cell = 1; i_cell < 2001; i_cell++)
+                {
+                   cell = row.CreateCell(i_cell);
+                   cell.CellStyle = cellStyle;
+                    if (i_cell == 1)
+                    {
+                        cell.SetCellValue("PeakSpectrumData");
+                    }
+                }
+
+                sheet2.AddMergedRegion(new NPOI.SS.Util.CellRangeAddress(1, 1, 1, 2000));
+
+                for (int j = 0; j < particles.Rows.Count; j++)
+                {
+                    row = sheet2.CreateRow(2 + j);
+                    cell = row.CreateCell(0);
+                    cell.CellStyle = cellStyle;
+                    cell.SetCellValue(j + 1);
+                    var tmpPart = Particledata.GetParticleXrayDataByFidAndPid(particles.Rows[j]["fieldid"].ToString(), particles.Rows[j]["particleid"].ToString());
+                    if (tmpPart != null)
+                    {
+                        if (tmpPart.XrayId > -1)
+                        {
+                            uint[] Analysis_xray = new uint[2000];
+                            for (int i = 0; i < 2000; i++)
+                            {
+                                Analysis_xray[i] = BitConverter.ToUInt32(tmpPart.XRayData, i * 4);
+                                cell = row.CreateCell(i + 1);
+                                cell.CellStyle = cellStyle;
+                                cell.SetCellValue(Analysis_xray[i]);
+                            }
+
+                        }
+
+                    }
+                }
+
+                ISheet sheet3;
+                sheet3 = workbook.CreateSheet("Peak spectrum");//创建工作表
+                sheet3.SetColumnWidth(0, 100 * 256);//图像列宽
+                ////插入表头
+                //row = sheet3.CreateRow(1);
+                //row.Height = 30 * 20;
+                //cell = row.CreateCell(0);
+                //cell.CellStyle = cellStyle;
+                //cell.SetCellValue("rowid");
+
+                //cell = row.CreateCell(1);
+                //cell.CellStyle = cellStyle;
+                //cell.SetCellValue("PeakSpectrum");
+                //for (int j = 0; j < particles.Rows.Count; j++)
+                //{
+                    row = sheet3.CreateRow(1);
+                    row.Height = 60 * 20;
+                    cell = row.CreateCell(0);
+                    cell.CellStyle = cellStyle;
+                    //cell.SetCellValue(1);
+                    cell = row.CreateCell(1);
+                    cell = row.CreateCell(2);
+                    IDrawing drawing = sheet3.CreateDrawingPatriarch();
+                    //锚点
+                    IClientAnchor anchor3 = drawing.CreateAnchor(0, 0, 0, 0, 0, 0, 2, 2);//XSSFClientAnchor(dx1,dy1,dx2,dy2,col1,row1,col2,row2);参数说明:dx1 dy1 起始单元格中的x,y坐标.dx2 dy2 结束单元格中的x,y坐标col1, row1 指定起始的单元格,下标从0开始col2, row2 指定结束的单元格,下标从0开始
+                    CreateChart(drawing, sheet2, anchor3, "title1");
+                //}
 
 
                 //完成后,对Excel进行保存
@@ -1929,7 +2003,40 @@ namespace OTSIncAReportGrids
             }
         }
 
+        void CreateChart(IDrawing drawing, ISheet sheet, IClientAnchor anchor, string serie1)
+        {
+            var chart = drawing.CreateChart(anchor) as XSSFChart;
+            // 创建图形注释的位置
+            //var legend = chart.GetOrCreateLegend();
+            //legend.Position = LegendPosition.Top;
+            
+
+            //图表
+            var data = chart.GetChartDataFactory().CreateLineChartData<double, double>(); //折线图散点图
+
+            IChartAxis bottomAxis = chart.GetChartAxisFactory().CreateCategoryAxis(AxisPosition.Bottom);
+            IValueAxis leftAxis = chart.GetChartAxisFactory().CreateValueAxis(AxisPosition.Left);
+            leftAxis.SetCrosses(AxisCrosses.AutoZero);
+
+            //数据源
+            //IChartDataSource<double> xs = DataSources.FromNumericCellRange(sheet, new CellRangeAddress(1, 1, 1, 2001));
+
+            Double[] doubles = new Double[2000];
+            for (int i = 0; i < 2000; i++)
+            {
+                doubles[i] = i;
+            }
+            IChartDataSource<double> xs = DataSources.FromArray(doubles);
+            IChartDataSource<double> ys = DataSources.FromArray(doubles);
+
+            //数据系列
+            var s1 = data.AddSerie(xs, ys);
+            s1.SetTitle(serie1);
+
+            // 开始绘制折线图
+            chart.Plot(data, bottomAxis, leftAxis);
 
+        }
         /// <summary>
         /// 将image转成bytes
         /// </summary>
@@ -1954,7 +2061,7 @@ namespace OTSIncAReportGrids
             }
         }
 
-     
+
 
         private void ToolStripMenuItem_Delete_Particle_Click(object sender, EventArgs e)
         {
@@ -1980,10 +2087,10 @@ namespace OTSIncAReportGrids
                             if (ReportFun.DeleteParticlesFromLibrary(item.ParticleId, item.FieldId))
                             {
                                 MessageBox.Show("Deleted successfully");
-                                
-                                for (int i=0;i< particlesAll.Rows.Count;i++)
+
+                                for (int i = 0; i < particlesAll.Rows.Count; i++)
                                 {
-                                    if (particlesAll.Rows[i]["Fieldid"].ToString()== item.FieldId.ToString() && particlesAll.Rows[i]["Particleid"].ToString()==item.ParticleId.ToString())
+                                    if (particlesAll.Rows[i]["Fieldid"].ToString() == item.FieldId.ToString() && particlesAll.Rows[i]["Particleid"].ToString() == item.ParticleId.ToString())
                                     {
                                         particlesAll.Rows.RemoveAt(i);
                                     }
@@ -2004,9 +2111,141 @@ namespace OTSIncAReportGrids
             }
         }
 
+
+        #region 将DataTable中的数据写到Excel的指定Sheet中
+        /// <summary>
+        /// 将DataTable中的数据写到Excel的指定Sheet中
+        /// </summary>
+        /// <param name="dt"></param>
+        /// <param name="m_Sheet"></param>
+        public void DataTableToSheet(string title, DataTable dt, Microsoft.Office.Interop.Excel._Worksheet m_Sheet,
+                                    Microsoft.Office.Interop.Excel._Workbook m_Book, int startrow)
+        {
+
+            //以下是填写EXCEL中数据
+            Microsoft.Office.Interop.Excel.Range range = m_Sheet.get_Range(m_Sheet.Cells[1, 1], m_Sheet.Cells[1, 2]);
+            range.MergeCells = true;  //合并单元格
+            range.Font.Bold = true;   //加粗单元格内字符
+            //写入题目
+            m_Sheet.Cells[startrow, startrow] = title;
+            int rownum = dt.Rows.Count;//行数
+            int columnnum = dt.Columns.Count;//列数
+            int num = rownum + 2;   //得到数据中的最大行数
+
+
+            //写入列标题
+            for (int j = 0; j < columnnum; j++)
+            {
+                int bt_startrow = startrow + 1;
+
+                //将字段名写入文档
+                m_Sheet.Cells[bt_startrow, 1 + j] = dt.Columns[j].ColumnName;
+
+                //单元格内背景色
+                m_Sheet.get_Range(m_Sheet.Cells[bt_startrow, 1 + j], m_Sheet.Cells[bt_startrow, 1 + j]).Interior.ColorIndex = 15;
+            }
+
+
+            //逐行写入数据
+            for (int i = 0; i < rownum; i++)
+            {
+                for (int j = 0; j < columnnum; j++)
+                {
+                    m_Sheet.Cells[startrow + 2 + i, 1 + j] = dt.Rows[i][j].ToString();
+                }
+            }
+            m_Sheet.Columns.AutoFit();
+
+
+
+            //在当前工作表中根据数据生成图表
+
+            CreateChart(m_Book, m_Sheet, num);
+        }
+        private void CreateChart(Microsoft.Office.Interop.Excel._Workbook m_Book, Microsoft.Office.Interop.Excel._Worksheet m_Sheet, int num)
+        {
+            Microsoft.Office.Interop.Excel.Range oResizeRange;
+            Microsoft.Office.Interop.Excel.Series oSeries;
+
+            m_Book.Charts.Add(Missing.Value, Missing.Value, 1, Missing.Value);
+            m_Book.ActiveChart.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlLine;//设置图形
+
+            //设置数据取值范围
+            m_Book.ActiveChart.SetSourceData(m_Sheet.get_Range("A2", "C" + num.ToString()), Microsoft.Office.Interop.Excel.XlRowCol.xlColumns);
+            //m_Book.ActiveChart.Location(Microsoft.Office.Interop.Excel.XlChartLocation.xlLocationAutomatic, title);
+            //以下是给图表放在指定位置
+            m_Book.ActiveChart.Location(Microsoft.Office.Interop.Excel.XlChartLocation.xlLocationAsObject, m_Sheet.Name);
+            oResizeRange = (Microsoft.Office.Interop.Excel.Range)m_Sheet.Rows.get_Item(10, Missing.Value);
+            m_Sheet.Shapes.Item("Chart 1").Top = (float)(double)oResizeRange.Top;  //调图表的位置上边距
+            oResizeRange = (Microsoft.Office.Interop.Excel.Range)m_Sheet.Columns.get_Item(6, Missing.Value);  //调图表的位置左边距
+                                                                                                              // m_Sheet.Shapes.Item("Chart 1").Left = (float)(double)oResizeRange.Left;
+            m_Sheet.Shapes.Item("Chart 1").Width = 400;   //调图表的宽度
+            m_Sheet.Shapes.Item("Chart 1").Height = 250;  //调图表的高度
+
+            m_Book.ActiveChart.PlotArea.Interior.ColorIndex = 19;  //设置绘图区的背景色
+            m_Book.ActiveChart.PlotArea.Border.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone;//设置绘图区边框线条
+            m_Book.ActiveChart.PlotArea.Width = 400;   //设置绘图区宽度
+            //m_Book.ActiveChart.ChartArea.Interior.ColorIndex = 10; //设置整个图表的背影颜色
+            //m_Book.ActiveChart.ChartArea.Border.ColorIndex = 8;// 设置整个图表的边框颜色
+            m_Book.ActiveChart.ChartArea.Border.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone;//设置边框线条
+            m_Book.ActiveChart.HasDataTable = false;
+
+
+            //设置Legend图例的位置和格式
+            m_Book.ActiveChart.Legend.Top = 20.00; //具体设置图例的上边距
+            m_Book.ActiveChart.Legend.Left = 60.00;//具体设置图例的左边距
+            m_Book.ActiveChart.Legend.Interior.ColorIndex = Microsoft.Office.Interop.Excel.XlColorIndex.xlColorIndexNone;
+            m_Book.ActiveChart.Legend.Width = 150;
+            m_Book.ActiveChart.Legend.Font.Size = 9.5;
+            //m_Book.ActiveChart.Legend.Font.Bold = true;
+            m_Book.ActiveChart.Legend.Font.Name = "宋体";
+            //m_Book.ActiveChart.Legend.Position = Microsoft.Office.Interop.Excel.XlLegendPosition.xlLegendPositionTop;//设置图例的位置
+            m_Book.ActiveChart.Legend.Border.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlLineStyleNone;//设置图例边框线条
+
+
+
+            //设置X轴的显示
+            Microsoft.Office.Interop.Excel.Axis xAxis = (Microsoft.Office.Interop.Excel.Axis)m_Book.ActiveChart.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary);
+            xAxis.MajorGridlines.Border.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlDot;
+            xAxis.MajorGridlines.Border.ColorIndex = 1;//gridLine横向线条的颜色
+            xAxis.HasTitle = false;
+            xAxis.MinimumScale = 1500;
+            xAxis.MaximumScale = 6000;
+            xAxis.TickLabels.Font.Name = "宋体";
+            xAxis.TickLabels.Font.Size = 9;
+
+
+
+            //设置Y轴的显示
+            Microsoft.Office.Interop.Excel.Axis yAxis = (Microsoft.Office.Interop.Excel.Axis)m_Book.ActiveChart.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary);
+            yAxis.TickLabelSpacing = 30;
+            yAxis.TickLabels.NumberFormat = "M月D日";
+            yAxis.TickLabels.Orientation = Microsoft.Office.Interop.Excel.XlTickLabelOrientation.xlTickLabelOrientationHorizontal;//Y轴显示的方向,是水平还是垂直等
+            yAxis.TickLabels.Font.Size = 8;
+            yAxis.TickLabels.Font.Name = "宋体";
+
+            //m_Book.ActiveChart.Floor.Interior.ColorIndex = 8;
+            /***以下是设置标题*****
+            m_Book.ActiveChart.HasTitle=true;
+            m_Book.ActiveChart.ChartTitle.Text = "净值指数";
+            m_Book.ActiveChart.ChartTitle.Shadow = true;
+            m_Book.ActiveChart.ChartTitle.Border.LineStyle = Microsoft.Office.Interop.Excel.XlLineStyle.xlContinuous;
+            */
+
+            oSeries = (Microsoft.Office.Interop.Excel.Series)m_Book.ActiveChart.SeriesCollection(1);
+            oSeries.Border.ColorIndex = 45;
+            oSeries.Border.Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick;
+            oSeries = (Microsoft.Office.Interop.Excel.Series)m_Book.ActiveChart.SeriesCollection(2);
+            oSeries.Border.ColorIndex = 9;
+            oSeries.Border.Weight = Microsoft.Office.Interop.Excel.XlBorderWeight.xlThick;
+
+        }
+
+        #endregion
     }
 
 
 
+
 }