Giter Site home page Giter Site logo

marinho / geraldo Goto Github PK

View Code? Open in Web Editor NEW
190.0 30.0 106.0 10.56 MB

Geraldo is a reports engine for Python and Django applications. It uses the power of ReportLab and PIL to generate reports with page header and footer, child bands, report begin and summary bands, agreggation and graphic elements, etc.

Home Page: http://geraldoreports.org/

License: Other

Shell 0.19% Python 97.97% Racket 0.02% JavaScript 1.82%

geraldo's Introduction

Overview
========

Geraldo is a reports generator created to work like ReportBuilder, QuickReport
or Jasper Reports. It has bands with fixed width and flexible height to show on
top, summary, page header, page footer, in table or each one for an object.

It is under GPL and works only with Django framework and Python language.

It depends on ReportLab library to work.

Our main long terms goals are (those with (x) are working):

Engine API
----------

- Support to basic bands:
 - Page header (x)
 - Page footer (x)
 - Report top/begin (x)
 - Report summary (x)
 - Detail (x)
 - Group (x)
 - Child bands (x)
 - Table details
- Support graphics (x)
- Support charts - use graphics.Image to set a rendered char image (x)
 - Support with no dependency on charts generators
- Support aggregation fields (x)
- Support expression (x)
- Support calculated fields (x)
- Support multiples group bands (x)
- Support band-width in widgets (x)
- Support stylizing widgets (font, colors, borders and alignments) (x)
- Support subreports (x)
- Report inheritance and composition (x)
- Support canvas drawing
- Reports merging (many reports at once) (x)
- Multiple columns
- Events system (x)
- Caching (x)
- Map/Reduce generating
- Drill down reports

Generators
----------

- Best use of PDF generator (x)
- Export to HTML and maybe to TXT
- Export/import structure to/from a XMLized format

User interaction
----------------

- Have a GUI tool to design reports, if possible to be used in a web browser
- Have a way to create and print reports using a server, with no low leve coding
- Have a explicit, clear and full documentation (x)

Dependencies
------------

- ReportLab
- If you use Image graphic element, Python Imaging Library (PIL) is also necessary

Marinho Brandao
http://www.marinhobrandao.com/
[email protected]

geraldo's People

Contributors

hassanch avatar marinho avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

geraldo's Issues

redefining named object

When I try to generate two reports in one file I get this error:

File "C:\Python27\lib\site-packages\reportlab\pdfbase\pdfdoc.py", line 516, in Reference
raise ValueError, "redefining named object: "+repr(name)
ValueError: redefining named object: 'toUnicodeCMap:AAAAAA+ArialMT'

my_report = MyFamilyReport(queryset=family)
c = my_report.generate_by(PDFGenerator, return_canvas=True, filename = 'family.pdf')
my_report = MyFamilyReport(queryset=family1)
my_report.generate_by(PDFGenerator, canvas = c)

utf-8 in page_tittle is abnormal

utf-8 characters show up correctly in band_detail , but utf-8 in page_tittle is abnormal !
Chinese characters show as a black box. why ? who to fix it ?

code as below:

import os
cur_dir = os.path.dirname(os.path.abspath(__file__))

#from django.contrib.auth.models import Permission

from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.lib.enums import TA_CENTER, TA_RIGHT

from geraldo import Report, ReportBand, Label, ObjectValue, SystemField,\
    FIELD_ACTION_COUNT, BAND_WIDTH


class PermissionsReport(Report):
    additional_fonts = {
        'wqy': '/Users/pset/Downloads/wqy-microhei/wqy-microhei.ttc'
    }
    default_style = {'fontName': 'wqy'}

    title = u'Permissions list(牛逼)'


    class band_begin(ReportBand):
        height = 1*cm
        elements = [
            Label(text='Look those permissions please', top=0.1*cm,
                left=8*cm),
        ]

    class band_summary(ReportBand):
        height = 0.7*cm
        elements = [
            Label(text="That's all", top=0.1*cm, left=0),
            ObjectValue(attribute_name='name', top=0.1*cm, left=3*cm,
                action=FIELD_ACTION_COUNT,
                display_format='%s permissions found'),
        ]
        borders = {'all': True}

    class band_page_header(ReportBand):
        height = 1.3*cm
        elements = [
            SystemField(expression='%(report_title)s', top=0.1*cm,
                left=0, width=BAND_WIDTH, style={'fontName': 'Helvetica-Bold',
                'fontSize': 14, 'alignment': TA_CENTER}),
            Label(text="ID", top=0.8*cm, left=0),
            Label(text="Name", top=0.8*cm, left=3*cm),
            Label(text="Longitude", top=0.8*cm, left=6*cm),
            Label(text="Latitude", top=0.8*cm, left=9*cm),
            Label(text="Number", top=0.8*cm, left=12*cm),
        ]
        borders = {'bottom': True}

    class band_page_footer(ReportBand):
        height = 0.5*cm
        elements = [
            Label(text='Created with Geraldo Reports', top=0.1*cm, left=0),
            SystemField(expression='Page # %(page_number)d (%(first_page_number)d ~ %(last_page_number)d, total: %(page_count)d)',
                top=0.1*cm, width=BAND_WIDTH, style={'alignment': TA_RIGHT}),
        ]
        borders = {'top': True}

    class band_detail(ReportBand):
        height = 0.5*cm
        elements = [
            ObjectValue(attribute_name='id', top=0, left=0),
            ObjectValue(attribute_name='name', top=0, left=3*cm, width=10*cm),
            ObjectValue(attribute_name='lon', top=0, left=6*cm, width=10*cm),
            ObjectValue(attribute_name='lat', top=0, left=9*cm, width=10*cm),
            ObjectValue(attribute_name='num', top=0, left=12*cm, width=10*cm),
        ]


