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]; } }
/// <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; }
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 object GetCellValue(string cell) { NativeExcel.IRange iCell = Worksheet.Range[cell]; object Value; Value = iCell.Value; return(Value); }
public object GetCellValue(int row, int column) { NativeExcel.IRange iCell = Worksheet.Range[row, column]; object Value; Value = iCell.Value; return(Value); }
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; }
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 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 SetCellValue(int row, int column, object value) { NativeExcel.IRange iCell = Worksheet.Range[row, column]; iCell.Formula = value; }
public void SetCellValue(string cell, object value) { NativeExcel.IRange iCell = Worksheet.Range[cell]; iCell.Formula = value; }