using GoldPrinter.ExcelConstants; using Microsoft.Office.Interop.Excel; using System; using System.Data; using System.Drawing; namespace GoldPrinter { public class ExcelAccess : ExcelBase { public void MergeCells(int p_startRowIndex, int p_startColIndex, int p_endRowIndex, int p_endColIndex) { base.MergeCells(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex)); } public void MergeCells(int p_startRowIndex, string p_startColChars, int p_endRowIndex, string p_endColChars) { base.MergeCells(base.GetRange(p_startRowIndex, p_startColChars, p_endRowIndex, p_endColChars)); } public void SetFont(int p_startRowIndex, int p_startColIndex, int p_endRowIndex, int p_endColIndex, System.Drawing.Font p_Font) { base.SetFont(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), p_Font, Color.Black); } public void SetBordersEdge(int p_rowIndex, int p_colIndex, BordersEdge p_BordersEdge, BordersLineStyle p_BordersLineStyle, BordersWeight p_BordersWeight) { base.SetBordersEdge(base.GetRange(p_rowIndex, p_colIndex), p_BordersEdge, p_BordersLineStyle, p_BordersWeight); } public void SetBordersEdge(int p_rowIndex, string p_colChars, BordersEdge p_BordersEdge, BordersLineStyle p_BordersLineStyle, BordersWeight p_BordersWeight) { base.SetBordersEdge(base.GetRange(p_rowIndex, p_colChars), p_BordersEdge, p_BordersLineStyle, p_BordersWeight); } public void SetBordersEdge(int p_startRowIndex, int p_startColIndex, int p_endRowIndex, int p_endColIndex, BordersEdge p_BordersEdge, BordersLineStyle p_BordersLineStyle, BordersWeight p_BordersWeight) { base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), p_BordersEdge, p_BordersLineStyle, p_BordersWeight); } public void SetBordersEdge(int p_startRowIndex, string p_startColChars, int p_endRowIndex, string p_endColChars, BordersEdge p_BordersEdge, BordersLineStyle p_BordersLineStyle, BordersWeight p_BordersWeight) { base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColChars, p_endRowIndex, p_endColChars), p_BordersEdge, p_BordersLineStyle, p_BordersWeight); } public void SetBordersEdge(int p_startRowIndex, int p_startColIndex, int p_endRowIndex, int p_endColIndex, bool IsBordersOrBordersGrid) { base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), BordersEdge.xlLeft); base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), BordersEdge.xlTop); base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), BordersEdge.xlRight); base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), BordersEdge.xlBottom); if (!IsBordersOrBordersGrid) { base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), BordersEdge.xlInsideHorizontal); base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), BordersEdge.xlInsideVertical); } } public void ClearBordersEdge(int p_rowIndex, int p_colIndex) { base.SetBordersEdge(base.GetRange(p_rowIndex, p_colIndex), BordersEdge.xlLineStyleNone); } public void ClearBordersEdge(int p_rowIndex, string p_colChars) { base.SetBordersEdge(base.GetRange(p_rowIndex, p_colChars), BordersEdge.xlLineStyleNone); } public void ClearBordersEdge(int p_startRowIndex, int p_startColIndex, int p_endRowIndex, int p_endColIndex) { base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex), BordersEdge.xlLineStyleNone); } public void ClearBordersEdge(int p_startRowIndex, string p_startColChars, int p_endRowIndex, string p_endColChars) { base.SetBordersEdge(base.GetRange(p_startRowIndex, p_startColChars, p_endRowIndex, p_endColChars), BordersEdge.xlLineStyleNone); } public string GetCellText(int p_rowIndex, int p_colIndex) { Range range = base.GetRange(p_rowIndex, p_colIndex); return range.Text.ToString(); } public string GetCellText(int p_rowIndex, string p_colChars) { Range range = base.GetRange(p_rowIndex, p_colChars); return range.Text.ToString(); } public void SetCellText(int p_rowIndex, int p_colIndex, string p_text) { Range range = base.GetRange(p_rowIndex, p_colIndex); range.Cells.FormulaR1C1 = p_text; } public void SetCellText(int p_rowIndex, string p_colChars, string p_text) { Range range = base.GetRange(p_rowIndex, p_colChars); range.Cells.FormulaR1C1 = p_text; } public void SetCellText(int p_startRowIndex, int p_startColIndex, int p_endRowIndex, int p_endColIndex, string p_text) { Range range = base.GetRange(p_startRowIndex, p_startColIndex, p_endRowIndex, p_endColIndex); range.Cells.FormulaR1C1 = p_text; } public void SetCellText(int p_startRowIndex, string p_startColChars, int p_endRowIndex, string p_endColChars, string p_text) { Range range = base.GetRange(p_startRowIndex, p_startColChars, p_endRowIndex, p_endColChars); range.Cells.FormulaR1C1 = p_text; } public void SetCellText(System.Data.DataTable p_DataTable, int p_startExcelRowIndex, int p_startExcelColIndex, bool IsDrawGridLine) { for (int i = 0; i < p_DataTable.Rows.Count; i++) { for (int j = 0; j < p_DataTable.Columns.Count; j++) { this.SetCellText(p_startExcelRowIndex + i, p_startExcelColIndex + j, p_DataTable.Rows[i][j].ToString()); } } if (IsDrawGridLine) { this.SetBordersEdge(p_startExcelRowIndex, p_startExcelColIndex, p_startExcelRowIndex + p_DataTable.Rows.Count - 1, p_startExcelColIndex + p_DataTable.Columns.Count - 1, false); } } } }