id = range(12)
city_name = [u'福冈', u'川崎', u'神户', u'名古屋', u'大阪', u'仙台', u'广岛', u'北九州', u'京都', u'冈山', u'扎幌', u'东京']
lon = [ 33.39, 35.32, 34.41, 35.1, 34.4, 38.16, 34.23, 33.52,  35, 34.4,  43.05, 35.41]
lat = [130.21, 139.43, 135.1, 136.55, 135.3, 140.52, 132.27, 130.49, 135.45, 133.54, 141.21, 139.44]
num = [333, 124, 555, 324, 330, 656, 876, 914, 154, 876, 908, 924]


class myObj():
    def __init__(self,ids= 1,name= 2,lon= 3,lat= 4,num= 5):
        self.id = ids
        self.name = name
        self.lon = lon
        self.lat = lat
        self.num = num

dataset = []

for i,j,k,l,m in zip(id,city_name,lon,lat,num):
    dataset.append(myObj(i,j,k,l,m))

print dataset

report = PermissionsReport(queryset= dataset)

#PDF generation

from geraldo.generators import PDFGenerator

report.generate_by(PDFGenerator,
                   filename=os.path.join(cur_dir, 'output/simple-report.pdf'),
                   encode_to="utf-8",
                   first_page_number=5)

#Text generation

from geraldo.generators import TextGenerator

report.generate_by(
    TextGenerator,
    filename=os.path.join(cur_dir, 'output/simple-report.txt'),
    to_printer=False,
    encode_to='utf-8',
    first_page_number=5,
)

#Page with half height (starting page number from default: 1)

report.page_size = (A4[0], A4[1] / 2)

report.generate_by(PDFGenerator, filename=os.path.join(cur_dir, 'output/simple-report-half-height.pdf'))

Multi Column display of objects

It appears that there is no way to display objects in multiple columns? That is data from sequential objects arranged across rows and columns

Using geraldo on django project

I have my django projects and I want to use deraldo to create reports(pdf).
How can I use geraldo on django?
I have tried to my level test to find tutorials/user guide, I have found none of it

Export to Excel

Hi, I am looking around for a reporting engine to use in my internal website. Is it possible to export report to excel and/or csv?

No way to enumerate rows

I don't know how to enumerate rows in a report. For example I want to create an invoice with concurrent numbers:

No. Name Value

  1. X 100
  2. Y 200
  3. Z 500

How do you create values in column "No." (i.e. 1,2,3,4,....)

UnicodeEncodeError: 'ascii' codec can't encode character

Hi, got this:

Traceback (most recent call last):
  File "/opt/easycloud_django/easypanel/views.py", line 882, in adminServerReportCsv
    report_server.generate_by(CSVGenerator, filename=resp)
  File "/opt/easycloud_env/lib/python2.6/site-packages/geraldo/base.py", line 435, in generate_by
    return generator.execute()
  File "/opt/easycloud_env/lib/python2.6/site-packages/geraldo/generators/csvgen.py", line 66, in execute
    self.generate_csv()
  File "/opt/easycloud_env/lib/python2.6/site-packages/geraldo/generators/csvgen.py", line 119, in generate_csv
    self.writer.writerow(cells)
UnicodeEncodeError: 'ascii' codec can't encode character u'\xe8' in position 3: ordinal not in range(128)

When subclassing:

class myBandDetail(DetailBand):
                elements = [
                    ObjectValue(expression='user.username'),
                    ObjectValue(expression='user.first_name'),
                    ObjectValue(expression='user.last_name'),
                    ObjectValue(expression='name'),
                    ObjectValue(expression='plan.name'),
                    ObjectValue(attribute_name='creation_date',
                                get_value=lambda instance: instance.creation_date.strftime('%d/%m/%Y %H:%M')),
                    ObjectValue(attribute_name='deletion_date',
                                get_value=lambda instance: instance.deletion_date.strftime('%d/%m/%Y %H:%M') if instance.deletion_date else '',
                    ),
                    ObjectValue(expression='month_billing',
                                get_value=lambda instance: ('%.2f' % instance.month_billing).replace('.',','),
                    ),
                ]

where user.last_name contains "è" or other non-ascii char

FYI: TypeError: strftime() argument 1 must be str, not unicode

