public ExcelCell this[string address] { get { RowColumn column = ExcelAddress.ToRowColumn(address); return(this[column.Row, column.Column]); } }
public OleDbCell this[string address] { get { RowColumn rc = ExcelAddress.ToRowColumn(address); return(this[rc.Row, rc.Column]); } }
public void CopyTo(string address) { RowColumn column = ExcelAddress.ToRowColumn(address); this.CopyTo(column.Row, column.Column); }
public void Load() { if (this._wsheet.GetOWorksheetPart() != null) { Action <Cell> action = delegate(Cell cell) { RowColumn column = ExcelAddress.ToRowColumn((string)cell.CellReference); CellProxy proxy = this.EnsureCell(column.Row, column.Column); if (cell.DataType != null) { proxy.DataType = new CellValues?(cell.DataType.Value); if (((CellValues)cell.DataType.Value) == CellValues.InlineString) { proxy.Value = cell.InlineString.Text.Text; } else if (cell.CellValue != null) { proxy.Value = cell.CellValue.Text; } else { proxy.Value = string.Empty; } } else if (cell.CellValue != null) { proxy.Value = cell.CellValue.Text; } if (cell.StyleIndex != null) { proxy.StyleIndex = new uint?((uint)cell.StyleIndex); } if (cell.ShowPhonetic != null) { proxy.ShowPhonetic = new bool?((bool)cell.ShowPhonetic); } if (cell.ValueMetaIndex != null) { proxy.ValueMetaIndex = new uint?((uint)cell.ValueMetaIndex); } if (cell.CellFormula != null) { proxy.CreateFormula(); proxy.Formula.Text = cell.CellFormula.Text; proxy.Formula.R1 = (string)cell.CellFormula.R1; proxy.Formula.R2 = (string)cell.CellFormula.R2; proxy.Formula.Reference = (string)cell.CellFormula.Reference; if (cell.CellFormula.AlwaysCalculateArray != null) { proxy.Formula.AlwaysCalculateArray = new bool?((bool)cell.CellFormula.AlwaysCalculateArray); } if (cell.CellFormula.Bx != null) { proxy.Formula.Bx = new bool?((bool)cell.CellFormula.Bx); } if (cell.CellFormula.CalculateCell != null) { proxy.Formula.CalculateCell = new bool?((bool)cell.CellFormula.CalculateCell); } if (cell.CellFormula.DataTable2D != null) { proxy.Formula.DataTable2D = new bool?((bool)cell.CellFormula.DataTable2D); } if (cell.CellFormula.DataTableRow != null) { proxy.Formula.DataTableRow = new bool?((bool)cell.CellFormula.DataTableRow); } if (cell.CellFormula.FormulaType != null) { proxy.Formula.FormulaType = new CellFormulaValues?((CellFormulaValues)cell.CellFormula.FormulaType); } if (cell.CellFormula.Input1Deleted != null) { proxy.Formula.Input1Deleted = new bool?((bool)cell.CellFormula.Input1Deleted); } if (cell.CellFormula.Input2Deleted != null) { proxy.Formula.Input2Deleted = new bool?((bool)cell.CellFormula.Input2Deleted); } if (cell.CellFormula.SharedIndex != null) { proxy.Formula.SharedIndex = new uint?((uint)cell.CellFormula.SharedIndex); } proxy.Value = null; } }; OpenXmlReader reader = OpenXmlReader.Create(this._wsheet.GetOWorksheetPart()); bool flag = false; while (reader.Read()) { if (flag && reader.IsStartElement) { if ((reader.ElementType == typeof(Row)) && reader.IsStartElement) { Row row = (Row)reader.LoadCurrentElement(); if ((from a in row.GetAttributes() let ln = a.LocalName where (ln != "r") && (ln != "spans") select a).Any <OpenXmlAttribute>()) { this._cachedRows.Add((uint)row.RowIndex, (Row)row.CloneNode(false)); } foreach (Cell cell in row.Elements <Cell>()) { action(cell); } } else if (reader.ElementType == typeof(SheetData)) { bool isStartElement = reader.IsStartElement; } else if (reader.IsStartElement) { OpenXmlElement item = reader.LoadCurrentElement(); this._cachedElements.Add(item); } } else if (reader.ElementType == typeof(Worksheet)) { flag = reader.IsStartElement; } } this.Modified = false; } }
public void Load() { WorksheetPart wp = _wsheet.GetOWorksheetPart(); if (wp == null) { return; } Action <Cell> readCell = (cell) => { RowColumn rc = ExcelAddress.ToRowColumn(cell.CellReference); CellProxy cellProxy = this.EnsureCell(rc.Row, rc.Column); if (cell.DataType != null) { cellProxy.DataType = cell.DataType.Value; if (cell.DataType.Value == CellValues.InlineString) { cellProxy.Value = cell.InlineString.Text.Text; } else { if (cell.CellValue != null) { cellProxy.Value = cell.CellValue.Text; } else { cellProxy.Value = string.Empty; } } } else { if (cell.CellValue != null) { cellProxy.Value = cell.CellValue.Text; } } if (cell.StyleIndex != null) { cellProxy.StyleIndex = cell.StyleIndex; } if (cell.ShowPhonetic != null) { cellProxy.ShowPhonetic = cell.ShowPhonetic; } if (cell.ValueMetaIndex != null) { cellProxy.ValueMetaIndex = cell.ValueMetaIndex; } if (cell.CellFormula != null) { cellProxy.CreateFormula(); cellProxy.Formula.Text = cell.CellFormula.Text; cellProxy.Formula.R1 = cell.CellFormula.R1; cellProxy.Formula.R2 = cell.CellFormula.R2; cellProxy.Formula.Reference = cell.CellFormula.Reference; if (cell.CellFormula.AlwaysCalculateArray != null) { cellProxy.Formula.AlwaysCalculateArray = cell.CellFormula.AlwaysCalculateArray; } if (cell.CellFormula.Bx != null) { cellProxy.Formula.Bx = cell.CellFormula.Bx; } if (cell.CellFormula.CalculateCell != null) { cellProxy.Formula.CalculateCell = cell.CellFormula.CalculateCell; } if (cell.CellFormula.DataTable2D != null) { cellProxy.Formula.DataTable2D = cell.CellFormula.DataTable2D; } if (cell.CellFormula.DataTableRow != null) { cellProxy.Formula.DataTableRow = cell.CellFormula.DataTableRow; } if (cell.CellFormula.FormulaType != null) { cellProxy.Formula.FormulaType = cell.CellFormula.FormulaType; } if (cell.CellFormula.Input1Deleted != null) { cellProxy.Formula.Input1Deleted = cell.CellFormula.Input1Deleted; } if (cell.CellFormula.Input2Deleted != null) { cellProxy.Formula.Input2Deleted = cell.CellFormula.Input2Deleted; } if (cell.CellFormula.SharedIndex != null) { cellProxy.Formula.SharedIndex = cell.CellFormula.SharedIndex; } cellProxy.Value = null; // Don't cache/store values for formulas } }; OpenXmlReader reader = OpenXmlReader.Create(_wsheet.GetOWorksheetPart()); bool inWorksheet = false; bool inSheetData = false; while (reader.Read()) { if (inWorksheet && reader.IsStartElement) { if (reader.ElementType == typeof(Row) && reader.IsStartElement) { // ---------------------------------------- // Scan row if anything other than RowIndex and Spans has been set, // if so then cache Row r = (Row)reader.LoadCurrentElement(); var needToCacheRow = (from a in r.GetAttributes() let ln = a.LocalName where ln != "r" && ln != "spans" select a).Any(); if (needToCacheRow) { _cachedRows.Add(r.RowIndex, (Row)r.CloneNode(false)); } foreach (Cell cell in r.Elements <Cell>()) { readCell(cell); } // ---------------------------------------- } else if (reader.ElementType == typeof(SheetData)) { inSheetData = reader.IsStartElement; } else if (reader.IsStartElement) { var e = reader.LoadCurrentElement(); _cachedElements.Add(e); } } else if (reader.ElementType == typeof(Worksheet)) { inWorksheet = reader.IsStartElement; } } // Reset modified to false (loading sets it to true due to CellProxy loading) this.Modified = false; }
public void CopyTo(string address) { RowColumn rc = ExcelAddress.ToRowColumn(address); CopyTo(rc.Row, rc.Column); }