예제 #1
0
        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);
        }
예제 #2
0
        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];
            }
        }
예제 #3
0
        public void CopyPasteSameRowHeigh(IVTRange range, int firstRow, bool copyStyleOnly = false)
        {
            NativeExcel.IRange iRange = range.Range;
            int firstColumn           = iRange.Column;

            CopyPasteSameRowHeigh(range, firstRow, firstColumn, copyStyleOnly);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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();
        }
예제 #9
0
        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);
        }
예제 #10
0
        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];
            }
        }
예제 #11
0
 public void PasteRange(IVTRange sourceRange, IVTRange targerRange)
 {
     NativeExcel.IRange iRange = sourceRange.Range;
     iRange.Copy(targerRange.Range, XlPasteType.xlPasteAll);
 }
예제 #12
0
        public void CopyPasteSameSize(IVTRange range, string cell)
        {
            VTVector vec = new VTVector(cell);

            CopyPasteSameSize(range, vec.X, vec.Y);
        }