| 1 | from cStringIO import StringIO |
|---|
| 2 | from common import Invoice, repos, inv |
|---|
| 3 | import demo_chart |
|---|
| 4 | |
|---|
| 5 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.text', |
|---|
| 6 | 'basic.odt', report_name='basic') |
|---|
| 7 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.text', |
|---|
| 8 | 'invoice.odt', report_name='complicated') |
|---|
| 9 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.spreadsheet', |
|---|
| 10 | 'pivot.ods', report_name='pivot') |
|---|
| 11 | repos.add_report(Invoice, 'application/vnd.oasis.opendocument.presentation', |
|---|
| 12 | 'presentation.odp', report_name='presentation') |
|---|
| 13 | repos.add_report(None, 'application/vnd.oasis.opendocument.text', |
|---|
| 14 | 'columns.odt', report_name='column') |
|---|
| 15 | |
|---|
| 16 | if __name__ == '__main__': |
|---|
| 17 | # Add a chart to the invoice |
|---|
| 18 | inv['chart'] = repos.classes[Invoice].ids['pie'] |
|---|
| 19 | |
|---|
| 20 | # ODT |
|---|
| 21 | basic_report, _ = repos.classes[Invoice].ids['basic'] |
|---|
| 22 | file('bonham_basic.odt', 'wb').write(basic_report(o=inv).render().getvalue()) |
|---|
| 23 | report, _ = repos.classes[Invoice].ids['complicated'] |
|---|
| 24 | file('bonham_complicated.odt', 'wb').write(report(o=inv).render().getvalue()) |
|---|
| 25 | |
|---|
| 26 | # ODS |
|---|
| 27 | ods_report, _ = repos.classes[Invoice].ids['pivot'] |
|---|
| 28 | file('bonham_pivot.ods', 'wb').write(ods_report(o=inv).render().getvalue()) |
|---|
| 29 | |
|---|
| 30 | # ODP |
|---|
| 31 | odp_report, _ = repos.classes[Invoice].ids['presentation'] |
|---|
| 32 | file('bonham_presentation.odp', 'wb').write(odp_report(o=inv).render().getvalue()) |
|---|
| 33 | |
|---|
| 34 | # Columns example |
|---|
| 35 | column_report, _ = repos.classes[None].ids['column'] |
|---|
| 36 | lst = [[], ['i'], ['a', 'b'], [1, 2, 3], ['I', 'II', 'III', 'IV']] |
|---|
| 37 | file('test_columns.odt', |
|---|
| 38 | 'wb').write(column_report(lst=lst).render().getvalue()) |
|---|