Пример #1
0
		public DataCellValue AddDataCell(DataCellValue dc)
		{
			if (Cells == null) Cells = new Dictionary<int, DataCellValue>();

			if (Cells.Where(c => c.Value.CellReference == dc.CellReference).Count() > 0)
				throw new Exception("Cell has already been recorded");
			dc.Row = this;
			Cells.Add(dc.field.OutputOrder, dc);

			return dc;
		}
Пример #2
0
		private void ProcessCells(SheetLayout sLayout, WorksheetPart wsp)
		{
			Dictionary<int, Field> cols = new Dictionary<int, Field>();
			sLayout.matchData.fldColMap.colmaps.ForEach(cm => cols.Add(cm.column, cm.field));

			IEnumerable<CellRowCol> tcs = Enumerable.Empty<CellRowCol>();

			switch (sLayout.matchData.fldColMap.colLayout.colLayoutType)
			{
				case ColLayoutType.Row_Col:
					tcs = wsp.Worksheet.Descendants<Cell>()
												.Where(c => c.InnerText.Length > 0)
												.Select(t => new CellRowCol { cell = t, row = GetRowNum(t.CellReference.InnerText), col = GetColumn(t.CellReference.InnerText) })
												.Where(k => k.row >= sLayout.matchData.fldColMap.colLayout.FirstRow && cols.ContainsKey(k.col));
					break;
				case ColLayoutType.Col_Row:
					tcs = wsp.Worksheet.Descendants<Cell>()
												.Where(c => c.InnerText.Length > 0)
												.Select(t => new CellRowCol { cell = t, col = GetRowNum(t.CellReference.InnerText), row = GetColumn(t.CellReference.InnerText) })
												.Where(k => k.row >= sLayout.matchData.fldColMap.colLayout.FirstRow && cols.ContainsKey(k.col));
					break;
			}


			foreach (var tc in tcs)
			{
				try
				{
					string sval = GetCellValue(tc.cell, stringTable.SharedStringTable, cellFormats, cols[tc.col]);
					var dataCell = new DataCellValue { CellReference = tc.cell.CellReference.InnerText, rowNumber = tc.row, colNumber = tc.col, field = cols[tc.col], Value = sval };
					sLayout.dataSet.AddCell(dataCell);
				}
				catch (Exception ex)
				{
					Log.New.Msg(ex);
				}
			}
		}
Пример #3
0
		public DataRow AddCell(DataCellValue dc)
		{
			if (Rows == null) Rows = new Dictionary<int, DataRow>();
			DataRow dr;
			if(Rows.ContainsKey(dc.rowNumber))
				dr = Rows[dc.rowNumber];
			else
			{
				dr = new DataRow(dc.rowNumber);
				dr.Sheet = this;
				Rows.Add(dc.rowNumber, dr);
			}
			dr.AddDataCell(dc);
			return dr;
		}