void TransposeSheet(ref DataTable dataSheet) { S8Spreadsheet sheet = (S8Spreadsheet)this.SelectedVariable.Value; foreach (var cell in sheet.Cells) { dataSheet.Rows[cell.Row - 1][cell.Col - 1] = cell.Value.ToString(); } }
void CreateTableRows(ref DataTable dataSheet) { S8Spreadsheet sheet = (S8Spreadsheet)this.SelectedVariable.Value; for (int i = 1; i <= sheet.RowCount; i++) { dataSheet.Rows.Add(dataSheet.NewRow()); } }
public object Clone() { S8Spreadsheet newSheet = new S8Spreadsheet(); newSheet.RowCount = this.RowCount; newSheet.ColCount = this.ColCount; foreach(S8Spreadsheet.Cell c in this.Cells){ newSheet.Cells.Add(new Cell{CellType = c.CellType, Row = c.Row, Col = c.Col, Value = c.Value}); } return newSheet; }
protected IEnumerable <XElement> WriteCells() { S8Spreadsheet sheet = (S8Spreadsheet)ToWrite.Value; var cells = from cell in sheet.Cells select new XElement("Cell", new XAttribute("Type", ((int)cell.CellType).ToString()), new XAttribute("Row", cell.Row.ToString()), new XAttribute("Col", cell.Col.ToString()), cell.Value); return(cells); }
public object Clone() { S8Spreadsheet newSheet = new S8Spreadsheet(); newSheet.RowCount = this.RowCount; newSheet.ColCount = this.ColCount; foreach (S8Spreadsheet.Cell c in this.Cells) { newSheet.Cells.Add(new Cell { CellType = c.CellType, Row = c.Row, Col = c.Col, Value = c.Value }); } return(newSheet); }
/// <summary> /// This should probably be encapsulated out /// </summary> /// <returns></returns> protected XElement WriteSpreadsheet() { S8Spreadsheet sheet = (S8Spreadsheet)ToWrite.Value; XElement xVar = new XElement("Variable", new XAttribute("ID", ToWrite.ID.ToString()), new XAttribute("Name", ToWrite.Name), new XAttribute("Type", ((int)ToWrite.PackageVariableType).ToString()), new XElement("Notes", ToWrite.Notes), new XElement("Cols", sheet.ColCount.ToString()), new XElement("Rows", sheet.RowCount.ToString())); xVar.Add(WriteCells().Select(s => s)); return(xVar); }
public void UpdateCells() { int row = 0; S8Spreadsheet sheet = (S8Spreadsheet)this.SelectedVariable.Value; foreach (DataRow dRow in this.dataSheet.Rows) { for (int col = 0; col < dataSheet.Columns.Count; col++) { sheet.GetCell(row + 1, col + 1).Value = dRow[col].ToString(); } row++; } this.HasUpdates = false; }
public void ShowVariableDetails() { S8Spreadsheet sheet = (S8Spreadsheet)this.SelectedVariable.Value; DataGridTableStyle style = new DataGridTableStyle(); style.MappingName = TABLE_NAME; style.AllowSorting = false; CreateTableCols(ref dataSheet, ref style); CreateTableRows(ref dataSheet); TransposeSheet(ref dataSheet); BindToDataSource(); this.dataGrid1.TableStyles.Add(style); this.HasUpdates = false; }
void CreateTableCols(ref DataTable dataSheet, ref DataGridTableStyle style) { S8Spreadsheet sheet = (S8Spreadsheet)this.SelectedVariable.Value; int maxCol = sheet.LastColContainingData(); style.GridColumnStyles.Clear(); for (int i = 1; i <= maxCol; i++) { dataSheet.Columns.Add("column" + i.ToString(), typeof(string)); DataGridColumnStyle c = new DataGridTextBoxColumn(); c.MappingName = "column" + i.ToString(); c.NullText = ""; if (null == style.GridColumnStyles[c.MappingName]) { style.GridColumnStyles.Add(c); } } }
public void Update(Variable source, Variable destination) { S8Spreadsheet sourceSheet = (S8Spreadsheet)source.Value; S8Spreadsheet destinationSheet = (S8Spreadsheet)destination.Value; foreach (S8Spreadsheet.Cell cell in sourceSheet) { try{ S8Spreadsheet.Cell toUpdate = destinationSheet.GetCell(cell.Row, cell.Col); toUpdate.Value = cell.Value; }catch (ArgumentOutOfRangeException) { destinationSheet.Cells.Add(new S8Spreadsheet.Cell() { Row = cell.Row, Col = cell.Col, Value = cell.Value }); } } destination.Value = destinationSheet; }