Ejemplo n.º 1
0
        public void readXSLFile(string filePath)
        {
            List<string> mDates = new List<string>();
            if (File.Exists(filePath))
            {
                FileStream stream = new FileStream(filePath, FileMode.Open, FileAccess.Read);

                var excelReader = ExcelReaderFactory.CreateBinaryReader(stream);
                //excelReader.IsFirstRowAsColumnNames = true;
                DataSet result = excelReader.AsDataSet();
                //excelReader.
                int position = 0;
                Date currentDate;
                double dateDouble;
                double percentOpen;
                SlopeMonthData currentMonthData = null;
                excelReader.Read();
                while (excelReader.Read())
                {
                    for (int i = 0; i < NUM_YEARS; i++)
                    {

                        if (excelReader[DATE_POSITION + (i * INCREMENT_PER_YEAR)] != null)
                        {
                            dateDouble = (double)excelReader[DATE_POSITION + (i * INCREMENT_PER_YEAR)];
                            currentDate = convertDateDoubleToDate(dateDouble);
                        }
                        else
                        {
                            continue;
                        }
                        if (excelReader[PERCENT_OPEN_POSITION + (i * INCREMENT_PER_YEAR)] != null)
                        {
                            percentOpen = (double)excelReader[PERCENT_OPEN_POSITION + (i * INCREMENT_PER_YEAR)] * 100;
                        }
                        else
                        {
                            continue;
                        }

                        currentMonthData = getSlopeMonthData(currentDate);
                        if (currentMonthData != null)
                        {
                            currentMonthData.addData(currentDate.day, percentOpen);
                        }
                        else
                        {
                            currentMonthData = new SlopeMonthData(currentDate.year, currentDate.month);
                            currentMonthData.addData(currentDate.day, percentOpen);
                            mMonthData.Add(currentMonthData);
                        }
                        currentMonthData = null;
                    }
                    /*
                    double dateDouble = (double)excelReader[position];

                    if (excelReader[position] != null)
                        mDates.Add((Convert.ToDateTime(dateDouble)).ToString());
                    else
                    {
                        mDates.Add("");
                    }
                    */
                }

                excelReader.Close();
            }
        }
Ejemplo n.º 2
0
 public static void xmlSerilize(SlopeMonthData monthData)
 {
     XmlSerializer ser = new XmlSerializer(typeof(SlopeMonthData));
     TextWriter contactList = new StreamWriter(@"../" + monthData.monthYearString() + ".xml");
     ser.Serialize(contactList, monthData);
 }