File "/usr/lib/python2.5/site-packages/Geraldo-0.4.14-py2.5.egg/geraldo/utils.py", line 119, in format_date
return date.strftime(expression)
TypeError: strftime() argument 1 must be str, not unicode

I got this error when I moved the code to the production server, although it was fine on development server. To fix it I just changed the line in utils.py to convert expression to string. Not sure if this is a fix that should be put into the main code or if the real problem is one of my settings somewhere...

Line 118 in utils.py

return date.strftime(str(expression))

Report headers

Is there anyway that I can create a report header ABOVE the page header? Banding seems to work like this:

band_page_header
band_begin
[band_detail]
band_summary
band_page_footer

The logical place to put this is in the a "report header" is in band_begin this does not work well as band_begin comes after the page header and the page headers have all of my column names so the report comes out strange.

col1 col2 col3 (band_page_header)

Report description (band_begin - first page only as desired)

[band_detail]

It would be much preferable for it to look like this

Report description (band_begin/band_report_header - first page only)

col1 col2 col3 (band_page_header)

[band_detail]

Any ideas how I could achieve this?

ObjectValue's clone() misses self.get_text

Hey, I'm a recent new user of Geraldo (version 0.4.12-stable) and love it!

Recently I hit a bug when defining a report using ObjectValue.get_text. Strangely, during report generation the value for get_text is None. Some debugging shows ObjectValue.clone() is called by ReportGenerator.clone() at geraldo/generators/base.py:201, and clone does not copy the reference for get_text.

Our temporary fix for this is to subclass ObjectValue and extend clone:

class CloneObjectValue(ObjectValue):
'''Enhanced ObjectValue with more correct cloning'''

def __init__(self, *args, **kwargs):
    super(CloneObjectValue, self).__init__(*args, **kwargs)

def clone(self):
    new = super(CloneObjectValue, self).clone()
    new.get_text = self.get_text
    return new

Progress Geraldo !

Hi,

Are there progress for new features and bug fixes to Geraldo? The project is stopped?

Thanks in advance.

Toninho Nunes

Poorly documented get_value and get_text

I was trying to make summary value printed in words. For example I want to print an invoice with summary value verbally like this:

Product | Value
X | 100
Y | 200

Sum: 300 (verbally: three hundred)

I did not find a way to do this. Display format does not allow to perform any functions on the value beeing displayed. On the other hand I cannot perform verbalizing function in get_value since it is summing those values. I was hoping on get_text, but this is poorly documented, no example given. Please either improve the documentation or at least give some examples on using get_text.

Getting Error Message

Illegal assignment of '904567891484' to 'value' in class Ean13BarcodeWidget

my model is as

class Items(models.Model):
i_date = models.DateTimeField(auto_now_add=True,verbose_name="item Date")
barcode = models.CharField(primary_key=True, max_length=24, verbose_name="item Id", help_text="place the barcode here")

view.py:

def barId_report(request):
resp = HttpResponse(mimetype='application/pdf')
item_list = Items.objects.all()
report = SimpleListReport(queryset=item_list)
report.generate_by(PDFGenerator, filename=resp)

    return resp

report.py

the normal one as given on the examples with code replaced to barcode.

By my gesture it is some problem arising due to the data retieved from my model as Unicode.
How to Over Come please help..

Better context in SubReport

In the detail_band of subreports, it uses the attributes from the subreport queryset, but in the band_header of subreport, it uses the attributes from the master report.

The suggestion is to make all of the bands in a subreport to get the attributes from the subreport's queryset, or making a filter to choose from what queryset to get the attributes from.

Bug on bottom border draw

If you set a graphic object for the bottom border, always draw a black line.

The problem is in generators/base.py on line 159:

graphic = isinstance(b_right, Graphic) and b_right or Line()

must be:

graphic = isinstance(b_bottom, Graphic) and b_bottom or Line()

seems like copy & paste ;-)

Geraldo incompatible with patched Reportlab for the latest GAE

Recently I was developing application for Google AppEngine with Django-nonrel and I discovered that the latest GAE doesn't work with Reportlab. I found patched version [1] which is unfortunately incompatible with Geraldo. That's because patched version is zipped and has to be imported with zipimport. So the solution is simple: every file that imports Reportlab has to do this according to zipimport documentation [2]. I can provide you with the patch. Any chance for it to be applied?

[1] http://ruudhelderman.appspot.com/testpdf
[2] http://docs.python.org/library/zipimport.html#examples

Cell borders with auto_expand_height

There's no way to create report with band detail in "full framing" (i.e. borders left, right, top, bottom) and auto_expand_height. If you create a row of ObjectValues with border: all thay do have the borders, but if any of the cells is expanded vertically, the rest of the cells have thir borders short in height.

Geraldo Reports not working

HI!
I tested the Geraldo Reports with Django 1.4.3 following the official documentation, but not working. I create the exact same example from doc for create a PDF of PermissionsReport.
http://www.geraldoreports.org/docs/examples/simple-report.html
The problem is, when i click in the link to download the pdf file, the name of pdf not appears in window and the file have this name:

bQtxVUB.pdf.part

This name change on each download attempt.
Any idea?
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.