Exemplo n.º 1
0
        protected bool AdjustRegionRelativeReference(Ptg[] ptgs, CellReference target, CellRangeAddressBase region)
        {
            if (!region.IsInRange(target))
            {
                throw new ArgumentException(target + " is not within " + region);
            }

            //return adjustRegionRelativeReference(ptgs, target.getRow() - region.getFirstRow(), target.getCol() - region.getFirstColumn());

            int deltaRow    = target.Row;
            int deltaColumn = target.Col;

            bool shifted = false;

            foreach (Ptg ptg in ptgs)
            {
                // base class for cell reference "things"
                if (ptg is RefPtgBase)
                {
                    RefPtgBase reference = (RefPtgBase)ptg;
                    // re-calculate cell references
                    SpreadsheetVersion version = _workbook.GetSpreadsheetVersion();
                    if (reference.IsRowRelative)
                    {
                        int rowIndex = reference.Row + deltaRow;
                        if (rowIndex > version.MaxRows)
                        {
                            throw new IndexOutOfRangeException(version.Name + " files can only have " + version.MaxRows + " rows, but row " + rowIndex + " was requested.");
                        }
                        reference.Row = rowIndex;
                        shifted       = true;
                    }
                    if (reference.IsColRelative)
                    {
                        int colIndex = reference.Column + deltaColumn;
                        if (colIndex > version.MaxColumns)
                        {
                            throw new IndexOutOfRangeException(version.Name + " files can only have " + version.MaxColumns + " columns, but column " + colIndex + " was requested.");
                        }
                        reference.Column = colIndex;
                        shifted          = true;
                    }
                }
            }
            return(shifted);
        }
Exemplo n.º 2
0
 public SpreadsheetVersion GetSpreadsheetVersion()
 {
     return(_masterBook.GetSpreadsheetVersion());
 }