Exemplo n.º 1
0
        public void SetArrayFormula(int sheet, int rowFirst, int rowLast, short colFirst, short colLast, IExcelFormula arrayFormula)
        {
            if (arrayFormula == null)
            {
                throw new ArgumentNullException("arrayFormula");
            }
            if (!arrayFormula.IsArrayFormula)
            {
                throw new ArgumentException(ResourceHelper.GetResourceString("arrayFormulaError"));
            }
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];
            ExcelCellRange  range     = new ExcelCellRange {
                Row        = rowFirst,
                RowSpan    = (rowLast - rowFirst) + 1,
                Column     = colFirst,
                ColumnSpan = (colLast - colFirst) + 1
            };

            for (int i = rowFirst; i <= rowLast; i++)
            {
                for (int j = colFirst; j <= colLast; j++)
                {
                    IExcelCell cell = worksheet.GetCell(i, j, true);
                    cell.CellFormula = arrayFormula;
                    cell.CellFormula.ArrayFormulaRange = range;
                    cell.IsArrayFormula = true;
                    cell.CellType       = CellType.Array;
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Specifies whether this GrepaCity.Excel.ExcelCellRange has the same setting compared with the specified System.Object
        /// </summary>
        /// <param name="obj">The System.Object used to compare</param>
        /// <returns>true if the obj is a ExcelCellRange instance and has the same setting as this Dt.Xls.ExcelCellRange</returns>
        public override bool Equals(object obj)
        {
            if ((obj == null) || !(obj is ExcelCellRange))
            {
                return(false);
            }
            ExcelCellRange range = obj as ExcelCellRange;

            return((((this.Row == range.Row) && (this.Column == range.Column)) && (this.RowSpan == range.RowSpan)) && (this.ColumnSpan == range.ColumnSpan));
        }
Exemplo n.º 3
0
        public bool SetMergeCells(short sheet, int rowStart, int rowEnd, int columnStart, int columnEnd)
        {
            IExcelWorksheet worksheet = this._workbook.Worksheets[sheet];

            if (worksheet.RowCount <= rowEnd)
            {
                worksheet.RowCount = rowEnd + 1;
            }
            if (worksheet.ColumnCount <= columnEnd)
            {
                worksheet.ColumnCount = columnEnd + 1;
            }
            ExcelCellRange range = new ExcelCellRange {
                Row        = rowStart,
                Column     = columnStart,
                RowSpan    = (rowEnd - rowStart) + 1,
                ColumnSpan = (columnEnd - columnStart) + 1
            };

            worksheet.MergedCells.Add(range);
            return(true);
        }