public void CopyAndInsertARow(IVTRange copiedRow, int insertRow, bool copyStyleOnly = false) { IRange aboveRange = Worksheet.Range["A" + insertRow, "A" + insertRow]; aboveRange.EntireRow.Insert(XlInsertShiftDirection.xlShiftDown); CopyPasteSameSize(copiedRow, insertRow, 1); }
public void CopyPasteSameSize(IVTRange range, int firstRow, int firstColumn) { NativeExcel.IRange iRange = range.Range; NativeExcel.IRange oRange = Worksheet.Range[firstRow, firstColumn, firstRow + iRange.Rows.Count - 1, firstColumn + iRange.Columns.Count - 1]; iRange.Copy(oRange, NativeExcel.XlPasteType.xlPasteAll); List <double> listHeight = new List <double>(); for (int i = 1; i <= iRange.Rows.Count; i++) { listHeight.Add(iRange.Rows[i].RowHeight); } for (int i = 1; i <= iRange.Rows.Count; i++) { oRange.Rows[i].RowHeight = listHeight[i - 1]; } List <double> listWidth = new List <double>(); for (int i = 1; i <= iRange.Columns.Count; i++) { listWidth.Add(iRange.Columns[i].ColumnWidth); } for (int i = 1; i <= iRange.Columns.Count; i++) { oRange.Columns[i].ColumnWidth = listWidth[i - 1]; } }
public void CopyPasteSameRowHeigh(IVTRange range, int firstRow, bool copyStyleOnly = false) { NativeExcel.IRange iRange = range.Range; int firstColumn = iRange.Column; CopyPasteSameRowHeigh(range, firstRow, firstColumn, copyStyleOnly); }
public IVTWorksheet CopySheetToBefore(IVTRange worksheetRange, int index, string sheetname = "") { NativeExcel.IWorksheet sheet = Workbook.Worksheets.AddBefore(index); IVTWorksheet vtSheet = new VTWorksheet(sheet); vtSheet.CopyPasteSameSize(worksheetRange, 1, 1); vtSheet.Name = sheetname; return(vtSheet); }
public void CopySheet(IVTWorksheet worksheet, string lastCell) { NativeExcel.IWorksheet templateSheet = worksheet.Worksheet; NativeExcel.IRange usedRang = templateSheet.UsedRange; IVTRange vtRange = worksheet.GetRange("A1", lastCell); CopyPasteSameSize(vtRange, 1, 1); CopyPageSetup(templateSheet); }
public void CopySheet(IVTWorksheet worksheet) { NativeExcel.IWorksheet templateSheet = worksheet.Worksheet; NativeExcel.IRange usedRang = templateSheet.UsedRange; IVTRange vtRange = worksheet.GetRange(1, 1, usedRang.Rows.Count + usedRang.Row - 1, usedRang.Columns.Count + 1); CopyPasteSameSize(vtRange, 1, 1); CopyPageSetup(templateSheet); }
public void CopyPaste(IVTRange range, int firstRow, int firstColumn, bool copyStyleOnly = false) { NativeExcel.IRange iRange = range.Range; NativeExcel.IRange oRange = Worksheet.Range[firstRow, firstColumn, firstRow + iRange.Rows.Count - 1, firstColumn + iRange.Columns.Count - 1]; XlPasteType type = copyStyleOnly ? XlPasteType.xlPasteFormats : XlPasteType.xlPasteAll; iRange.Copy(oRange, type); }
public void CutPaste(IVTRange range, int firstRow, int firstColumn) { NativeExcel.IRange iRange = range.Range; NativeExcel.IRange oRange = Worksheet.Range[firstRow, firstColumn, firstRow + iRange.Rows.Count - 1, firstColumn + iRange.Columns.Count - 1]; XlPasteType type = XlPasteType.xlPasteAll; iRange.Copy(oRange, type); oRange.Delete(); }
public void CopyAndInsertARow(int copiedRow, int insertRow, bool copyStyleOnly = false) { if (copiedRow >= insertRow) { copiedRow++; } IRange aboveRange = Worksheet.Range["A" + insertRow, "A" + insertRow]; aboveRange.EntireRow.Insert(XlInsertShiftDirection.xlShiftDown); IVTRange copiedRange = GetRange(copiedRow, 1, copiedRow, Worksheet.UsedRange.Columns.Count + Worksheet.UsedRange.Column); CopyPasteSameSize(copiedRange, insertRow, 1); }
public void CopyPasteSameColumnWidth(IVTRange range, int firstRow, int firstColumn, bool copyStyleOnly = false) { NativeExcel.IRange iRange = range.Range; NativeExcel.IRange oRange = Worksheet.Range[firstRow, firstColumn, firstRow + iRange.Rows.Count - 1, firstColumn + iRange.Columns.Count - 1]; XlPasteType type = copyStyleOnly ? NativeExcel.XlPasteType.xlPasteFormats : NativeExcel.XlPasteType.xlPasteAll; iRange.Copy(oRange, type); List <double> listWidth = new List <double>(); for (int i = 1; i <= iRange.Columns.Count; i++) { listWidth.Add(iRange.Columns[i].ColumnWidth); } for (int i = 1; i <= iRange.Columns.Count; i++) { oRange.Columns[i].ColumnWidth = listWidth[i - 1]; } }
public void PasteRange(IVTRange sourceRange, IVTRange targerRange) { NativeExcel.IRange iRange = sourceRange.Range; iRange.Copy(targerRange.Range, XlPasteType.xlPasteAll); }
public void CopyPasteSameSize(IVTRange range, string cell) { VTVector vec = new VTVector(cell); CopyPasteSameSize(range, vec.X, vec.Y); }