Ejemplo n.º 1
0
    def Parse(self):
        timesheet  =  None;
        workbook  =  xlrd.open_workbook(self.Filename)
        
        if(len(workbook.sheets()) > 0):
            #interested on the first sheet
            sheet      =  workbook.sheets()[0];
            timesheet  = Timesheet(sheet.name);
            cell = sheet.cell(0,4) # the timesheet header text
            if(cell is not None):            
                timesheet.Header            = cell.value;
            timesheet.EmployeeName          = sheet.cell(2, 2).value
            timesheet.Title                 = sheet.cell(2, 4).value
            timesheet.WeekEndingSunday      = sheet.cell(2, 10).value
            timesheet.Department            = sheet.cell(3, 2).value
            timesheet.Description           = sheet.cell(4,0).value

            #Timesheet column titles
            timesheet.Projects.Header.append(sheet.cell(5,0).value) # RSRCE
            timesheet.Projects.Header.append(sheet.cell(5,1).value) # Work Order No
            timesheet.Projects.Header.append(sheet.cell(5,2).value) # Contract Number
            timesheet.Projects.Header.append(sheet.cell(5,3).value) # Total Hours
            timesheet.Projects.Header.append(sheet.cell(5,4).value) # Description

            # Load the projects that are filled by default its fixed to 24 records
            user_defineds_recs = self.__FromRowAtToList(sheet, 6,30);                
            self._ParseProjects(timesheet, user_defineds_recs, ProjectType.USER_DEFINED_PROJECT)

            #Fixed records
            fixed_project_recs =  self.__FromRowAtToList(sheet,31,45)
          
            self._ParseProjects(timesheet, fixed_project_recs, ProjectType.FIXED_PROJECT)
            
            # The year stamp time for the timesheet.
            timesheet.Template  = sheet.cell(50,0).value
        
        return timesheet
Ejemplo n.º 2
0
    def Parse(self):
        timesheet  =  None;
        workbook  =  pyexcel_ods.get_data(self.Filename)
        keys =  list(workbook.keys())
        
        if(len(keys) > 0):
            sheets  =  list(workbook.items())
            
            if(len(sheets) > 0):
                # Interested in the first sheet
                sheet  =  sheets[0]
                if(sheet is not None):
                    timesheet =  Timesheet(sheet[0])
                    records  =  sheet[1]
                    """
                      Records are list of records.
                      record are python list object of cell values that are not empty.
                    """
                    if(len(records) > 0):
                        header_record       =  records[0]
                        timesheet.Header    =  header_record[-1]

                        #3record is weekly timesheet line
                        
                        weekly_record                  =  records[2]
                        timesheet.EmployeeName         = weekly_record[1]
                        timesheet.Title                = weekly_record[2]
                        timesheet.WeekEndingSunday     = weekly_record[4]

                        #department record line
                        department_record = records[3];
                        timesheet.Department    = department_record[1]

                        #timesheet description
                        timesheet.Description   =  records[4][0]

                        #project records
                        project_column_headers  =  records[5]
                        if(len(project_column_headers) > 5):
                            timesheet.Projects.Header.append(project_column_headers[0]) # RSRCE
                            timesheet.Projects.Header.append(project_column_headers[1]) # Work Order No
                            timesheet.Projects.Header.append(project_column_headers[2]) # Contract Number
                            timesheet.Projects.Header.append(project_column_headers[3]) # Total Hours
                            timesheet.Projects.Header.append(project_column_headers[4]) # Description
                    
                            # Load the projects that are filled by default its fixed to 24 records
                            user_defineds_recs = records[6:30]
                            self._ParseProjects(timesheet, user_defineds_recs, ProjectType.USER_DEFINED_PROJECT)

                            # Load the fixed projects or tasks projects.
                            # this involves holidays , pay leaves e.t.c
                            # there are 15 of does at the moment.
                            fixed_project_recs =  records[31:45]
                            self._ParseProjects(timesheet, fixed_project_recs, ProjectType.FIXED_PROJECT)

                            # The year stamp time for the timesheet.
                            template_records  = records[50:52];
                            if(len(template_records) > 0):
                                template_rec =  template_records[0]
                                if(len(template_rec) > 0):
                                   timesheet.Template =  template_rec[0]
                            
        return timesheet