Exemple #1
0
        public IList <FilmDetails> ExtractFilms()
        {
            List <FilmDetails> list        = new List <FilmDetails>();
            Application        application = new Excel.ApplicationClass();

            application.Workbooks.Open(this.SpreadsheetLocation, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value, (object)Missing.Value);
            Worksheet worksheet = application.ActiveWorkbook.Worksheets[(object)1] as Worksheet;

            for (int index = 2; index < worksheet.Rows.Count; ++index)
            {
                Range range = worksheet.get_Range((object)(this.TitleCell + (object)index), (object)Missing.Value);
                if (!string.IsNullOrEmpty(range.Text.ToString()))
                {
                    list.Add(new FilmDetails()
                    {
                        Title                 = range.Text.ToString(),
                        Genre                 = worksheet.get_Range((object)(this.GenreCell + (object)index), (object)Missing.Value).Text.ToString(),
                        Gauge                 = worksheet.get_Range((object)(this.GaugeCell + (object)index), (object)Missing.Value).Text.ToString(),
                        Ratio                 = worksheet.get_Range((object)(this.RatioCell + (object)index), (object)Missing.Value).Text.ToString(),
                        Resolution            = worksheet.get_Range((object)(this.ResolutionCell + (object)index), (object)Missing.Value).Text.ToString(),
                        RunTime               = TypeExtensions.AsSafeInt32(worksheet.get_Range((object)(this.RunTimeCell + (object)index), (object)Missing.Value).Value2),
                        In                    = TypeExtensions.AsSafeNullableDateTime(worksheet.get_Range((object)(this.InCell + (object)index), (object)Missing.Value).Text),
                        Language              = worksheet.get_Range((object)(this.LanguageCell + (object)index), (object)Missing.Value).Text.ToString(),
                        Country               = worksheet.get_Range((object)(this.CountryCell + (object)index), (object)Missing.Value).Text.ToString(),
                        InSuspect             = (bool)worksheet.get_Range((object)(this.InCell + (object)index), (object)Missing.Value).Font.Italic,
                        Out                   = TypeExtensions.AsSafeNullableDateTime(worksheet.get_Range((object)(this.OutCell + (object)index), (object)Missing.Value).Text),
                        OutSuspect            = (bool)worksheet.get_Range((object)(this.OutCell + (object)index), (object)Missing.Value).Font.Italic,
                        Leaving               = TypeExtensions.AsSafeDateTime(worksheet.get_Range((object)(this.LeavingCell + (object)index), (object)Missing.Value).Text),
                        OriginatingRegion     = worksheet.get_Range((object)(this.OriginCell + (object)index), (object)Missing.Value).Text.ToString().Trim().ToUpper(),
                        WellingtonScreeningNo = worksheet.get_Range((object)(this.WellingtonScreeningNoCell + (object)index), (object)Missing.Value).Text.ToString(),
                        AucklandScreeningNo   = worksheet.get_Range((object)(this.AucklandScreeningNoCell + (object)index), (object)Missing.Value).Text.ToString()
                    });
                }
                else
                {
                    break;
                }
            }
            IntPtr hwnd = new IntPtr(application.Parent.Hwnd);

            application.ActiveWorkbook.Close((object)false, (object)this.SpreadsheetLocation, (object)Missing.Value);
            application.Quit();
            this.CheckAndForceKill(hwnd);
            return((IList <FilmDetails>)list);
        }