def relatorio_ods(request): # montar objeto lista com os campos a mostrar no relatorio/pdf lista = request.session[nome_relatorio] if lista: ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, ods) # subtitle sheet.getCell(0, 1).setAlignHorizontal('center').stringValue( 'Nome').setFontSize('14pt') sheet.getRow(1).setHeight('20pt') #TRECHO PERSONALIZADO DE CADA CONSULTA #DADOS x = 0 for obj in lista: sheet.getCell(0, x + 2).setAlignHorizontal('center').stringValue( obj.name) x += 1 #TRECHO PERSONALIZADO DE CADA CONSULTA relatorio_ods_base(ods, planilha_relatorio) # generating response response = HttpResponse(mimetype=ods.mimetype.toString()) response[ 'Content-Disposition'] = 'attachment; filename=' + nome_relatorio + '.ods' ods.save(response) return response else: return HttpResponseRedirect(response_consulta)
def relatorio_ods(request): # montar objeto lista com os campos a mostrar no relatorio/pdf lista = request.session[nome_relatorio] if lista: ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, ods) # subtitle sheet.getCell(0, 1).setAlignHorizontal('center').stringValue( 'Nome' ).setFontSize('14pt') sheet.getRow(1).setHeight('20pt') #TRECHO PERSONALIZADO DE CADA CONSULTA #DADOS x = 0 for obj in lista: sheet.getCell(0, x+2).setAlignHorizontal('center').stringValue(obj.nome) x += 1 #TRECHO PERSONALIZADO DE CADA CONSULTA relatorio_ods_base(ods, planilha_relatorio) # generating response response = HttpResponse(mimetype=ods.mimetype.toString()) response['Content-Disposition'] = 'attachment; filename='+nome_relatorio+'.ods' ods.save(response) return response else: return HttpResponseRedirect( response_consulta )
def relatorio_ods(request): # montar objeto lista com os campos a mostrar no relatorio/pdf lista = request.session[nome_relatorio] if lista: ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, ods) # subtitle sheet.getCell(0, 1).setAlignHorizontal("center").stringValue("Nome").setFontSize("14pt") sheet.getCell(1, 1).setAlignHorizontal("center").stringValue("Estado").setFontSize("14pt") sheet.getRow(1).setHeight("20pt") # TRECHO PERSONALIZADO DE CADA CONSULTA # DADOS x = 0 for obj in lista: sheet.getCell(0, x + 2).setAlignHorizontal("center").stringValue(obj.nmregional) sheet.getCell(1, x + 2).setAlignHorizontal("center").stringValue(obj.tbuf.nmuf) x += 1 # TRECHO PERSONALIZADO DE CADA CONSULTA relatorio_ods_base(ods, planilha_relatorio) # generating response response = HttpResponse(mimetype=ods.mimetype.toString()) response["Content-Disposition"] = "attachment; filename=" + nome_relatorio + ".ods" ods.save(response) return response else: return HttpResponseRedirect(response_consulta)
def report(): ods = ODS() # sheet title sheet = ods.content.getSheet(0) sheet.setSheetName('Totals') # title sheet.getCell(0, 0).stringValue("REPORTE").setFontSize('14pt') sheet.getRow(0).setHeight('18pt') sheet.getColumn(0).setWidth('10cm') # Cell1 sheet.getCell(0, 1).stringValue("Foo") sheet.getCell(1, 1).floatValue(2) # Cell2 sheet.getCell(0, 2).stringValue("Bar") sheet.getCell(1, 2).floatValue(3) # Cell3 with formula sheet.getCell(0, 3).stringValue("Total").setBold(True) sheet.getCell(1, 3).floatFormula(0, '=SUM(B2:B3)').setBold(True) ods.save("archivo.ods")
def csv_to_ods(trans_csv, meta_csv, local_ods): """ Converts csv files to one ods file :param trans_csv: path to csv file with translations :param meta_csv: path to csv file with metadata :param local_ods: path to new ods file """ trans_reader = UnicodeReader(trans_csv) meta_reader = UnicodeReader(meta_csv) ods = ODS() trans_title = trans_reader.next() meta_reader.next() _prepare_ods_columns(ods, trans_title) for i, (trans_row, meta_row) in enumerate(izip(trans_reader, meta_reader)): _write_row_into_ods(ods, 0, i, trans_row) _write_row_into_ods(ods, 1, i, meta_row) trans_reader.close() meta_reader.close() ods.save(local_ods)
def report(): ods = ODS() # sheet title sheet = ods.content.getSheet(0) sheet.setSheetName('Totals') # title sheet.getCell(0, 0).stringValue("Nice cool report").setFontSize('14pt') sheet.getRow(0).setHeight('18pt') sheet.getColumn(0).setWidth('10cm') # Cell1 sheet.getCell(0, 1).stringValue("Foo") sheet.getCell(1, 1).floatValue(2) # Cell2 sheet.getCell(0, 2).stringValue("Bar") sheet.getCell(1, 2).floatValue(3) # Cell3 with formula sheet.getCell(0, 3).stringValue("Total").setBold(True) sheet.getCell(1, 3).floatFormula(0, '=SUM(B2:B3').setBold(True) # generating response #response = HttpResponse(mimetype=ods.mimetype.toString()) #response['Content-Disposition'] = 'attachment; filename="report.ods"' #ods.save(response) #return response ods.save("generado.ods")
def po_to_ods(languages, locale_root, po_files_path, temp_file_path): """ Converts po file to csv GDocs spreadsheet readable format. :param languages: list of language codes :param locale_root: path to locale root folder containing directories with languages :param po_files_path: path from lang directory to po file :param temp_file_path: path where temporary files will be saved """ title_row = ['file', 'comment', 'msgid'] title_row += map(lambda s: s + ':msgstr', languages) ods = ODS() _prepare_ods_columns(ods, title_row) po_files = _get_all_po_filenames(locale_root, languages[0], po_files_path) i = 1 for po_filename in po_files: po_file_path = os.path.join(locale_root, languages[0], po_files_path, po_filename) start_row = i po = polib.pofile(po_file_path) for entry in po: meta = dict(entry.__dict__) meta.pop('msgid', None) meta.pop('msgstr', None) meta.pop('tcomment', None) ods.content.getSheet(1) ods.content.getCell(0, i).stringValue( str(meta)).setCellColor(settings.EVEN_COLUMN_BG_COLOR) ods.content.getSheet(0) ods.content.getCell(0, i) \ .stringValue(po_filename) \ .setCellColor(settings.ODD_COLUMN_BG_COLOR) ods.content.getCell(1, i) \ .stringValue(_escape_apostrophe(entry.tcomment)) \ .setCellColor(settings.ODD_COLUMN_BG_COLOR) ods.content.getCell(2, i) \ .stringValue(_escape_apostrophe(entry.msgid)) \ .setCellColor(settings.EVEN_COLUMN_BG_COLOR) ods.content.getCell(3, i) \ .stringValue(_escape_apostrophe(entry.msgstr))\ .setCellColor(settings.ODD_COLUMN_BG_COLOR) i += 1 _write_trans_into_ods(ods, languages, locale_root, po_files_path, po_filename, start_row) ods.save(temp_file_path)
def relatorio_titulo_ods(request): titulos = request.session['titulos-caixa'] if titulos: #GERACAO nome_relatorio = "relatorio-titulos-caixa" titulo_relatorio = "RELATORIO DOS TITULOS DA CAIXA "+titulos[0].tbtitulo.tbcaixa.nmlocalarquivo planilha_relatorio = "Titulos da Caixa" ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, len(titulos), ods) # TITULOS DAS COLUNAS sheet.getCell(0, 6).setAlignHorizontal('center').stringValue( 'Titulo' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(1, 6).setAlignHorizontal('center').stringValue( 'Processo' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(2, 6).setAlignHorizontal('center').stringValue( 'Requerente' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(3, 6).setAlignHorizontal('center').stringValue( 'CPF' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(4, 6).setAlignHorizontal('center').stringValue( 'Imovel em' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(5, 6).setAlignHorizontal('center').stringValue( 'Gleba' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getRow(1).setHeight('20pt') sheet.getRow(2).setHeight('20pt') sheet.getRow(6).setHeight('20pt') sheet.getColumn(0).setWidth("2in") sheet.getColumn(1).setWidth("2in") sheet.getColumn(2).setWidth("5in") sheet.getColumn(3).setWidth("2in") sheet.getColumn(4).setWidth("5in") sheet.getColumn(5).setWidth("5in") #DADOS DA CONSULTA x = 5 for obj in titulos: sheet.getCell(0, x+2).setAlignHorizontal('center').stringValue(obj.tbtitulo.cdtitulo) sheet.getCell(1, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.nrprocesso) sheet.getCell(4, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.tbmunicipio.nome_mun) sheet.getCell(5, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.tbgleba.nmgleba) r = Tbprocessorural.objects.get( tbprocessobase__id = obj.tbprocessobase.id ) sheet.getCell(2, x+2).setAlignHorizontal('center').stringValue(r.nmrequerente) sheet.getCell(3, x+2).setAlignHorizontal('center').stringValue(r.nrcpfrequerente) x += 1 #GERACAO DO DOCUMENTO relatorio_ods_base(ods, planilha_relatorio) response = HttpResponse(mimetype=ods.mimetype.toString()) response['Content-Disposition'] = 'attachment; filename='+nome_relatorio+'.ods' ods.save(response) return response else: return HttpResponseRedirect( response_consulta )
def search_results_to_ods(checks, view, search_engine='Yandex'): ods = ODS() current_date = datetime.date.today() # sheet title sheet = ods.content.getSheet(0) sheet.getCell(0, 0).stringValue(u"{hostname} {search_engine}-{region}".format( hostname=view.resource.website.hostname, search_engine=search_engine, region=view.name)) sheet.getCell(0, 1).stringValue(u"Запрос") sheet.getCell(1, 1).stringValue(u"Частотность") for i, check_date in enumerate(checks, start=2): sheet.getCell(i, 1).stringValue(check_date.strftime("%Y-%m-%d")) for j, entry in enumerate(view.entries.all(), start=2): # первый проход if i == 2: sheet.getCell(0, j).stringValue(entry.subscription.subscription.__unicode__()) if entry.subscription.subscription.quantities.exists(): sheet.getCell(1, j).stringValue(entry.subscription.subscription.quantities.latest().quantity) else: sheet.getCell(1, j).stringValue("-") q = entry.subscription.reports.filter(datestamp=check_date) if q.exists(): if q[0].position >= 0: cell_value = q[0].position else: cell_value = u"Не попал в %s" % entry.subscription.search_depth else: if check_date == current_date: cell_value = u'сбор данных' else: cell_value = u"N/A" sheet.getCell(i, j).setFontColor('#808080') sheet.getCell(i, j).stringValue(cell_value) response = HttpResponse(mimetype=ods.mimetype.toString()) response['Content-Disposition'] = 'attachment; filename="report.ods"' ods.save(response) return response
def test(): print ("Test") # Create a New Sheet ods = ODS() # Creat Sheet Title sheet = ods.content.getSheet(0) sheet.setSheetName('Test') # Add some content sheet.getCell(0,0).stringValue("Some Cool Text") sheet.getCell(0,1).floatValue(2) # Add some more content sheet.getCell(1,0).stringValue("Some More Cooler Text") sheet.getCell(0,1).floatValue(3) # Add a Formula sheet.getCell(2,0).stringValue("Together Now") sheet.getCell(2,1).floatForumula(0, '=SUM(B2:B3)') return
def relatorio_ods(request): # montar objeto lista com os campos a mostrar no relatorio lista = request.session[nome_relatorio] lista_processo = request.session[processos_relatorio] if lista: ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, len(lista), ods) # subtitle sheet.getCell(0, 1).setAlignHorizontal('center').stringValue( 'Titulo').setFontSize('10pt') sheet.getCell(1, 1).setAlignHorizontal('center').stringValue( 'Processo').setFontSize('10pt') sheet.getCell(2, 1).setAlignHorizontal('center').stringValue( 'Nome').setFontSize('10pt') sheet.getCell(3, 1).setAlignHorizontal('center').stringValue( 'CPF').setFontSize('10pt') sheet.getCell(4, 1).setAlignHorizontal('center').stringValue( 'Gleba').setFontSize('10pt') sheet.getCell(5, 1).setAlignHorizontal('center').stringValue( 'Municipio do imovel').setFontSize('10pt') sheet.getCell(6, 1).setAlignHorizontal('center').stringValue( 'Conjuge').setFontSize('10pt') sheet.getCell(7, 1).setAlignHorizontal('center').stringValue( 'CPF conjuge').setFontSize('10pt') sheet.getCell(8, 1).setAlignHorizontal('center').stringValue( 'Endereco').setFontSize('10pt') sheet.getCell(9, 1).setAlignHorizontal('center').stringValue( 'Contato').setFontSize('10pt') sheet.getCell(10, 1).setAlignHorizontal('center').stringValue( 'Municipio domicilio').setFontSize('10pt') sheet.getCell(11, 1).setAlignHorizontal('center').stringValue( 'Pasta').setFontSize('10pt') sheet.getRow(1).setHeight('10pt') #TRECHO PERSONALIZADO DE CADA CONSULTA #DADOS x = 0 for obj in lista: sheet.getCell(0, x + 3).setAlignHorizontal('left').stringValue( obj.tbtitulo.cdtitulo) sheet.getCell(1, x + 3).setAlignHorizontal('left').stringValue( obj.tbprocessobase.nrprocesso) sheet.getCell(4, x + 3).setAlignHorizontal('left').stringValue( obj.tbprocessobase.tbgleba.nmgleba) sheet.getCell(5, x + 3).setAlignHorizontal('left').stringValue( obj.tbprocessobase.tbmunicipio.nome_mun) sheet.getCell(8, x + 3).setAlignHorizontal('left').stringValue( obj.tbprocessobase.nmendereco) sheet.getCell(9, x + 3).setAlignHorizontal('left').stringValue( obj.tbprocessobase.nmcontato) try: sheet.getCell( 10, x + 3).setAlignHorizontal('left').stringValue( obj.tbprocessobase.tbmunicipiodomicilio.nome_mun) except: sheet.getCell(10, x + 3).setAlignHorizontal('left').stringValue('') try: sheet.getCell(11, x + 3).setAlignHorizontal('left').stringValue( obj.tbtitulo.tbcaixa.nmlocalarquivo) except: sheet.getCell(11, x + 3).setAlignHorizontal('left').stringValue('') for obj2 in lista_processo: if obj.tbprocessobase.id == obj2.tbprocessobase.id: sheet.getCell(2, x + 3).setAlignHorizontal('left').stringValue( obj2.nmrequerente) sheet.getCell(3, x + 3).setAlignHorizontal('left').stringValue( obj2.nrcpfrequerente) sheet.getCell(6, x + 3).setAlignHorizontal('left').stringValue( obj2.nmconjuge) sheet.getCell(7, x + 3).setAlignHorizontal('left').stringValue( obj2.nrcpfconjuge) x += 1 #TRECHO PERSONALIZADO DE CADA CONSULTA relatorio_ods_base(ods, planilha_relatorio) # generating response response = HttpResponse(mimetype=ods.mimetype.toString()) response[ 'Content-Disposition'] = 'attachment; filename=' + nome_relatorio + '.ods' ods.save(response) return response else: return HttpResponseRedirect(response_consulta)
def __init__(self, device_name, startdate, enddate, route_length, points): self.ods = ODS() self.device_name = device_name self.startdate = startdate self.enddate = enddate self.route_length = route_length self.points = points # sheet title sheet = self.ods.content.getSheet(0) sheet.setSheetName(self.device_name) # title sheet.getCell( 0, 0).stringValue(u"Συσκευή").setFontSize('12pt').setBold(True) sheet.getCell(1, 0).stringValue( self.device_name).setFontSize('12pt').setBold(True) sheet.getRow(0).setHeight('18pt') #sheet.getColumn(0).setWidth('10cm') # Start date cell = sheet.getCell( 0, 1).stringValue(u"Από:").setAlignHorizontal("right") sheet.getCell(1, 1).stringValue( self.startdate).setAlignHorizontal("right") #cell.setAlignHorizontal("right") # End date sheet.getCell(0, 2).stringValue(u"Εώς:").setAlignHorizontal("right") sheet.getCell(1, 2).stringValue(self.enddate).setAlignHorizontal("right") # Route Length sheet.getCell(0, 3).stringValue( u"Μήκος διαδρομής (km):").setAlignHorizontal("right") sheet.getCell(1, 3).floatValue( self.route_length).setAlignHorizontal("right") # Label for point s sheet.getCell( 0, 5).stringValue(u'Δεδομένα στιγμάτων').setAlignHorizontal("right") # Headers for points settings_header_points = (("id", "left"), ("Valid", "left"), ("Time", "left"), ("Latitude", "left"), ("Longitude", "left"), ("Altitude", "left"), ("Speed", "left"), ("Course", "left"), ("Power", "left"), ("Altitude", "left")) settings = collections.OrderedDict(settings_header_points) row = 6 # row of the headers for points index = 0 for k, v in settings_header_points: # set header value and alignment sheet.getCell(index, row).stringValue(k).setAlignHorizontal(v) index += 1 self.rowoffset = 8 # row offset from top (0) for (index, point) in enumerate(self.points): row = index + self.rowoffset # row to write cellvalues = [ point.id, point.valid, point.time, point.latitude, point.longtitude, point.altitude, point.speed, point.course, point.power, point.address ] for (i, value) in enumerate(cellvalues): # set value (i=cell) sheet.getCell( i, row).stringValue(value).setAlignHorizontal("left")
def relatorio_titulo_ods(request): titulos = request.session['titulos-caixa'] if titulos: #GERACAO nome_relatorio = "relatorio-titulos-caixa" titulo_relatorio = "RELATORIO DOS TITULOS DA CAIXA " + titulos[ 0].tbtitulo.tbcaixa.nmlocalarquivo planilha_relatorio = "Titulos da Caixa" ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, len(titulos), ods) # TITULOS DAS COLUNAS sheet.getCell(0, 6).setAlignHorizontal('center').stringValue( 'Titulo').setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(1, 6).setAlignHorizontal('center').stringValue( 'Processo').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell(2, 6).setAlignHorizontal('center').stringValue( 'Requerente').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell(3, 6).setAlignHorizontal('center').stringValue( 'CPF').setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(4, 6).setAlignHorizontal('center').stringValue( 'Imovel em').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell(5, 6).setAlignHorizontal('center').stringValue( 'Gleba').setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getRow(1).setHeight('20pt') sheet.getRow(2).setHeight('20pt') sheet.getRow(6).setHeight('20pt') sheet.getColumn(0).setWidth("2in") sheet.getColumn(1).setWidth("2in") sheet.getColumn(2).setWidth("5in") sheet.getColumn(3).setWidth("2in") sheet.getColumn(4).setWidth("5in") sheet.getColumn(5).setWidth("5in") #DADOS DA CONSULTA x = 5 for obj in titulos: sheet.getCell(0, x + 2).setAlignHorizontal('center').stringValue( obj.tbtitulo.cdtitulo) sheet.getCell(1, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.nrprocesso) sheet.getCell(4, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.tbmunicipio.nome_mun) sheet.getCell(5, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.tbgleba.nmgleba) r = Tbprocessorural.objects.get( tbprocessobase__id=obj.tbprocessobase.id) sheet.getCell(2, x + 2).setAlignHorizontal('center').stringValue( r.nmrequerente) sheet.getCell(3, x + 2).setAlignHorizontal('center').stringValue( r.nrcpfrequerente) x += 1 #GERACAO DO DOCUMENTO relatorio_ods_base(ods, planilha_relatorio) response = HttpResponse(mimetype=ods.mimetype.toString()) response[ 'Content-Disposition'] = 'attachment; filename=' + nome_relatorio + '.ods' ods.save(response) return response else: return HttpResponseRedirect(response_consulta)
def relatorio_ods(request): processos = request.session['processos-caixa'] if processos: #GERACAO nome_relatorio = "relatorio-processos-caixa" titulo_relatorio = "RELATORIO DOS PROCESSOS DA CAIXA " + processos[ 0].tbprocessobase.tbcaixa.nmlocalarquivo planilha_relatorio = "Processos da Caixa" ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, len(processos), ods) # TITULOS DAS COLUNAS sheet.getCell(0, 6).setAlignHorizontal('center').stringValue( 'Processo').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") if processos[ 0].tbprocessobase.tbtipoprocesso.tabela == 'tbprocessourbano': sheet.getCell(1, 6).setAlignHorizontal('center').stringValue( 'Povoado').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") else: sheet.getCell(1, 6).setAlignHorizontal('center').stringValue( 'Requerente').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") if processos[ 0].tbprocessobase.tbtipoprocesso.tabela == 'tbprocessourbano': sheet.getCell(2, 6).setAlignHorizontal('center').stringValue( 'CNPJ').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") else: sheet.getCell( 2, 6).setAlignHorizontal('center').stringValue('CPF').setFontSize( '14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(3, 6).setAlignHorizontal('center').stringValue( 'Principal | Anexo').setFontSize('14pt').setBold( True).setCellColor("#ccff99") sheet.getCell(4, 6).setAlignHorizontal('center').stringValue( 'Tipo').setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(5, 6).setAlignHorizontal('center').stringValue( 'Imovel / Gleba').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell(6, 6).setAlignHorizontal('center').stringValue( 'Endereco').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell( 7, 6).setAlignHorizontal('center').stringValue('Contato').setFontSize( '14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(8, 6).setAlignHorizontal('center').stringValue( 'Ultima Caixa').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell(9, 6).setAlignHorizontal('center').stringValue( 'Qtd. Pendencias').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell(10, 6).setAlignHorizontal('center').stringValue( 'Pendentes').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getCell(11, 6).setAlignHorizontal('center').stringValue( 'Notificadas').setFontSize('14pt').setBold(True).setCellColor( "#ccff99") sheet.getRow(1).setHeight('20pt') sheet.getRow(2).setHeight('20pt') sheet.getRow(6).setHeight('20pt') sheet.getColumn(0).setWidth("2in") sheet.getColumn(1).setWidth("5in") sheet.getColumn(2).setWidth("2in") sheet.getColumn(3).setWidth("2in") sheet.getColumn(4).setWidth("2.5in") sheet.getColumn(5).setWidth("2.5in") sheet.getColumn(6).setWidth("3in") sheet.getColumn(7).setWidth("2in") sheet.getColumn(8).setWidth("2.5in") sheet.getColumn(9).setWidth("1.5in") sheet.getColumn(10).setWidth("2in") sheet.getColumn(11).setWidth("2in") #DADOS DA CONSULTA x = 5 for obj in processos: sheet.getCell(0, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.nrprocesso) nome = '' cpf = '' print obj.tbprocessobase.id if obj.tbprocessobase.tbtipoprocesso.id == 3: nome += obj.nmpovoado cpf += obj.nrcnpj elif obj.tbprocessobase.tbtipoprocesso.id == 1: nome += obj.nmrequerente cpf += obj.nrcpfrequerente else: if obj.nminteressado: nome += obj.nminteressado + " (Interessado) " cpf += obj.nrcpfinteressado + " (Interessado) " if obj.nmrequerente: cpf += obj.nrcpfrequerente + " (Titulado)" nome += obj.nmrequerente + " (Titulado)" sheet.getCell(1, x + 2).setAlignHorizontal('center').stringValue(nome) sheet.getCell(2, x + 2).setAlignHorizontal('center').stringValue(cpf) if obj.tbprocessobase.tbclassificacaoprocesso.id == 2: sheet.getCell( 3, x + 2).setAlignHorizontal('center').stringValue('ANEXO') else: sheet.getCell( 3, x + 2).setAlignHorizontal('center').stringValue('PRINCIPAL') sheet.getCell(4, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.tbtipoprocesso.nome) sheet.getCell(5, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.tbmunicipio.nome_mun + " / " + obj.tbprocessobase.tbgleba.nmgleba) sheet.getCell(6, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.nmendereco) sheet.getCell(7, x + 2).setAlignHorizontal('center').stringValue( obj.tbprocessobase.nmcontato) mov = Tbmovimentacao.objects.filter( tbprocessobase__id=obj.tbprocessobase.id).order_by("-id")[:1] if mov: sheet.getCell(8, x + 2).setAlignHorizontal('center').stringValue( mov[0].tbcaixa_id_origem.nmlocalarquivo) # buscar todas as pendencias do processo, que nao estao sanadas pendencias_pendente = Tbpendencia.objects.filter( Q(tbprocessobase__id=obj.tbprocessobase.id, tbstatuspendencia__id=2)) pendencias_notificado = Tbpendencia.objects.filter( Q(tbprocessobase__id=obj.tbprocessobase.id, tbstatuspendencia__id=3)) sheet.getCell(9, x + 2).setAlignHorizontal('center').stringValue( len(pendencias_pendente) + len(pendencias_notificado)) # buscando as descricoes das pendencias pendentes desc_pendencias = '' for pend in pendencias_pendente: desc_pendencias += pend.tbtipopendencia.dspendencia + ' : ' + pend.dsdescricao + ' | ' sheet.getCell( 10, x + 2).setAlignHorizontal('center').stringValue(desc_pendencias) # buscando as descricoes das pendencias notificadas desc_pendencias = '' for pend in pendencias_notificado: desc_pendencias += pend.tbtipopendencia.dspendencia + ' : ' + pend.dsdescricao + ' | ' sheet.getCell( 11, x + 2).setAlignHorizontal('center').stringValue(desc_pendencias) x += 1 #GERACAO DO DOCUMENTO relatorio_ods_base(ods, planilha_relatorio) response = HttpResponse(mimetype=ods.mimetype.toString()) response[ 'Content-Disposition'] = 'attachment; filename=' + nome_relatorio + '.ods' ods.save(response) return response else: return HttpResponseRedirect(response_consulta)
def relatorio_ods(request): processos = request.session['processos-caixa'] if processos: #GERACAO nome_relatorio = "relatorio-processos-caixa" titulo_relatorio = "RELATORIO DOS PROCESSOS DA CAIXA "+processos[0].tbprocessobase.tbcaixa.nmlocalarquivo planilha_relatorio = "Processos da Caixa" ods = ODS() sheet = relatorio_ods_base_header(planilha_relatorio, titulo_relatorio, len(processos), ods) # TITULOS DAS COLUNAS sheet.getCell(0, 6).setAlignHorizontal('center').stringValue( 'Processo' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") if processos[0].tbprocessobase.tbtipoprocesso.tabela == 'tbprocessourbano': sheet.getCell(1, 6).setAlignHorizontal('center').stringValue( 'Povoado' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") else: sheet.getCell(1, 6).setAlignHorizontal('center').stringValue( 'Requerente' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") if processos[0].tbprocessobase.tbtipoprocesso.tabela == 'tbprocessourbano': sheet.getCell(2, 6).setAlignHorizontal('center').stringValue( 'CNPJ' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") else: sheet.getCell(2, 6).setAlignHorizontal('center').stringValue( 'CPF' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(3, 6).setAlignHorizontal('center').stringValue( 'Principal | Anexo' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(4, 6).setAlignHorizontal('center').stringValue( 'Tipo' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(5, 6).setAlignHorizontal('center').stringValue( 'Imovel / Gleba' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(6, 6).setAlignHorizontal('center').stringValue( 'Endereco' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(7, 6).setAlignHorizontal('center').stringValue( 'Contato' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(8, 6).setAlignHorizontal('center').stringValue( 'Ultima Caixa' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(9, 6).setAlignHorizontal('center').stringValue( 'Qtd. Pendencias' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(10, 6).setAlignHorizontal('center').stringValue( 'Pendentes' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getCell(11, 6).setAlignHorizontal('center').stringValue( 'Notificadas' ).setFontSize('14pt').setBold(True).setCellColor("#ccff99") sheet.getRow(1).setHeight('20pt') sheet.getRow(2).setHeight('20pt') sheet.getRow(6).setHeight('20pt') sheet.getColumn(0).setWidth("2in") sheet.getColumn(1).setWidth("5in") sheet.getColumn(2).setWidth("2in") sheet.getColumn(3).setWidth("2in") sheet.getColumn(4).setWidth("2.5in") sheet.getColumn(5).setWidth("2.5in") sheet.getColumn(6).setWidth("3in") sheet.getColumn(7).setWidth("2in") sheet.getColumn(8).setWidth("2.5in") sheet.getColumn(9).setWidth("1.5in") sheet.getColumn(10).setWidth("2in") sheet.getColumn(11).setWidth("2in") #DADOS DA CONSULTA x = 5 for obj in processos: sheet.getCell(0, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.nrprocesso) nome = '' cpf = '' print obj.tbprocessobase.id if obj.tbprocessobase.tbtipoprocesso.id == 3: nome += obj.nmpovoado cpf += obj.nrcnpj elif obj.tbprocessobase.tbtipoprocesso.id == 1: nome += obj.nmrequerente cpf += obj.nrcpfrequerente else: if obj.nminteressado: nome += obj.nminteressado+" (Interessado) " cpf += obj.nrcpfinteressado+" (Interessado) " if obj.nmrequerente: cpf += obj.nrcpfrequerente+" (Titulado)" nome += obj.nmrequerente+" (Titulado)" sheet.getCell(1, x+2).setAlignHorizontal('center').stringValue(nome) sheet.getCell(2, x+2).setAlignHorizontal('center').stringValue(cpf) if obj.tbprocessobase.tbclassificacaoprocesso.id == 2: sheet.getCell(3, x+2).setAlignHorizontal('center').stringValue('ANEXO') else: sheet.getCell(3, x+2).setAlignHorizontal('center').stringValue('PRINCIPAL') sheet.getCell(4, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.tbtipoprocesso.nome) sheet.getCell(5, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.tbmunicipio.nome_mun+" / "+obj.tbprocessobase.tbgleba.nmgleba) sheet.getCell(6, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.nmendereco) sheet.getCell(7, x+2).setAlignHorizontal('center').stringValue(obj.tbprocessobase.nmcontato) mov = Tbmovimentacao.objects.filter( tbprocessobase__id = obj.tbprocessobase.id ).order_by("-id")[:1] if mov: sheet.getCell(8, x+2).setAlignHorizontal('center').stringValue(mov[0].tbcaixa_id_origem.nmlocalarquivo) # buscar todas as pendencias do processo, que nao estao sanadas pendencias_pendente = Tbpendencia.objects.filter( Q(tbprocessobase__id = obj.tbprocessobase.id, tbstatuspendencia__id = 2) ) pendencias_notificado = Tbpendencia.objects.filter( Q(tbprocessobase__id = obj.tbprocessobase.id, tbstatuspendencia__id = 3) ) sheet.getCell(9, x+2).setAlignHorizontal('center').stringValue( len(pendencias_pendente) + len(pendencias_notificado) ) # buscando as descricoes das pendencias pendentes desc_pendencias = '' for pend in pendencias_pendente: desc_pendencias += pend.tbtipopendencia.dspendencia + ' : ' + pend.dsdescricao + ' | ' sheet.getCell(10, x+2).setAlignHorizontal('center').stringValue( desc_pendencias ) # buscando as descricoes das pendencias notificadas desc_pendencias = '' for pend in pendencias_notificado: desc_pendencias += pend.tbtipopendencia.dspendencia + ' : ' + pend.dsdescricao + ' | ' sheet.getCell(11, x+2).setAlignHorizontal('center').stringValue( desc_pendencias ) x += 1 #GERACAO DO DOCUMENTO relatorio_ods_base(ods, planilha_relatorio) response = HttpResponse(mimetype=ods.mimetype.toString()) response['Content-Disposition'] = 'attachment; filename='+nome_relatorio+'.ods' ods.save(response) return response else: return HttpResponseRedirect( response_consulta )