//public void InsertPictures(string Filename, string ws, int Height, int Width)
        //插入图片操作二
        //{
        //    GetSheet(ws).Shapes.AddPicture(Filename, MsoTriState.msoFalse, MsoTriState.msoTrue, 10, 10, 150, 150);
        //    GetSheet(ws).Shapes.get_Range(Type.Missing).Height = Height;
        //    GetSheet(ws).Shapes.get_Range(Type.Missing).Width = Width;
        //}
        //public void InsertPictures(string Filename, string ws, int left, int top, int Height, int Width)
        //插入图片操作三
        //{

        //    GetSheet(ws).Shapes.AddPicture(Filename, MsoTriState.msoFalse, MsoTriState.msoTrue, 10, 10, 150, 150);
        //    GetSheet(ws).Shapes.get_Range(Type.Missing).IncrementLeft(left);
        //    GetSheet(ws).Shapes.get_Range(Type.Missing).IncrementTop(top);
        //    GetSheet(ws).Shapes.get_Range(Type.Missing).Height = Height;
        //    GetSheet(ws).Shapes.get_Range(Type.Missing).Width = Width;
        //}

        public void InsertActiveChart(Microsoft.Office.Interop.Excel.XlChartType ChartType, string ws, int DataSourcesX1, int DataSourcesY1, int DataSourcesX2, int DataSourcesY2, Microsoft.Office.Interop.Excel.XlRowCol ChartDataType)
        //插入图表操作
        {
            ChartDataType = Microsoft.Office.Interop.Excel.XlRowCol.xlColumns;
            wb.Charts.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            {
                wb.ActiveChart.ChartType = ChartType;
                wb.ActiveChart.SetSourceData(GetSheet(ws).get_Range(GetSheet(ws).Cells[DataSourcesX1, DataSourcesY1], GetSheet(ws).Cells[DataSourcesX2, DataSourcesY2]), ChartDataType);
                wb.ActiveChart.Location(Microsoft.Office.Interop.Excel.XlChartLocation.xlLocationAsObject, ws);
            }
        }
        //</Snippet16>


        //<Snippet17>
        private void lineChart_CheckedChanged(object sender, EventArgs e)
        {
            if (((RadioButton)sender).Checked)
            {
                this.selectedType = Microsoft.Office.Interop.Excel.XlChartType.xlLineMarkers;
                if (this.SelectionChanged != null)
                {
                    this.SelectionChanged(this, EventArgs.Empty);
                }
            }
        }
示例#3
0
        /// <summary>
        /// 在此工作表添加一个图表
        /// </summary>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <returns></returns>
        public Chart AddChart(double left = 0.0d, double top = 0.0d)
        {
            Microsoft.Office.Interop.Excel.XlChartType use_ChartType =
                Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered;
            object tempshapes = ExcelUtilityMethod.GetProperty(m_workSheet, "Shapes");

            object tempShape = ExcelUtilityMethod.UseMethod(tempshapes, "AddChart",
                                                            new object[] { use_ChartType, left, top });

            object tempChart = ExcelUtilityMethod.GetProperty(tempShape, "Chart");

            return(new Chart(tempChart));
        }
示例#4
0
        /// <summary>
        /// 添加Chart
        /// </summary>
        /// <returns></returns>
        public Chart AddChart()
        {
            Microsoft.Office.Interop.Excel.XlChartType use_ChartType =
                Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered;
            Microsoft.Office.Interop.Excel.XlChartLocation use_XlLocation =
                Microsoft.Office.Interop.Excel.XlChartLocation.xlLocationAutomatic;
            object chartsObject     = ExcelUtilityMethod.GetProperty(m_workBook, "Charts");
            object addedChartObject = ExcelUtilityMethod.UseMethod(chartsObject, "Add",
                                                                   new object[] { Type.Missing, Type.Missing, 1 });

            //图表形式
            ExcelUtilityMethod.SetProperty(addedChartObject, "ChartType", new object[] { use_ChartType });
            //图表位置
            ExcelUtilityMethod.UseMethod(addedChartObject, "Location", new object[] { use_XlLocation });
            return(new Chart(addedChartObject));
        }
示例#5
0
    public void Chart_Hinzufuegen(string DiagrammTitle, string TextXAchse, string TextYAchse, Microsoft.Office.Interop.Excel.XlChartType ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlXYScatter)
    {
        this.CanClose   = true;
        this.XlWorkBook = XlApp.Workbooks.Add();

        this.XlChart                 = XlWorkBook.Charts.Add();
        this.XlChart.HasTitle        = true;
        this.XlChart.ChartTitle.Text = DiagrammTitle;
        this.XlChart.ChartType       = ChartType;


        this.XlChart.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary).HasTitle       = true;
        this.XlChart.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlValue, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = TextYAchse;

        this.XlChart.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary).HasTitle       = true;
        this.XlChart.Axes(Microsoft.Office.Interop.Excel.XlAxisType.xlCategory, Microsoft.Office.Interop.Excel.XlAxisGroup.xlPrimary).AxisTitle.Text = TextXAchse;
    }