using System; using System.Collections.Generic; using System.Text; namespace Biff8Excel.Excel { public class Helper:IDisposable { WorkSheetCollection m_workSheets; //reference to the worksheets collection public string ConvertColRowToRef(ushort columnNumer, ushort rowNumber) { return ConvertColRowToRef(columnNumer, rowNumber, -1); } public string ConvertColRowToRef(ushort columnNumer, ushort rowNumber, int sheet) { // Columns are zero based ,sheet 1 based string s = ""; //ExcelWorksheet ws; if (sheet != -1) { if (sheet == 0) sheet = 1; s = m_workSheets[sheet].SheetName + "!"; } return s + Globals.ConvertColNumToString(columnNumer) + rowNumber.ToString(); } public string ConverColRowToAreaRef(ushort columnFrom, ushort rowFrom, ushort columnTo, ushort rowTo) { return ConverColRowToAreaRef(columnFrom, rowFrom, columnTo, rowTo,null,null); } public string ConverColRowToAreaRef(ushort columnFrom, ushort rowFrom, ushort columnTo, ushort rowTo, string sheetFrom, string sheetTo) { // Row and Columns are zero based, sheet 1 based string s = ""; string sheetsFrom = ""; string sheetFromTo = ""; if (sheetFrom != null) { if (sheetFrom == "0") sheetFrom = "1"; sheetsFrom = m_workSheets[sheetFrom].SheetName; } if (sheetTo != null) { if (sheetTo.ToString() == "0") sheetTo = "1"; if (sheetsFrom.Length > 0) sheetFromTo = sheetsFrom + ":" + m_workSheets[sheetTo].SheetName; else sheetFromTo = m_workSheets[sheetTo].SheetName; } if (sheetFromTo.Length > 0 ) s = sheetFromTo + "!" + Globals.ConvertColNumToString(columnFrom) + rowFrom.ToString() + ":" + Globals.ConvertColNumToString(columnTo) + rowTo.ToString(); else s = Globals.ConvertColNumToString(columnFrom) + rowFrom.ToString() + ":" + Globals.ConvertColNumToString(columnTo) + rowTo.ToString(); return s; } internal WorkSheetCollection ExcelWorkSheets { set { m_workSheets = value; } } #region IDisposable ³ΙΤ± public void Dispose() { m_workSheets = null; } #endregion } }