public bool FindText(string text, bool matchCase, bool matchEntireCellContents, out int row, out int column) { CellRangeEnumerator readEnumerator = this.GetReadEnumerator(); if (!matchCase) { text = text.ToLower(); } while (readEnumerator.MoveNext()) { object obj2 = readEnumerator.CurrentCell.Value; if (obj2 != null) { string str = obj2.ToString(); if (str != null) { if (!matchCase) { str = str.ToLower(); } if (matchEntireCellContents) { if (str != text) { continue; } row = readEnumerator.CurrentRow; column = readEnumerator.CurrentColumn; return(true); } if (str.IndexOf(text) != -1) { row = readEnumerator.CurrentRow; column = readEnumerator.CurrentColumn; return(true); } } } } row = -1; column = -1; return(false); }
public void AutoFit() { int num = 2; CellRangeEnumerator readEnumerator = this.Cells.GetReadEnumerator(); while (readEnumerator.MoveNext()) { object obj2 = readEnumerator.CurrentCell.Value; if (obj2 != null) { string str = obj2.ToString(); if ((str != null) && (str.Length > num)) { num = str.Length; } } } this.width = num * 340; }
public void CopyTo(ExcelWorksheet destinationWorksheet, int absoluteRow, int absoluteColumn) { CellRange range; try { range = destinationWorksheet.Cells.GetSubrangeAbsolute(absoluteRow, absoluteColumn, (absoluteRow + this.Height) - 1, (absoluteColumn + this.Width) - 1); } catch (Exception) { throw new ArgumentException("Destination range is incorrectly specified."); } if (this.Overlaps(range)) { throw new ArgumentException("Destination range can't overlap with source range."); } if (range.IsAnyCellMerged) { throw new ArgumentException("Destination range can't overlap with existing merged range."); } int num = absoluteRow - this.firstRow; int num2 = absoluteColumn - this.firstColumn; Hashtable hashtable = new Hashtable(); CellRangeEnumerator readEnumerator = this.GetReadEnumerator(); while (readEnumerator.MoveNext()) { ExcelCell currentCell = readEnumerator.CurrentCell; ExcelCell cell2 = destinationWorksheet.Rows[readEnumerator.CurrentRow + num].AllocatedCells[readEnumerator.CurrentColumn + num2]; cell2.Value = currentCell.Value; cell2.Style = currentCell.Style; CellRange mergedRange = currentCell.MergedRange; if (mergedRange != null) { hashtable[mergedRange] = (mergedRange); } } foreach (MergedCellRange range3 in hashtable.Values)//.get_Values()) { destinationWorksheet.Cells.GetSubrangeAbsolute(range3.firstRow + num, range3.firstColumn + num2, range3.lastRow + num, range3.lastColumn + num2).Merged = true; } }