Example #1
0
        /// <summary>
        /// 自动调整
        /// </summary>
        public void AutoFit()
        {
            object temp = ExcelUtilityMethod.GetProperty(m_range, "EntireColumn");

            ExcelUtilityMethod.UseMethod(temp, "AutoFit", null);
            return;
        }
Example #2
0
        /// <summary>
        /// 获得终止行
        /// </summary>
        /// <returns></returns>
        public int EndRow()
        {
            object tempEnd = ExcelUtilityMethod.GetProperty(m_range, "End",
                                                            new object[] { Microsoft.Office.Interop.Excel.XlDirection.xlDown });

            return((int)ExcelUtilityMethod.GetProperty(tempEnd, "Row"));
        }
Example #3
0
        /// <summary>
        /// 获取一个Range
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Range Range(int row, int column)
        {
            string rangStr    = ExcelUtilityMethod.ConvertToTitle(column + 1) + (row + 1).ToString();
            object tenmpRange = ExcelUtilityMethod.GetProperty(m_workSheet, "Range",
                                                               new object[] { rangStr });

            return(new Range(tenmpRange));
        }
Example #4
0
        /// <summary>
        /// 在此工作表添加一个图片
        /// </summary>
        /// <param name="strTempPath"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="tempImageHeight"></param>
        /// <param name="tempImageWidth"></param>
        /// <returns></returns>
        public Shape AddPicture(string strTempPath, float left, float top, float tempImageHeight, float tempImageWidth)
        {
            object tempShapes = ExcelUtilityMethod.GetProperty(m_workSheet, "Shapes");
            object temp       = ExcelUtilityMethod.UseMethod(tempShapes, "AddPicture", new object[] { strTempPath, Microsoft.Office.Core.MsoTriState.msoFalse, Microsoft.Office.Core.MsoTriState.msoTrue,
                                                                                                      left, top, tempImageWidth, tempImageHeight });

            return(new Shape(temp));
        }
Example #5
0
        /// <summary>
        /// 获取一个Cell
        /// </summary>
        /// <param name="row"></param>
        /// <param name="column"></param>
        /// <returns></returns>
        public dynamic Cell(int row, int column)
        {
            string rangStr    = ExcelUtilityMethod.ConvertToTitle(column + 1) + (row + 1).ToString();
            object tenmpRange = ExcelUtilityMethod.GetProperty(m_workSheet, "Range",
                                                               new object[] { rangStr });

            return(ExcelUtilityMethod.GetProperty(tenmpRange, "Value"));
        }
Example #6
0
        /// <summary>
        /// 获取一个Cell
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public void Cell(int row, int column, dynamic input)
        {
            string rangStr    = ExcelUtilityMethod.ConvertToTitle(column + 1) + (row + 1).ToString();
            object tenmpRange = ExcelUtilityMethod.GetProperty(m_workSheet, "Range",
                                                               new object[] { rangStr });

            ExcelUtilityMethod.SetProperty(tenmpRange, "Value", new object[] { input });
        }
Example #7
0
        /// <summary>
        /// 获取一个Range
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public Range Range(int rowOne, int columnOne, int rowTwo, int columnTwo)
        {
            string rangStrOne = ExcelUtilityMethod.ConvertToTitle(columnOne + 1) + (rowOne + 1).ToString();
            string rangStrTwo = ExcelUtilityMethod.ConvertToTitle(columnTwo + 1) + (rowTwo + 1).ToString();
            string rangStr    = rangStrOne + ":" + rangStrTwo;
            object tenmpRange = ExcelUtilityMethod.GetProperty(m_workSheet, "Range",
                                                               new object[] { rangStr });

            return(new Range(tenmpRange));
        }
Example #8
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));
        }
Example #9
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));
        }
Example #10
0
        /// <summary>
        /// 获得其中一个工作表
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public Worksheet Get_Item(int index)
        {
            object thisObject = ExcelUtilityMethod.GetProperty(m_workSheets, "Item", new object[] { index });

            return(new Worksheet(thisObject));
        }
Example #11
0
 /// <summary>
 /// 获取一个Range
 /// </summary>
 /// <param name="input"></param>
 /// <returns></returns>
 public Range Range(string input)
 {
     return(new Range(ExcelUtilityMethod.GetProperty(m_workSheet, "Range", new object[] { input, Missing.Value })));
 }