void PrepareSharedStringTable() { var sslist = _sharedStringTable.Elements <SharedStringItem>().ToList(); for (Int32 i = 0; i < sslist.Count; i++) { var ssitem = sslist[i]; String str = ssitem.Text.Text; if (!str.StartsWith("{")) { continue; } if (_sharedStringMap == null) { _sharedStringMap = new Dictionary <String, SharedStringDef>(); } if (_sharedStringIndexMap == null) { _sharedStringIndexMap = new Dictionary <Int32, SharedStringDef>(); } var ssd = new SharedStringDef(ssitem, i); _sharedStringMap.Add(str, ssd); _sharedStringIndexMap.Add(i, ssd); } }
void SetCellData(Cell cell, ExpandoObject data) { if (cell.DataType == null) { return; } if (cell.DataType != CellValues.SharedString) { return; } if (_sharedStringIndexMap == null) { return; } String addr = cell.CellValue.Text.ToString(); // this is the line number from SharedStrings if (!Int32.TryParse(addr, out Int32 strIndex)) { return; } if (!_sharedStringIndexMap.ContainsKey(strIndex)) { return; } SharedStringDef ssd = _sharedStringIndexMap[strIndex]; if (ssd == null) { return; } if (ssd.Parse()) { Object dat = _dataModel.Eval <Object>(data, ssd.Expression); SetCellValueData(cell, dat); } }