Beispiel #1
0
        /// <summary>
        /// Reads a momento in from a file.
        /// </summary>
        public void Load()
        {
            using (FileStream fs = new FileStream("Spreadsheet.ts", FileMode.Open))
            {
                fs.CopyTo(state);
            }

            try
            {
                state.Position = 0; //We have to read from beginning of the stream.
                SpreadSheet    = (SpreadsheetWindow)formatter.Deserialize(state);
            }
            catch (SerializationException e)
            {
                Console.WriteLine("Failed to deserialize: " + e.Message);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Expands a string like "A1:A3" to A1, A2, A3
        /// </summary>
        /// <param name="cellRange">String indicating a cell range.</param>
        /// <returns>Every Cell in a given range</returns>
        public static Queue <String> ExpandCellRange(String cellRange)
        {
            Queue <String> Cells = new Queue <String>();
            int            split = cellRange.IndexOf(':');

            if (split != -1)
            {
                //split range into two cells
                string firstCell = cellRange.Slice(0, split);
                string lastCell  = cellRange.Slice(split, cellRange.Length);

                //get column and row values
                int firstCol = GetColumnIndex(GetColumn(firstCell));
                int lastCol  = GetColumnIndex(GetColumn(lastCell));
                int firstRow = getRow(firstCell);
                int lastRow  = getRow(lastCell);

                // insert  to queue
                for (int i = firstCol; i <= lastCol; i++)
                {
                    for (int j = firstRow; j <= lastRow; j++)
                    {
                        String cell = SpreadsheetWindow.GenerateName(i);
                        String row  = j.ToString();
                        cell = cell + row;
                        Cells.Enqueue(cell);
                    }
                }
                return(Cells);
            }
            else
            {
                Cells.Enqueue(cellRange);
                return(Cells);
            }
        }