Esempio n. 1
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];
            }
        }
Esempio n. 2
0
 /// <summary>
 ///Lock cell cua hoc sinh mien giam
 /// </summary>
 public void LockCellExemptType(IVTWorksheet workSheet, int row1, int col1, int row2, int col2)
 {
     NativeExcel.IWorksheet templateSheet = workSheet.Worksheet;
     NativeExcel.IRange     usedRang      = templateSheet.Range[row1, col1, row2, col2];
     usedRang.Locked           = true;
     usedRang.EntireRow.Locked = true;
 }
Esempio n. 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);
        }
Esempio n. 4
0
        public object GetCellValue(string cell)
        {
            NativeExcel.IRange iCell = Worksheet.Range[cell];
            object             Value;

            Value = iCell.Value;
            return(Value);
        }
Esempio n. 5
0
        public object GetCellValue(int row, int column)
        {
            NativeExcel.IRange iCell = Worksheet.Range[row, column];
            object             Value;

            Value = iCell.Value;
            return(Value);
        }
Esempio n. 6
0
 public void Lock(IVTWorksheet workSheet, int row1, int col1, int row2, int col2)
 {
     NativeExcel.IWorksheet templateSheet = workSheet.Worksheet;
     NativeExcel.IRange     usedRang      = templateSheet.Range[row1, col1, row2, col2];
     usedRang.Locked         = true;
     usedRang.Font.Color     = System.Drawing.Color.Black;
     usedRang.Interior.Color = System.Drawing.Color.Yellow;
     //usedRang.Font.Strikethrough = true;
 }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
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();
        }
Esempio n. 11
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];
            }
        }
Esempio n. 12
0
 public void PasteRange(IVTRange sourceRange, IVTRange targerRange)
 {
     NativeExcel.IRange iRange = sourceRange.Range;
     iRange.Copy(targerRange.Range, XlPasteType.xlPasteAll);
 }
Esempio n. 13
0
 public void SetCellValue(int row, int column, object value)
 {
     NativeExcel.IRange iCell = Worksheet.Range[row, column];
     iCell.Formula = value;
 }
Esempio n. 14
0
 public void SetCellValue(string cell, object value)
 {
     NativeExcel.IRange iCell = Worksheet.Range[cell];
     iCell.Formula = value;
 }