示例#1
0
  def SetFormat(self,row,col,fmt):
    pyws   = self.pyws
    font   = None
    color  = None
    align  = None
    fill   = None
    numFmt = None
    border = None

    c = pyws.cell(row=row,column=col)

    #-------------------------------------------------------------------------
    for i in fmt:
      if (i == 'hAlign'): 
        if (not align): align = Alignment()
        align.horizontal = alignType[fmt[i]]
      elif (i == 'vAlign'): 
        if (not align): align = Alignment()
        align.vertical   = alignType[fmt[i]]
      elif (i == 'tAlign'): 
        if (not align): align = Alignment()
        align.text_rotation = fmt[i]
      elif (i == 'wrap'): 
        if (not align): align = Alignment()
        align.wrap_text = fmt[i]

      elif (i == 'font'):
        name = 'Calibri'
        bold = False
        size = 11
        dict = fmt[i]
        if ('emph' in dict):
          if (dict['emph'] == 'B'):
            bold = True
        if ('size' in dict):
          size = dict['size']
        if (not font):
            font = Font(name=name,size=size,bold=bold)

      elif (i == 'border'):
        dict = fmt[i]
        color = None
        style = None
        if ('Color' in dict):
          color = ColorTable[dict['Color']]
        else:
          color = ColorTable['Black']
        if ('Style' in dict):
          color = dict['Style']
        if (c.border.top.style == None):
          tSide = Side(color=color)
        else:
          tSide = c.border.top.copy()
        if (c.border.bottom.style == None):
          bSide = Side(color=color)
        else:
          bSide = c.border.bottom.copy()
        if (c.border.left.style == None):
          lSide = Side(color=color)
        else:
          lSide = c.border.left.copy()
        if (c.border.right.style == None):
          rSide = Side(color=color)
        else:
          rSide = c.border.right.copy()

        if ((len(dict) ==1) and ('A' in dict)):
          tSide.style = dict['A']
          bSide.style = dict['A']
          lSide.style = dict['A']
          rSide.style = dict['A']
        else:
          for j in dict:
            if (j == 'T'):
              tSide.style = dict[j]
            if (j == 'B'):
              bSide.style = dict[j]
            if (j == 'L'):
              lSide.style = dict[j]
            if (j == 'R'):
              rSide.style = dict[j]

        border = Border(left=lSide,right=rSide,top=tSide,bottom=bSide)

      elif (i == 'fill'): 
        color = ColorTable[fmt[i]]
        fill = PatternFill(start_color=color,end_color='FFFFFFFF',fill_type='solid')

      elif (i == 'orient'): 
        pass

      elif (i == 'numFmt'):
        numFmt = fmt[i]

    #-------------------------------------------------------------------------
    if (font):
      c.font = font.copy()

    if (align):
      c.alignment = align.copy()

    if (border):
      c.border = border.copy()

    if (fill):
      c.fill = fill.copy()

    if (numFmt):
      c.number_format = numFmt
