//--------------------------------- public static List <ExcelCellInfo> ToCellList(ExcelCell[,] cellsArray, int minRow, int minCol) { if (cellsArray == null || minRow < 1 || minCol < 1) { return(null); } List <ExcelCellInfo> cells = new List <ExcelCellInfo>(); int numRow = cellsArray.GetLength(0); int numCol = cellsArray.GetLength(1); for (int iR = 0; iR < numRow; iR++) { for (int iC = 0; iC < numCol; iC++) { ExcelCell cell = cellsArray [iR, iC]; if (cell.content != "" || cell.format != "" || cell.formula != "") { ExcelCellInfo cellInfo = new ExcelCellInfo(minRow + iR, minCol + iC, cell.content, cell.format, cell.prefix, cell.formula); cells.Add(cellInfo); } } } return(cells); }
public int CompareTo(object obj) { ExcelCellInfo orderToCompare = obj as ExcelCellInfo; if (orderToCompare.row < row) { return(1); } if (orderToCompare.row == row) { if (orderToCompare.col < col) { return(1); } if (orderToCompare.col == col) { return(0); } else { return(-1); } } else { return(-1); } }
public bool IsEqual(ExcelCellInfo other) { if (CompareTo(other) != 0) { return(false); } return((this as ExcelCell) == (other as ExcelCell)); }
public static void Post(string str) { ExcelDataReceiver data = new ExcelDataReceiver(); if (str != "") { string content = str.Replace(codeDollar, "$"); content = content.Replace(codePound, "#"); content = content.Replace(codePrefLeft, "\'"); content = content.Replace(codePrefRight, "\""); content = content.Replace(codePrefBlank, "\\"); if (content.Substring(0, 1) == codeCommand) { if (content.Length == 1 || (content.Length >= 6 && content.Substring(1) == "close")) { DispatchQueue.MainQueue.DispatchAsync(() => { NSNotificationCenter.DefaultCenter.PostNotificationName(notificationExcelClosed, data, null); }); } else { Console.WriteLine("Excel: {0}", content.Substring(1)); } return; } string[] lines = content.Split('\n'); foreach (string strInfo in lines) { if (strInfo != "") { ExcelCellInfo cellInfo = new ExcelCellInfo(strInfo); if (cellInfo.row > 0 && cellInfo.col > 0) { data.dataList.Add(cellInfo); } } } } string notificationName = data.dataList.Count > 0 ? notificationExcelChanged : notificationExcelEmpty; DispatchQueue.MainQueue.DispatchAsync(() => { NSNotificationCenter.DefaultCenter.PostNotificationName(notificationName, data, null); }); }
//------------------------------------- public static bool Compare(List <ExcelCellInfo> list1, List <ExcelCellInfo> list2) { if (list1 == null || list2 == null) { return(false); } if (list1.Count != list2.Count) { return(false); } list1.Sort(); list2.Sort(); for (int i = 0; i < list1.Count; i++) { ExcelCellInfo info1 = list1[i], info2 = list2[i]; if (!info1.IsEqual(info2)) { return(false); } } return(true); }