Example #1
0
    def on_btnExportar_clicked(self, widget):
        """
        Evento que nos permite exportar un fichero con los cliente guardados
        :return: Void
        """
        try:
            destino = variables.ventanaExportar.get_filename()
            destino = str(destino) + str('/fichero_exportado.xls')
            estilo_cabecera = xlwt.easyxf(
                'font: name Times New Roman, colour red, bold on')
            estilo_celda = xlwt.easyxf(num_format_str='DD-MM-YY')
            fichero_excel = xlwt.Workbook()

            hoja_excel = fichero_excel.add_sheet('NuevoClientes',
                                                 cell_overwrite_ok=True)
            hoja_excel.write(0, 0, 'DNI', estilo_cabecera)
            hoja_excel.write(0, 1, 'APELIDOS', estilo_cabecera)
            hoja_excel.write(0, 2, 'NOMBRE', estilo_cabecera)
            hoja_excel.write(0, 3, 'FECHA_ALTA', estilo_cabecera)

            listado_clientes = funcionescli.listar()

            for i in range(len(listado_clientes)):
                for j in range(len(listado_clientes[0])):
                    hoja_excel.write(i, j, listado_clientes[i][j],
                                     estilo_celda)
            fichero_excel.save(destino)

            variables.ventanaExportar.connect('delete-event',
                                              lambda w, e: w.hide() or True)
            variables.ventanaExportar.hide()
        except Exception as e:
            print(e)
            print("Error en exportar clientes")
Example #2
0
def cuerpolistacli():


    lista = funcionescli.listar()
    print(len(lista))
    x=65
    con =0
    y=615

    while con!=len(lista):
        bill.setFont('Helvetica', size=8)
        bill.drawString(x, y, str(lista[con][0]))
        x=x+60
        bill.drawString(x, y, str(lista[con][1]))
        x=x+70
        bill.drawString(x, y, str(lista[con][2]))
        x=x+140
        bill.drawString(x, y, str(lista[con][3]))
        x=x+120
        bill.drawString(x, y, str(lista[con][4]))
        y=y-20
        x=65
        con = con +1
        if con%25==0:
            try:
                bill.showPage()
                basico()
                cabeceralistacli()

                x=65
                y=615
            except:
                print('Error salto de pag')

    x=x+390
Example #3
0
def exportar():
    '''
    Se encarga de exportar los datos de los clientes de nuestra base de datos e imprimirlas en el fichero export.xls
    @return:
    '''
    try:
        style0 = xlwt.easyxf('font: name Times New Roman, colour red, bold on')
        style1 = xlwt.easyxf()

        wb = xlwt.Workbook()

        ws = wb.add_sheet('NuevosClientes',  True)
        ws.write(0, 0, 'DNI', style0)
        ws.write(0, 1, 'APELIDOS', style0)
        ws.write(0, 2, 'NOMBRE', style0)
        ws.write(0, 3, 'FECHA ALTA', style0)

        listado = funcionescli.listar()
        j = 1
        for registro in listado:
            for i in range(len(registro)-1):
                ws.write(j,i,registro[i+1],style1)
            j = j + 1


        wb.save('export.xls')
        print("Export realizado")

    except Exception as e:
        print("Error exportando", e)
Example #4
0
    def on_btnelegirRutaExportarAceptar_clicked(self, widget):
        """
        Exporta a la carpeta indicada con el nombre de archivo indicado la bd.

        Comprueba que hayas introducido un nombre de  fichero y almacena
        el fichero exportado en la carpeta seleccionada con el nombre escrito.

        :param widget:
        :return: void
        """
        nombreFichero = variables.entryExportar.get_text()
        if (nombreFichero != ""):

            try:
                destino = variables.filechooserRutaExportar.get_filename()
                print(str(destino))

                #Ejemplo de creación de hoja Excel
                #definimos los estilos
                style0 = xlwt.easyxf('font: name DejaVu Sans')
                #Creamos un fichero excel
                wb = xlwt.Workbook()

                lista = funcionescli.listar()
                con = 0
                # le añadimos una hoja llamada NuevoClientesque permite sobreescribir celdas
                ws = wb.add_sheet('NuevoClientes', cell_overwrite_ok=True)
                while con != len(lista):
                    # AQUÍ LO VAMOS RECORRIENDO E INSERTANDO EN LA CELDACORRESPONDIENTE
                    ws.write(con, 0, lista[con][1], style0)
                    ws.write(con, 1, lista[con][2], style0)
                    ws.write(con, 2, lista[con][3], style0)
                    ws.write(con, 3, lista[con][4], style0)
                    con = con + 1
                #Guardamos el archivo
                wb.save(destino + '/' + nombreFichero + '.xls')

            except Exception as e:
                print(e)
        else:
            print("No has metido na")

        variables.filechooserRutaExportar.connect(
            'delete-event', lambda w, e: w.hide() or True)
        variables.filechooserRutaExportar.hide()
Example #5
0
    def on_menuBarExportar_activate(self, widget):
        """
        Gestiona el evento del botón exportar de la barra de menú.
        Se encarga de leer todos los clientes y escribirlso en un documento xls.
        :param widget:
        :return: No devuelve nada.

        """
        style0 = xlwt.easyxf('font: name DejaVu Sans')
        wb = xlwt.Workbook()

        lista = funcionescli.listar()
        con = 0

        ws = wb.add_sheet('NuevoClientes', cell_overwrite_ok=True)
        while con != len(lista):
            ws.write(con, 0, lista[con][1], style0)
            ws.write(con, 1, lista[con][2], style0)
            ws.write(con, 2, lista[con][3], style0)
            ws.write(con, 3, lista[con][4], style0)
            con = con + 1
        wb.save('exportarclientes.xls')
        variables.vendialogexportar.show()
Example #6
0
 def on_menuBarExportar_activate(self, widget):
     """
     Evento que gestiona el botón para exportar desde el menubar
     """
     try:
         estilo_cabecera = xlwt.easyxf(
             'font: name Times New Roman, colour red, bold on')
         estilo_celda = xlwt.easyxf(num_format_str='DD-MM-YY')
         fichero_excel = xlwt.Workbook()
         hoja_excel = fichero_excel.add_sheet('NuevoClientes',
                                              cell_overwrite_ok=True)
         hoja_excel.write(0, 0, 'DNI', estilo_cabecera)
         hoja_excel.write(0, 1, 'APELIDOS', estilo_cabecera)
         hoja_excel.write(0, 2, 'NOMBRE', estilo_cabecera)
         hoja_excel.write(0, 3, 'FECHA_ALTA', estilo_cabecera)
         listado_clientes = funcionescli.listar()
         for i in range(len(listado_clientes)):
             for j in range(len(listado_clientes[0])):
                 hoja_excel.write(i, j, listado_clientes[i][j],
                                  estilo_celda)
         fichero_excel.save('clientes_exportados.xls')
     except Exception as e:
         print(e)
         print("Error exportar menu bar")