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 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 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); }