[Stoq-devel] [StoqlibReporting]Sugestão deacesso
Guedes
billguedes at terra.com.br
Thu Apr 21 14:26:12 BRT 2005
Olá Lista,
Segue abaixo uma sugestão de acesso a biblioteca StoqlibReporting.
Acessão Padrão:
from stoqlib.reporting import print_preview, \
build_report, \
ReportTemplate
from stoqlib.reporting.tables import ObjectTableColumn as OTC, \
RIGHT
class ObjectTableColumnTest(ReportTemplate):
report_name = "Simples teste com ObjectTableColumn"
def __init__(self, filename, clients):
ReportTemplate.__init__(self, filename,
self.report_name)
self.add_title("Relatório de Clientes")
self.add_object_table(clients, self.get_cols())
def get_cols(self):
return [OTC("Cod.", lambda obj: "%04d" % obj.id,
width=80, align=RIGHT),
OTC("Nome", lambda obj: obj.name, width=400)]
class Client:
def __init__(self, id, name):
self.id, self.name = (id, name)
client_list = []
for i in range(35):
client = Client(i, "Nome do cliente #%d" % i)
client_list.append(client)
report_file = build_report(ObjectTableColumnTest, client_list)
print_preview(report_file)
Minha Sugestão:
from stoqlib.reporting.tables import TableColumn as TC, RIGHT
from stoqlib.reporting import print_preview, build_report,
ReportTemplate
linha= []
for registro in range(35):
id= registro
nome= 'Nome %s' % registro
fone= 'Fone %s' % registro
coluna=[id, nome, fone]
linha.append(coluna)
r= ReportTemplate('arquivo.pdf', 'Relatório de Clientes', landscape=
1)
cabecalho= [TC('ID', 20), TC('Nome', 300), TC('Fone', 50)]
r.add_column_table(linha, cabecalho)
r.save()
print_preview('arquivo.pdf')
--
Abraços,
Guedes.
============================================
*** Nada é Impossível, Apenas Improvável ***
*** Seja Livre, Use GNU/Linux ***
UIN-> 177815213
E-MAIL'S:
PHP-> billguedes.php at terra.com.br
OUTROS-> billguedes at ig.com.br
PYTHON-> billguedes.python at terra.com.br
EMPRESAS-> billguedes at terra.com.br
GNU/LINUX-> billguedes.linux at terra.com.br
SISTEMA: Debian GNU/Linux - Kernel 2.4.27
More information about the Stoq-devel
mailing list