internal override void Execute(ExcelFile Workbook, TWaitingCoords Coords, TBand Band) { int t, l, b, r; GetBounds(Coords, out t, out l, out b, out r); int fr = Math.Min(t, b); int fc = Math.Min(l, r); int lr = Math.Max(t, b); int lc = Math.Max(l, r); TValueAndXF val = new TValueAndXF(); val.Workbook = Workbook; XFDef.Evaluate(0, 0, 0, 0, val); TConfigFormat fmt = FormatList.GetValue(FlxConvert.ToString(val.Value)); if (fmt.ApplyFmt == null) { Workbook.SetCellFormat(fr, fc, lr, lc, fmt.XF); } else { Workbook.SetCellFormat(fr, fc, lr, lc, Workbook.GetFormat(fmt.XF), fmt.ApplyFmt, fmt.ExteriorBorders); } }
internal override void Execute(ExcelFile Workbook, TWaitingCoords Coords, TBand Band) { int t, l, b, r; GetBounds(Coords, out t, out l, out b, out r); TXlsCellRange rangeToDelete = new TXlsCellRange(t, l, b, r); if (Sheet1 <= 0 || Sheet2 <= 0) { Workbook.DeleteRange(rangeToDelete, InsertMode); } else { Workbook.DeleteRange(Sheet1, Sheet2, rangeToDelete, InsertMode); } if (Sheet1 <= 0 || Sheet2 <= 0 || (Sheet1 <= Workbook.ActiveSheet && Sheet2 >= Workbook.ActiveSheet)) { if (Band != null) { if (InsertMode == TFlxInsertMode.ShiftRangeDown || InsertMode == TFlxInsertMode.ShiftRowDown) { Band.AddTmpExpandedRows(-rangeToDelete.RowCount, Left + Coords.ColOfs, Left + Coords.ColOfs + rangeToDelete.ColCount); Band.TmpPartialRows += -rangeToDelete.RowCount; } else if (InsertMode == TFlxInsertMode.ShiftColRight || InsertMode == TFlxInsertMode.ShiftRangeRight) { Band.AddTmpExpandedCols(-rangeToDelete.ColCount, Top + Coords.RowOfs, Top + Coords.RowOfs + rangeToDelete.RowCount); Band.TmpPartialCols += -rangeToDelete.ColCount; } } } }
private void CopyRowAndColFormat(ExcelFile Workbook, TWaitingCoords Coords, ExcelFile IncludedReport, TXlsCellRange range) { //Columns go before rows. if (CopyColFormats || (InsertMode == TFlxInsertMode.ShiftColRight && (range.Top > 1 || range.Bottom < FlxConsts.Max_Rows + 1))) { for (int c = range.Left; c < range.Right; c++) { if (!IncludedReport.IsNotFormattedCol(c)) { int c1 = c - range.Left + Left + Coords.ColOfs; int cw = IncludedReport.GetColWidth(c); Workbook.SetColWidth(c1, cw); int co = IncludedReport.GetColOptions(c); if (cw != IncludedReport.DefaultColWidth || cw != Workbook.DefaultColWidth) { co |= 0x02; //the column has no standard width. } Workbook.SetColOptions(c1, co); TFlxFormat fmt = IncludedReport.GetFormat(IncludedReport.GetColFormat(c)); fmt.LinkedStyle.AutomaticChoose = false; Workbook.SetColFormat(c1, Workbook.AddFormat(fmt)); if (c1 + 1 <= FlxConsts.Max_Columns) { Workbook.KeepColsTogether(c1, c1 + 1, IncludedReport.GetKeepColsTogether(c), true); } } } } if (CopyRowFormats || (InsertMode == TFlxInsertMode.ShiftRowDown && (range.Left > 1 || range.Right < FlxConsts.Max_Columns + 1))) { for (int r = range.Top; r < range.Bottom; r++) { if (!IncludedReport.IsEmptyRow(r)) { int r1 = r - range.Top + Top + Coords.RowOfs; Workbook.SetRowHeight(r1, IncludedReport.GetRowHeight(r)); Workbook.SetRowOptions(r1, IncludedReport.GetRowOptions(r)); TFlxFormat fmt = IncludedReport.GetFormat(IncludedReport.GetRowFormat(r)); fmt.LinkedStyle.AutomaticChoose = false; Workbook.SetRowFormat(r1, Workbook.AddFormat(fmt)); if (r1 + 1 <= FlxConsts.Max_Rows) { Workbook.KeepRowsTogether(r1, r1 + 1, IncludedReport.GetKeepRowsTogether(r), true); } } } } }
protected void GetBounds(TWaitingCoords Coords, out int t, out int l, out int b, out int r) { if (Range != null) { CalcBounds(Range); } t = Top; if (!RowAbs1) { t += Coords.RowOfs; if (t > Coords.LastRangeRow) { t += Coords.InsRowOfs; } } b = Bottom; if (!RowAbs2) { b += Coords.RowOfs; if (b > Coords.LastRangeRow) { b += Coords.InsRowOfs; } } l = Left; if (!ColAbs1) { l += Coords.ColOfs; if (l > Coords.LastRangeCol) { l += Coords.InsColOfs; } } r = Right; if (!ColAbs2) { r += Coords.ColOfs; if (r > Coords.LastRangeCol) { r += Coords.InsColOfs; } } }
internal override void Execute(ExcelFile Workbook, TWaitingCoords Coords, TBand Band) { Workbook.DeleteRange(new TXlsCellRange(Top + Coords.RowOfs, Left + Coords.ColOfs, LastRow + Coords.RowOfs, Left + Coords.ColOfs), TFlxInsertMode.ShiftRangeRight); Band.AddTmpExpandedCols(-1, Top + Coords.RowOfs, LastRow + Coords.RowOfs); Band.TmpPartialCols -= 1; }
internal override void Execute(ExcelFile Workbook, TWaitingCoords Coords, TBand Band) { ExcelFile IncludedReport = FInclude.Run(); //Workbook.InsertAndCopyRange(IncludedReport.GetNamedRange(FInclude.RangeName, IncludedReport.ActiveSheet), // Top+RowOfs, Left+ColOfs, 1, InsertMode , TRangeCopyMode.All, IncludedReport, IncludedReport.ActiveSheet); //This is to avoid inserting one row more on the include. TXlsNamedRange range = IncludedReport.GetNamedRange(FInclude.RangeName, IncludedReport.ActiveSheet); //We don't want to copy he full range even if using "__". Just *insert* the full range //if (InsertMode == TFlxInsertMode.ShiftRowDown) {range.Left = 1; range.Right = FlxConsts.Max_Columns + 1;} //if (InsertMode == TFlxInsertMode.ShiftColRight) {range.Top = 1; range.Bottom = FlxConsts.Max_Rows + 1;} if (InsertMode == TFlxInsertMode.ShiftColRight || InsertMode == TFlxInsertMode.ShiftRangeRight) { TXlsCellRange rangeToInsert = new TXlsCellRange(range.Top, range.Left, range.Bottom, range.Right - 1); if (InsertMode == TFlxInsertMode.ShiftColRight) { rangeToInsert.Top = 1; rangeToInsert.Bottom = FlxConsts.Max_Rows + 1; } if (range.Left > range.Right) { } // not possible. Workbook.DeleteRange(); else if (range.Left < range.Right) { int CopyTop = Top + Coords.RowOfs; if (InsertMode == TFlxInsertMode.ShiftColRight) { CopyTop = 1; } Workbook.InsertAndCopyRange(rangeToInsert, CopyTop, Left + Coords.ColOfs, 1, InsertMode, TRangeCopyMode.None); if (Band != null) { Band.AddTmpExpandedCols(rangeToInsert.ColCount, Top + Coords.RowOfs, Top + Coords.RowOfs + rangeToInsert.RowCount); Band.TmpPartialCols += rangeToInsert.ColCount; } } CopyRowAndColFormat(Workbook, Coords, IncludedReport, range); if (range.Left <= range.Right) { Workbook.InsertAndCopyRange(range, Top + Coords.RowOfs, Left + Coords.ColOfs, 1, TFlxInsertMode.NoneRight, TRangeCopyMode.AllIncludingDontMoveAndSizeObjects, IncludedReport, IncludedReport.ActiveSheet); } } else { TXlsCellRange rangeToInsert = new TXlsCellRange(range.Top, range.Left, range.Bottom - 1, range.Right); if (InsertMode == TFlxInsertMode.ShiftRowDown) { rangeToInsert.Left = 1; rangeToInsert.Right = FlxConsts.Max_Columns + 1; } if (range.Top > range.Bottom) { } // not possible. Workbook.DeleteRange(); else if (range.Top < range.Bottom) { int CopyLeft = Left + Coords.ColOfs; if (InsertMode == TFlxInsertMode.ShiftRowDown) { CopyLeft = 1; } Workbook.InsertAndCopyRange(rangeToInsert, Top + Coords.RowOfs, CopyLeft, 1, InsertMode, TRangeCopyMode.None); if (Band != null) { Band.AddTmpExpandedRows(rangeToInsert.RowCount, Left + Coords.ColOfs, Left + Coords.ColOfs + rangeToInsert.ColCount); Band.TmpPartialRows += rangeToInsert.RowCount; } } CopyRowAndColFormat(Workbook, Coords, IncludedReport, range); if (range.Top <= range.Bottom) { Workbook.InsertAndCopyRange(range, Top + Coords.RowOfs, Left + Coords.ColOfs, 1, TFlxInsertMode.NoneDown, TRangeCopyMode.AllIncludingDontMoveAndSizeObjects, IncludedReport, IncludedReport.ActiveSheet); } } }
internal abstract void Execute(ExcelFile Workbook, TWaitingCoords Coords, TBand Band);