Exemplo n.º 1
0
        private void InsertColumns(int colFrom, int cols, ExcelSparkline sl)
        {
            if (cols > 0)
            {
                if (sl.Cell.Column >= colFrom)
                {
                    sl.Cell = new ExcelCellAddress(sl.Cell.Row, sl.Cell.Column + cols);
                }

                var address = sl.GetRangeAddress(_ws.Names);
                if (!(address is ExcelNamedRange))
                {
                    if (colFrom <= address.Start.Column)
                    {
                        var newAddress = ExcelCellBase.GetAddress(address.Start.Row, address.Start.Column + cols, address.End.Row, address.End.Column + cols);
                        sl.RangeAddress = new ExcelAddress(BuildNewAddress(address, newAddress));
                    }
                    else if (colFrom <= address.End.Column && address.End.Column + cols < ExcelPackage.MaxColumns)
                    {
                        var newAddress = ExcelCellBase.GetAddress(address.Start.Row, address.Start.Column, address.End.Row, address.End.Column + cols);
                        sl.RangeAddress = new ExcelAddress(BuildNewAddress(address, newAddress));
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void InsertRows(int rowFrom, int rows, ExcelSparkline sl)
        {
            if (rows > 0)
            {
                if (sl.Cell.Row >= rowFrom)
                {
                    sl.Cell = new ExcelCellAddress(sl.Cell.Row + rows, sl.Cell.Column);
                }

                var address = sl.GetRangeAddress(_ws.Names);
                if (!(address is ExcelNamedRange))
                {
                    if (rowFrom <= address.Start.Row)
                    {
                        var newAddress = ExcelCellBase.GetAddress(address.Start.Row + rows, address.Start.Column, address.End.Row + rows, address.End.Column);
                        var ttt        = new ExcelAddress(BuildNewAddress(address, newAddress));
                        sl.RangeAddress = ttt;
                    }
                    else if (rowFrom <= address.End.Row && address.End.Row + rows <= ExcelPackage.MaxRows)
                    {
                        var newAddress = ExcelCellBase.GetAddress(address.Start.Row, address.Start.Column, address.End.Row + rows, address.End.Column);
                        sl.RangeAddress = new ExcelAddress(BuildNewAddress(address, newAddress));
                    }
                }
            }
        }