Exemplo n.º 1
0
 internal void RecalcCellReferences(SheetChange sheetChange)
 {
     foreach (ExcelWorksheet worksheet in this.Workbook.Worksheets)
     {
         worksheet.RecalcCellReferences(sheetChange);
     }
 }
Exemplo n.º 2
0
 internal void RecalcCellReferences(SheetChange sheetChange)
 {
     foreach (var w in this.Workbook.Worksheets)
     {
         w.RecalcCellReferences(sheetChange);
     }
 }
Exemplo n.º 3
0
        public void RecalcCellReferences(SheetChange sheetChange)
        {
            foreach (var i in this.Cells())
            {
                var c = i.Value;
                if (c.Formula != null)
                {
                    c.Formula.Text      = ExcelFormula.TranslateForSheetChange(c.Formula.Text, sheetChange, _wsheet.Name);
                    c.Formula.R1        = ExcelRange.TranslateForSheetChange(c.Formula.R1, sheetChange, _wsheet.Name);
                    c.Formula.R2        = ExcelRange.TranslateForSheetChange(c.Formula.R2, sheetChange, _wsheet.Name);
                    c.Formula.Reference = ExcelRange.TranslateForSheetChange(c.Formula.Reference, sheetChange, _wsheet.Name);
                }
            }

            // Adjust conditional formatting
            List <ConditionalFormatting> cfToRemoveList = new List <ConditionalFormatting>();

            foreach (var cf in this.GetElements <ConditionalFormatting>())
            {
                bool removeCf          = false;
                List <StringValue> lst = new List <StringValue>();
                foreach (var sqrefItem in cf.SequenceOfReferences.Items)
                {
                    string newRef = ExcelRange.TranslateForSheetChange(sqrefItem.Value, sheetChange, _wsheet.Name);
                    if (!newRef.StartsWith("#")) // no error
                    {
                        lst.Add(new StringValue(newRef));
                    }
                    else
                    {
                        cfToRemoveList.Add(cf);
                        removeCf = true;
                        break;
                    }
                }
                if (removeCf)
                {
                    break;
                }
                cf.SequenceOfReferences = new ListValue <StringValue>(lst);
                foreach (var f in cf.Descendants <Formula>())
                {
                    f.Text = ExcelFormula.TranslateForSheetChange(f.Text, sheetChange, _wsheet.Name);
                }
            }
            foreach (ConditionalFormatting cf in cfToRemoveList)
            {
                this.RemoveElement(cf);
            }
        }
Exemplo n.º 4
0
        public void RecalcCellReferences(SheetChange sheetChange)
        {
            foreach (KeyValuePair <ulong, CellProxy> pair in this.Cells())
            {
                CellProxy proxy = pair.Value;
                if (proxy.Formula != null)
                {
                    proxy.Formula.Text      = ExcelFormula.TranslateForSheetChange(proxy.Formula.Text, sheetChange, this._wsheet.Name);
                    proxy.Formula.R1        = ExcelRange.TranslateForSheetChange(proxy.Formula.R1, sheetChange, this._wsheet.Name);
                    proxy.Formula.R2        = ExcelRange.TranslateForSheetChange(proxy.Formula.R2, sheetChange, this._wsheet.Name);
                    proxy.Formula.Reference = ExcelRange.TranslateForSheetChange(proxy.Formula.Reference, sheetChange, this._wsheet.Name);
                }
            }
            List <ConditionalFormatting> list = new List <ConditionalFormatting>();

            foreach (ConditionalFormatting formatting in this.GetElements <ConditionalFormatting>())
            {
                bool flag = false;
                List <StringValue> list2 = new List <StringValue>();
                foreach (StringValue value2 in formatting.SequenceOfReferences.Items)
                {
                    string str = ExcelRange.TranslateForSheetChange(value2.Value, sheetChange, this._wsheet.Name);
                    if (!str.StartsWith("#"))
                    {
                        list2.Add(new StringValue(str));
                    }
                    else
                    {
                        list.Add(formatting);
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    break;
                }
                formatting.SequenceOfReferences = new ListValue <StringValue>(list2);
                foreach (Formula formula in formatting.Descendants <Formula>())
                {
                    formula.Text = ExcelFormula.TranslateForSheetChange(formula.Text, sheetChange, this._wsheet.Name);
                }
            }
            foreach (ConditionalFormatting formatting2 in list)
            {
                this.RemoveElement(formatting2);
            }
        }
 public void DeleteRows(uint rowStart, int qty)
 {
     if (qty < 1)
     {
         throw new ArgumentException("Quantity cannot be less than 0");
     }
     if (qty != 0)
     {
         this._sheetCache.InsertOrDeleteRows(rowStart, -qty, false);
         SheetChange sheetChange = new SheetChange {
             SheetName = this.Name,
             RowStart  = rowStart,
             RowDelta  = -qty
         };
         this.Document.RecalcCellReferences(sheetChange);
     }
 }
 public void PushColumns(uint colStart, int qty)
 {
     if (qty < 1)
     {
         throw new ArgumentException("Quantity cannot be less than 0");
     }
     if (qty != 0)
     {
         this._sheetCache.InsertOrDeleteColumns(colStart, qty, false);
         SheetChange sheetChange = new SheetChange {
             SheetName   = this.Name,
             ColumnStart = colStart,
             ColumnDelta = qty
         };
         this.Document.RecalcCellReferences(sheetChange);
     }
 }
Exemplo n.º 7
0
        public void InsertRows(uint rowStart, int qty)
        {
            if (qty < 1)
            {
                throw new ArgumentException("Quantity cannot be less than 0");
            }
            if (qty == 0)
            {
                return;
            }

            _sheetCache.InsertOrDeleteRows(rowStart, qty, true);

            SheetChange sheetChange = new SheetChange()
            {
                SheetName = this.Name, RowStart = rowStart, RowDelta = qty
            };

            this.Document.RecalcCellReferences(sheetChange);
        }
Exemplo n.º 8
0
 internal void OnSheetChange(object Sh, object Target)
 {
     SheetChange?.Invoke(GetSheet(Sh), GetRange(Target));
 }
Exemplo n.º 9
0
 internal void RecalcCellReferences(SheetChange sheetChange)
 {
     _sheetCache.RecalcCellReferences(sheetChange);
 }