示例#1
0
        public List <Work> ExcelMakeWorkList(IWorkFile workFile)
        {
            Excel.Application TempImportExcel = new Excel.Application();;
            Excel.Workbook    TempWoorkBook   =
                TempImportExcel.Application.Workbooks.Open(workFile.Path);
            Excel.Worksheet TempWorkSheet = TempWoorkBook.Worksheets.get_Item(1);
            TempImportExcel.DisplayAlerts = false;

            List <Work> works = new List <Work>();

            if (workFile is Subcontractor)
            {
                CASExcelParserSubcontr parser    = new CASExcelParserSubcontr();
                CASInfoMakerSubcontr   infoMaker = new CASInfoMakerSubcontr();
                for (int index = 0; index < parser.LastIndexInFile(TempImportExcel); index++)
                {
                    works.Add(infoMaker.MakeInfoWork(TempImportExcel, index));
                }
            }
            else
            {
                CASExcelParserContr parser    = new CASExcelParserContr();
                CASInfoMakerContr   infoMaker = new CASInfoMakerContr();
                for (int index = 0; index < parser.LastIndexInFile(TempImportExcel); index++)
                {
                    works.Add(infoMaker.MakeInfoWork(TempImportExcel, index));
                }
            }

            return(works);
        }
示例#2
0
        public IWorker ExcelMakeWorkList(IWorkFile workFile)
        {
            Excel.Application TempImportExcel = new Excel.Application();;
            Excel.Workbook    TempWoorkBook   =
                TempImportExcel.Application.Workbooks.Open(workFile.Path);
            Excel.Worksheet TempWorkSheet = TempWoorkBook.Worksheets.get_Item(1);
            TempImportExcel.DisplayAlerts = false;
            object[,] array = TempWorkSheet.UsedRange.Value;

            IWorker     worker = workFile.worker;
            List <Work> works  = new List <Work>();

            if (workFile is SubcontrWorkFile)
            {
                CASExcelParserSubcontr parser    = new CASExcelParserSubcontr();
                CASInfoMakerSubcontr   infoMaker = new CASInfoMakerSubcontr();
                int lastIndexInFile = parser.LastIndexInFile(array);
                for (int index = 1; index <= lastIndexInFile; index++)
                {
                    works.Add(infoMaker.MakeInfoWork(array, index));
                }
            }
            else
            {
                CASExcelParserContr parser    = new CASExcelParserContr();
                CASInfoMakerContr   infoMaker = new CASInfoMakerContr();
                int lastIndexInFile           = parser.LastIndexInFile(array);
                for (int index = 1; index <= lastIndexInFile; index++)
                {
                    works.Add(infoMaker.MakeInfoWork(array, index));
                }
            }

            TempWoorkBook.Close(false);
            TempImportExcel.Quit();
            TempImportExcel = null;
            TempWoorkBook   = null;
            TempWorkSheet   = null;
            GC.Collect();

            worker.WorkList = works;
            return(worker);
        }