public void loadSpreadsheet(Stream s) { XmlReaderSettings settings = new XmlReaderSettings(); XmlReader myReader = XmlReader.Create(s, settings); string cellName = ""; //temp string to get cell name of XML cell and find corresponding cell in spreadsheet Cell temp = new UsedCell(0, 0, ""); //temp cell to get the row and col of XML cell this.clearSpreadsheetData(); //clear all current spreadsheet data to avoid merge while (myReader.Read()) { if (myReader.IsStartElement("cell")) //is there a cell to load? { if (myReader.HasAttributes) //does the cell have attributes (a name)? { cellName = myReader.GetAttribute("name"); //get the value of name attribute (cell name) temp = this.getCorrespondingCell(cellName); } } if (myReader.IsStartElement("bgcolor")) //is there a background color to load? { uint bgcolor; UInt32.TryParse(myReader.ReadElementContentAsString(), out bgcolor); ss[temp.RowIndex, temp.ColIndex].BGColor = bgcolor; } if (myReader.IsStartElement("text")) //is there cell text to load? { ss[temp.RowIndex, temp.ColIndex].Text = myReader.ReadElementContentAsString(); } } myReader.Close(); this.undoStack.Clear(); this.redoStack.Clear(); }
public spreadsheet(int row, int col) { this.rows = row; this.columns = col; ss = new Cell[row, col]; for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { ss[r, c] = new UsedCell(r, c, ""); ss[r, c].PropertyChanged += SPropertyChanged; } } }
public Spreadsheet(int rows, int cols) { this.rowCount = rows; this.colCount = cols; ss = new Cell[rows, cols]; //create spreadsheet (2d array of cells) for (int r = 0; r < rows; r++) //initialize each cell to proper row/col index, text = "" { for (int c = 0; c < cols; c++) { ss[r, c] = new UsedCell(r, c, ""); //instantiate every index of the 2d array to a cell ss[r, c].PropertyChanged += Spreadsheet_PropertyChanged; //"subscribe" to each cell } } }
public spreadsheet(int row, int col) { this.rows = row; this.columns = col; this.dep = new Dictionary <Cell, HashSet <Cell> >(); ss = new Cell[row, col]; for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { ss[r, c] = new UsedCell(r, c, ""); ss[r, c].PropertyChanged += new PropertyChangedEventHandler(SPropertyChanged); } } }