///<summary> ///Convert formula token to string representation. ///</summary> ///<returns>formula token string representation</returns> public override string ToString() { string text1 = this.IsRowRelative ? ExcelRowCollection.RowIndexToName(this.row) : (RefFormulaToken.AbsoluteCellMark + ExcelRowCollection.RowIndexToName(this.row)); string text2 = this.IsColumnRelative ? ExcelColumnCollection.ColumnIndexToName(this.column) : (RefFormulaToken.AbsoluteCellMark + ExcelColumnCollection.ColumnIndexToName(this.column)); return(text2 + text1); }
// Properties ///<summary> ///Gets the column with the specified name. ///</summary> ///<param name="name">The name of the column.</param> ///<example> Look at following code for cell referencing examples: ///<code lang="Visual Basic"> ///Dim ws As ExcelWorksheet = excelFile.Worksheets.ActiveWorksheet /// ///ws.Cells("B2").Value = "Cell B2." ///ws.Cells(6, 0).Value = "Cell in row 7 and column A." /// ///ws.Rows(2).Cells(0).Value = "Cell in row 3 and column A." ///ws.Rows("4").Cells("B").Value = "Cell in row 4 and column B." /// ///ws.Columns(2).Cells(4).Value = "Cell in column C and row 5." ///ws.Columns("AA").Cells("6").Value = "Cell in AA column and row 6." ///</code> ///<code lang="C#"> ///ExcelWorksheet ws = excelFile.Worksheets.ActiveWorksheet; /// ///ws.Cells["B2"].Value = "Cell B2."; ///ws.Cells[6,0].Value = "Cell in row 7 and column A."; /// ///ws.Rows[2].Cells[0].Value = "Cell in row 3 and column A."; ///ws.Rows["4"].Cells["B"].Value = "Cell in row 4 and column B."; /// ///ws.Columns[2].Cells[4].Value = "Cell in column C and row 5."; ///ws.Columns["AA"].Cells["6"].Value = "Cell in AA column and row 6."; ///</code> ///</example> public ExcelColumn this[string name] { get { return(this[ExcelColumnCollection.ColumnNameToIndex(name)]); } }
internal ExcelColumnCollection(ExcelWorksheet parent, ExcelColumnCollection sourceColumns) : base(parent) { base.MaxOutlineLevel = sourceColumns.MaxOutlineLevel; foreach (ExcelColumn column1 in sourceColumns) { base.Items.Add(new ExcelColumn(this, column1)); } }
public static void SetAreaColumns(string value, out byte firstColumn, out byte lastColumn) { firstColumn = 0; lastColumn = 0; Match match1 = AreaFormulaToken.IsCellRangeRegex.Match(value); firstColumn = (byte)ExcelColumnCollection.ColumnNameToIndex(match1.Groups["Column1"].Value); lastColumn = (byte)ExcelColumnCollection.ColumnNameToIndex(match1.Groups["Column2"].Value); }
///<summary> ///Convert formula token to string representation. ///</summary> ///<returns>formula token string representation</returns> public override string ToString() { string text1 = this.IsFirstRowRelative ? ExcelRowCollection.RowIndexToName(this.FirstRow) : (RefFormulaToken.AbsoluteCellMark + ExcelRowCollection.RowIndexToName(this.FirstRow)); string text2 = this.IsLastRowRelative ? ExcelRowCollection.RowIndexToName(this.LastRow) : (RefFormulaToken.AbsoluteCellMark + ExcelRowCollection.RowIndexToName(this.LastRow)); string text3 = this.IsFirstColumnRelative ? ExcelColumnCollection.ColumnIndexToName(this.FirstColumn) : (RefFormulaToken.AbsoluteCellMark + ExcelColumnCollection.ColumnIndexToName(this.FirstColumn)); string text4 = this.IsLastColumnAbsolute ? ExcelColumnCollection.ColumnIndexToName(this.LastColumn) : (RefFormulaToken.AbsoluteCellMark + ExcelColumnCollection.ColumnIndexToName(this.LastColumn)); string[] textArray1 = new string[] { text3, text1, ":", text4, text2 }; return(string.Concat(textArray1)); }
private void AdjustArraySize(int index) { if (index > (base.Items.Count - 1)) { ExcelColumnCollection.ExceptionIfColumnOutOfRange(index); int num2 = index - (base.Items.Count - 1); for (int num1 = 0; num1 < num2; num1++) { base.Items.Add(new ExcelColumn(this, base.Items.Count)); } } }
private void SetColumn(string column) { if (column[0] == RefFormulaToken.AbsoluteCellMark) { this.IsColumnRelative = false; column = column.Substring(1); } else { this.IsColumnRelative = true; } this.column = (byte)ExcelColumnCollection.ColumnNameToIndex(column); }
///<summary> ///Converts column name ("A", "B", ...) to column index (0, 1, ...). ///</summary> ///<param name="name">Column name.</param> public static int ColumnNameToIndex(string name) { int num1 = -1; if (name.Length == 1) { num1 = ExcelColumnCollection.GetLetterIndex(name[0]); } else if (name.Length == 2) { num1 = ((ExcelColumnCollection.GetLetterIndex(name[0]) + 1) * 0x1a) + ExcelColumnCollection.GetLetterIndex(name[1]); } if ((num1 < 0) || (num1 > 0xff)) { throw new ArgumentOutOfRangeException("name", name, "Column name must be one-letter or two-letter name from A to IV."); } return(num1); }
private static bool IsValidCell(Match regexMatch) { string text1 = regexMatch.Groups["Row"].Value; if (text1[0] == RefFormulaToken.AbsoluteCellMark) { text1 = text1.Remove(0, 1); } string text2 = regexMatch.Groups["Column"].Value; if (text2[0] == RefFormulaToken.AbsoluteCellMark) { text2 = text2.Remove(0, 1); } if (RefFormulaToken.IsColumnValid(ExcelColumnCollection.ColumnNameToIndex(text2))) { return(RefFormulaToken.IsRowValid(ExcelRowCollection.RowNameToIndex(text1))); } return(false); }
internal ExcelColumn(ExcelColumnCollection parent, int index) : base(parent, index) { this.width = -1; }
// Methods internal ExcelColumn(ExcelColumnCollection parent, ExcelColumn sourceColumn) : base(parent, sourceColumn) { this.width = -1; this.width = sourceColumn.width; this.hidden = sourceColumn.hidden; }
public static byte CellToColumn(string value) { return((byte)ExcelColumnCollection.ColumnNameToIndex(RefFormulaToken.IsCellRegex.Match(value).Groups["Column"].Value)); }