获取鼠标位置、C# 获取Excel鼠标位置、获取Excel 光标位置

        /// <summary>
        /// 获取行号
        /// </summary>
        public static void GetCellCode()
        {
            try
            {

                Microsoft.Office.Interop.Excel.ApplicationClass excel = wbb.Application as Microsoft.Office.Interop.Excel.ApplicationClass;

                Microsoft.Office.Interop.Excel.Workbook wb = excel.Workbooks[1];

                //获取鼠标光标位置

               int  _rowIndex = wb.Application.ActiveCell.Row;
               int   _columnIndex = wb.Application.ActiveCell.Column;    

            }
            catch (Exception)
            {

                //throw;
            }

        }

你可能感兴趣的:(Excel)