Ejemplo n.º 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="row">从1开始的整数</param>
 /// <param name="col">从1开始的整数</param>
 public ExcelCellPoint(int row, int col)
 {
     Row    = row;
     Col    = col;
     ColStr = ExcelCellPoint.R1C1FormulasReverse(col);
     R1C1   = ExcelCellPoint.R1C1FormulasReverse(col) + row;
 }
Ejemplo n.º 2
0
 ///// <summary>
 /////
 ///// </summary>
 ///// <param name="row">从1开始的整数</param>
 ///// <param name="col">只能是字母</param>
 ///// <param name="r1C1">譬如A2 等</param>
 //public ExcelCellPoint(int row, string col, string r1C1)
 //{
 //    Row = row;
 //    Col = R1C1Formulas(col);
 //    R1C1 = r1C1;
 //}
 public ExcelCellPoint(string r1C1)
 {
     //K3 = row:3, col:11
     r1C1   = r1C1.Split(':')[0].Trim();                        //防止传入 "A1:B3" 这种的配置格式的
     Row    = Convert.ToInt32(RegexHelper.GetLastNumber(r1C1)); //3
     ColStr = RegexHelper.GetFirstStringByReg(r1C1, "[A-Za-z]+");
     Col    = ExcelCellPoint.R1C1Formulas(ColStr);              //K -> 11
     R1C1   = r1C1;
 }
Ejemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="excelAddress"></param>
        public ExcelCellPoint(OfficeOpenXml.ExcelAddress excelAddress)
        {
            //ExcelCellPoint(excelAddress.Address);
            var r1C1 = excelAddress.Address;

            r1C1   = r1C1.Split(':')[0].Trim();                        //防止传入 "A1:B3" 这种的配置格式的
            Row    = Convert.ToInt32(RegexHelper.GetLastNumber(r1C1)); //3
            ColStr = RegexHelper.GetFirstStringByReg(r1C1, "[A-Za-z]+");
            Col    = ExcelCellPoint.R1C1Formulas(ColStr);              //K -> 11
            R1C1   = r1C1;
        }
Ejemplo n.º 4
0
        public ExcelCellRange(string r1c1, ExcelWorksheet ws)
        {
            string _r1c1;

            if (ws != null)
            {
                var ecp = new ExcelCellPoint(r1c1);
                if (!EPPlusHelper.IsMergeCell(ws, ecp.Row, ecp.Col, out var mergeCellAddress))
                {
                    throw new Exception($@"r1c1:{r1c1}不是合并单元格");
                }
                var ea = new ExcelAddress(mergeCellAddress);
                _r1c1 = ea.Address;
            }
            else
            {
                _r1c1 = r1c1;
            }

            this.Range = _r1c1;
            var cellPoints = _r1c1.Split(':');

            if (cellPoints.Length == 1)
            {
                this.Start       = new ExcelCellPoint(cellPoints[0].Trim());
                this.End         = default(ExcelCellPoint);
                this.IntervalCol = 0;
                this.IntervalRow = 0;
                this.IsMerge     = false;
            }
            else if (cellPoints.Length == 2)
            {
                this.Start       = new ExcelCellPoint(cellPoints[0].Trim());
                this.End         = new ExcelCellPoint(cellPoints[1].Trim());
                this.IntervalCol = End.Col - Start.Col;
                this.IntervalRow = End.Row - Start.Row;
                this.IsMerge     = true;
            }
            else
            {
                throw new Exception("程序的配置有问题");
            }
        }