private S8Spreadsheet.Cell createCell(int row, int col, VariableType type)
 {
     S8Spreadsheet.Cell tmpCell = new S8Spreadsheet.Cell();
     tmpCell.CellType = type;
     tmpCell.Row      = row; tmpCell.Col = col;
     return(tmpCell);
 }
        private List <S8Spreadsheet> LoadSpreadsheet(List <Variable> ssVariable)
        {
            List <S8Spreadsheet> NewSS = new List <S8Spreadsheet>();


            for (int i = 0; i < ssVariable.Count; i++)
            {
                S8Spreadsheet tt = (S8Spreadsheet)ssVariable[i].Value;
            }

            for (int i = 0; i < ssVariable.Count; i++)
            {
                string lineReaded = null;
                string ssFilename = xmlBase + ssVariable[i].Name + ".csv";
                string path1      = System.Web.Hosting.HostingEnvironment.MapPath(ssFilename);

                StreamReader       ssReader  = new StreamReader(path1);
                S8Spreadsheet      tempSheet = new S8Spreadsheet();
                S8Spreadsheet.Cell tmpCell   = null;

                tempSheet.ColCount = 5;
                tempSheet.RowCount = Convert.ToInt16(ssReader.ReadLine());

                //ResulttextBox.Text += "1=>"+tempSheet.Cells.Count+" \r\n";
                lineReaded    = ssReader.ReadLine(); //hospital name
                tmpCell       = createCell(1, 1, VariableType.Text);
                tmpCell.Value = String.Copy(lineReaded);
                tempSheet.Cells.Add(tmpCell);

                //  plist
                lineReaded    = ssReader.ReadLine(); //ARRIVAL
                tmpCell       = createCell(2, 1, VariableType.Text);
                tmpCell.Value = String.Copy(lineReaded);
                tempSheet.Cells.Add(tmpCell);

                lineReaded = ssReader.ReadLine(); //TBA, Number
                string[] parseText = lineReaded.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                tmpCell       = createCell(3, 1, VariableType.Text);
                tmpCell.Value = parseText[0];
                tempSheet.Cells.Add(tmpCell);

                tmpCell       = createCell(3, 2, VariableType.Text);
                tmpCell.Value = parseText[1];
                tempSheet.Cells.Add(tmpCell);

                int count = Convert.ToInt16(ssReader.ReadLine());
                for (int j = 0; j < count; j++)
                {
                    int rowIdx = 4 + j;
                    lineReaded    = ssReader.ReadLine();
                    parseText     = lineReaded.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                    tmpCell       = createCell(rowIdx, 1, VariableType.Number);
                    tmpCell.Value = parseText[0];
                    tempSheet.Cells.Add(tmpCell);

                    tmpCell       = createCell(rowIdx, 2, VariableType.Number);
                    tmpCell.Value = parseText[1];
                    tempSheet.Cells.Add(tmpCell);
                }

                //  nlist
                lineReaded    = ssReader.ReadLine(); //SERVICE
                tmpCell       = createCell(2, 3, VariableType.Text);
                tmpCell.Value = String.Copy(lineReaded);
                tempSheet.Cells.Add(tmpCell);

                lineReaded    = ssReader.ReadLine(); //TBA, Number, Time
                parseText     = lineReaded.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                tmpCell       = createCell(3, 3, VariableType.Text);
                tmpCell.Value = parseText[0];
                tempSheet.Cells.Add(tmpCell);

                tmpCell       = createCell(3, 4, VariableType.Text);
                tmpCell.Value = parseText[1];
                tempSheet.Cells.Add(tmpCell);

                tmpCell       = createCell(3, 5, VariableType.Text);
                tmpCell.Value = parseText[2];
                tempSheet.Cells.Add(tmpCell);

                count = Convert.ToInt16(ssReader.ReadLine()); //plist
                for (int j = 0; j < count; j++)
                {
                    int rowIdx = 4 + j;
                    lineReaded    = ssReader.ReadLine();
                    parseText     = lineReaded.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries);
                    tmpCell       = createCell(rowIdx, 3, VariableType.Number);
                    tmpCell.Value = parseText[0];
                    tempSheet.Cells.Add(tmpCell);

                    tmpCell       = createCell(rowIdx, 4, VariableType.Number);
                    tmpCell.Value = parseText[1];
                    tempSheet.Cells.Add(tmpCell);

                    tmpCell       = createCell(rowIdx, 5, VariableType.Number);
                    tmpCell.Value = parseText[2];
                    tempSheet.Cells.Add(tmpCell);
                }

                NewSS.Add(tempSheet);
            }

            return(NewSS);
        }