Ejemplo n.º 1
0
        public static WorkScheduleConfig LoadWorkScheduleConfig(string fullPathToExcelFile)
        {
            DataTable dtOfWorkScheduleForUnit = new DataTable();

            try
            {
                OleDbExcelDataProvider oleXlsProvider = new OleDbExcelDataProvider(fullPathToExcelFile, null);
                dtOfWorkScheduleForUnit = oleXlsProvider.ReadSheet(Properties.Settings.Default.SHEET_NAME_WORK_SCHEDULE_MAIN);
            }
            catch (InvalidOperationException exception)
            {
                try
                {
                    ApplicationExcelDataProvider appXlsProvider = new ApplicationExcelDataProvider(fullPathToExcelFile, null);
                    dtOfWorkScheduleForUnit = appXlsProvider.ReadSheet(Properties.Settings.Default.SHEET_NAME_WORK_SCHEDULE_MAIN);
                }
                catch (Exception exceptionFromExcel)
                {
                    throw exceptionFromExcel;
                }
            }
            catch
            {
                throw;
            }
            return(null);
        }
Ejemplo n.º 2
0
        private static DataTable GetSheetFromXls(string fullPathToExcelFile, string sheetName)
        {
            DataTable dtOfWorkScheduleForUnit = new DataTable();

            try
            {
                OleDbExcelDataProvider oleXlsProvider = new OleDbExcelDataProvider(fullPathToExcelFile, null);
                dtOfWorkScheduleForUnit = oleXlsProvider.ReadSheet(sheetName);
            }
            catch (InvalidOperationException exception)
            {
                try
                {
                    ApplicationExcelDataProvider appXlsProvider = new ApplicationExcelDataProvider(fullPathToExcelFile, null);
                    dtOfWorkScheduleForUnit = appXlsProvider.ReadSheet(sheetName);
                }
                catch (Exception exceptionFromExcel)
                {
                    throw exceptionFromExcel;
                }
            }
            catch
            {
                throw;
            }

            return(dtOfWorkScheduleForUnit);
        }