示例#2
0
def Informe(sheet, dic,lista_alumnos,cant_alumno):
    columnas_filas(sheet, 0, 'A', 20.00)
    columnas_filas(sheet, 0, 'B', 18.00)
    columnas_filas(sheet, 0, 'C', 40.00)     
    columnas_filas(sheet, 0, 'D', 40.00)
    columnas_filas(sheet, 0, 'F', 40.00)
    columnas_filas(sheet, 0, 'E', 50.00)
    columnas_filas(sheet, 0, 'G', 20.00)
    columnas_filas(sheet, 0, 'H', 20.00)
    columnas_filas(sheet, 0, 'I', 15.00)

    alignment_title = Alignment(horizontal='center', vertical='center')
    fuente = Font(bold=False, size=11, name='arial')

    fila = 3
    fila1 = 2
    acum=1
    cont=0
    col=2
    col1=4
    fil=4
    coli=2
    colf=2

    sheet.merge_cells('A2:I2')
    sheet['A2'].alignment = alignment_title.copy(wrapText=True,horizontal='center', vertical='top')
    sheet['A2'].font = fuente.copy(bold=True,size=15, name= "arial")
    sheet['A2']= 'DIRECTORIO DE ALUMNOS'

    sheet['G1'].alignment = alignment_title.copy(wrapText=True,horizontal='right', vertical='top')
    sheet['G1'].font = fuente.copy(bold=True,size=12, name= "arial")
    sheet['G1']= 'Usuario'

    sheet['H1'].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
    sheet['H1'].font = fuente
    sheet['H1']= dic['usuario_id']

    sheet['A1'].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
    sheet['A1'].font = fuente.copy(bold=True,size=12, name= "arial")
    sheet['A1']= 'Cia'

    sheet.merge_cells('B1:C1')
    sheet['B1'].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
    sheet['B1'].font = fuente.copy(bold=False,size=12, name= "arial")
    sheet['B1']= dic['company_id']

    sheet['A3'].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
    sheet['A3'].font = fuente.copy(bold=True,size=12, name= "arial")
    sheet['A3']= 'Fecha Emision:'
    

    #fecha_actual = datetime.strftime(datetime.now(), '%d-%m-%Y %H:%M:%S')
    fecha_actual = dic['fecha']

    sheet.merge_cells('B3:C3')
    sheet['B3'].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
    sheet['B3'].font = fuente.copy(bold=True,size=12, name= "arial")
    sheet['B3']= fecha_actual

    fila=6
    for recorrer in lista_alumnos:
        sheet['A'+str(fila+1)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['A'+str(fila+1)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['A'+str(fila+1)]= 'Seccion:'

        sheet.merge_cells('B'+str(fila+1)+':C'+str(fila+1))
        sheet['B'+str(fila+1)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['B'+str(fila+1)].font = fuente.copy(bold=False,size=12, name= "arial")
        if recorrer['seccion_id']==False:
            sheet['B'+str(fila+1)]= ''    
        else:
            sheet['B'+str(fila+1)]= recorrer['seccion_id']

        sheet['A'+str(fila+2)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['A'+str(fila+2)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['A'+str(fila+2)]= 'Curso:'

        sheet.merge_cells('B'+str(fila+2)+':C'+str(fila+2))
        sheet['B'+str(fila+2)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['B'+str(fila+2)].font = fuente.copy(bold=False,size=12, name= "arial")
        if recorrer['curso_id']==False:
            sheet['B'+str(fila+2)]= ''    
        else:
            sheet['B'+str(fila+2)]= recorrer['curso_id']


        sheet['A'+str(fila+3)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['A'+str(fila+3)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['A'+str(fila+3)]= 'Codigo:'

        sheet.merge_cells('B'+str(fila+3)+':C'+str(fila+3))
        sheet['B'+str(fila+3)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['B'+str(fila+3)].font = fuente.copy(bold=False,size=12, name= "arial")
        if recorrer['codigo_curso']==False:
            sheet['B'+str(fila+3)]= ''    
        else:
            sheet['B'+str(fila+3)]= recorrer['codigo_curso']


        sheet['A'+str(fila+4)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['A'+str(fila+4)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['A'+str(fila+4)]= 'Paralelo:'

        sheet.merge_cells('B'+str(fila+4)+':C'+str(fila+4))
        sheet['B'+str(fila+4)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['B'+str(fila+4)].font = fuente.copy(bold=False,size=12, name= "arial")
        if recorrer['paralelo_id']==False:
            sheet['B'+str(fila+4)]= ''    
        else:
            sheet['B'+str(fila+4)]= recorrer['paralelo_id']


        sheet['A'+str(fila+5)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['A'+str(fila+5)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['A'+str(fila+5)]= 'Total Alumnos:'

        sheet['B'+str(fila+5)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['B'+str(fila+5)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['B'+str(fila+5)]= len(recorrer['lista_detalle'])

        fila=fila+7

        #poner_border(sheet,13,7,'medium','none','none','none')
        border_tabla(sheet,1,9,fila,fila,'none','none','none','medium')

        sheet['A'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['A'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['A'+str(fila)]= 'Orden'

        sheet['B'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['B'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['B'+str(fila)]= 'Codigo'

        sheet['C'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['C'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['C'+str(fila)]= 'Alumno'

        sheet['D'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['D'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['D'+str(fila)]= 'Representante'

        sheet['E'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['E'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['E'+str(fila)]= 'Correo'

        sheet['F'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['F'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['F'+str(fila)]= 'Direccion'

        sheet['G'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['G'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['G'+str(fila)]= 'Telefono'

        sheet['H'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['H'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['H'+str(fila)]= 'Cedula - RUC'

        sheet['I'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
        sheet['I'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
        sheet['I'+str(fila)]= 'Status'

        fila=fila+1
        orden=1
        for detalle in recorrer['lista_detalle']:       
            sheet['A'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
            sheet['A'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            sheet['A'+str(fila)]= orden
            orden=orden+1

            sheet['B'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
            sheet['B'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            sheet['B'+str(fila)]= detalle['codigo']

            sheet['C'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='justify', vertical='top')
            sheet['C'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            sheet['C'+str(fila)]= detalle['alumno']

            sheet['D'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='justify', vertical='top')
            sheet['D'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            sheet['D'+str(fila)]= detalle['representante']

            sheet['E'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
            sheet['E'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            if detalle['correo']==False:
                sheet['E'+str(fila)]= ''    
            else:
                sheet['E'+str(fila)]= detalle['correo']

            sheet['F'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
            sheet['F'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            if detalle['direccion']==False:
                sheet['F'+str(fila)]= ''    
            else:
                sheet['F'+str(fila)]= detalle['direccion']

            sheet['G'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='justify', vertical='top')
            sheet['G'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            if detalle['telefono']==False:
                sheet['G'+str(fila)]= ''    
            else:
                sheet['G'+str(fila)]= detalle['telefono']

            sheet['H'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
            sheet['H'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            sheet['H'+str(fila)]= detalle['cedula']

            sheet['I'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
            sheet['I'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
            sheet['I'+str(fila)]= detalle['state']

            fila=fila+1
        border_tabla(sheet,1,9,fila,fila,'none','none','none','medium')
        fila=fila+2




    fila=fila+2
    sheet.merge_cells('A'+str(fila)+':B'+str(fila))
    sheet['A'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
    sheet['A'+str(fila)].font = fuente.copy(bold=True,size=12, name= "arial")
    sheet['A'+str(fila)]= 'TOTAL ALUMNOS REPORTE'


    sheet['C'+str(fila)].alignment = alignment_title.copy(wrapText=True,horizontal='left', vertical='top')
    sheet['C'+str(fila)].font = fuente.copy(bold=False,size=12, name= "arial")
    sheet['C'+str(fila)]= cant_alumno