Skip to content

Commit 4a9c954

Browse files
committed
fix #676 : implemented ExcelReport class to generate an Excel file with multiple graphs at once
1 parent 355a2fd commit 4a9c954

File tree

12 files changed

+975
-38
lines changed

12 files changed

+975
-38
lines changed

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
include COPYING
2-
recursive-include larray/tests/data *.csv *.xlsx *.h5
2+
recursive-include larray/tests/data *.csv *.xlsx *.h5
3+
recursive-include larray/tests/excel_template *.crtx

doc/source/api.rst

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,37 @@ Excel
675675
Workbook.close
676676
Workbook.app
677677

678+
ExcelReport
679+
===========
680+
681+
.. autosummary::
682+
:toctree: _generated/
683+
684+
ExcelReport
685+
ExcelReport.template_dir
686+
ExcelReport.template
687+
ExcelReport.set_item_default_size
688+
ExcelReport.graphs_per_row
689+
ExcelReport.new_sheet
690+
ExcelReport.sheet_names
691+
ExcelReport.to_excel
692+
693+
ReportSheet
694+
===========
695+
696+
.. autosummary::
697+
:toctree: _generated/
698+
699+
ReportSheet
700+
ReportSheet.template_dir
701+
ReportSheet.template
702+
ReportSheet.set_item_default_size
703+
ReportSheet.graphs_per_row
704+
ReportSheet.add_title
705+
ReportSheet.add_graph
706+
ReportSheet.add_graphs
707+
ReportSheet.newline
708+
678709
.. _api-misc:
679710

680711
Miscellaneous

doc/source/changes/version_0_31.rst.inc

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,30 +18,8 @@ Backward incompatible changes
1818
New features
1919
^^^^^^^^^^^^
2020

21-
* added a feature (see the :ref:`miscellaneous section <misc>` for details). It works on :ref:`api-axis` and
22-
:ref:`api-group` objects.
23-
24-
Here is an example of the new feature:
25-
26-
>>> arr = ndtest((2, 3))
27-
>>> arr
28-
a\b b0 b1 b2
29-
a0 0 1 2
30-
a1 3 4 5
31-
32-
And it can also be used like this:
33-
34-
>>> arr = ndtest("a=a0..a2")
35-
>>> arr
36-
a a0 a1 a2
37-
0 1 2
38-
39-
* added another feature in the editor (closes :editor_issue:`1`).
40-
41-
.. note::
42-
43-
- It works for foo bar !
44-
- It does not work for foo baz !
21+
* added the :py:obj:`ExcelReport` class allowing to generate multiple graphs in an
22+
Excel file at once (closes :issue:`676`).
4523

4624

4725
.. _misc:

larray/__init__.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from larray.inout.sas import read_sas
3131
from larray.inout.stata import read_stata
3232
from larray.inout.xw_excel import open_excel, Workbook
33+
from larray.inout.xw_reporting import ExcelReport
3334

3435
# just make sure handlers for .pkl and .pickle are initialized
3536
import larray.inout.pickle as _pkl
@@ -41,7 +42,7 @@
4142

4243
from larray.extra.ipfp import ipfp
4344

44-
from larray.example import get_example_filepath, load_example_data
45+
from larray.example import get_example_filepath, load_example_data, EXAMPLE_EXCEL_TEMPLATES_DIR
4546

4647
import larray.random
4748

@@ -75,15 +76,16 @@
7576
'real_if_close', 'interp', 'isnan', 'isinf', 'inverse',
7677
# inout
7778
'from_lists', 'from_string', 'from_frame', 'from_series', 'read_csv', 'read_tsv',
78-
'read_eurostat', 'read_excel', 'read_hdf', 'read_sas', 'read_stata', 'open_excel', 'Workbook',
79+
'read_eurostat', 'read_excel', 'read_hdf', 'read_sas', 'read_stata',
80+
'open_excel', 'Workbook', 'ExcelReport',
7981
# utils
8082
'get_options', 'set_options',
8183
# viewer
8284
'view', 'edit', 'compare',
8385
# ipfp
8486
'ipfp',
8587
# example
86-
'get_example_filepath', 'load_example_data',
88+
'get_example_filepath', 'load_example_data', 'EXAMPLE_EXCEL_TEMPLATES_DIR',
8789
]
8890

8991

larray/example.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,18 @@
22
import larray as la
33

44

5-
EXAMPLE_FILES_DIR = os.path.dirname(__file__) + '/tests/data/'
5+
_TEST_DIR = os.path.join(os.path.dirname(__file__), 'tests')
6+
7+
EXAMPLE_FILES_DIR = os.path.join(_TEST_DIR, 'data')
8+
# TODO : replace 'demography.h5' by 'population_session.h5' and remove 'demo' ?
69
AVAILABLE_EXAMPLE_DATA = {
10+
'demo': os.path.join(EXAMPLE_FILES_DIR, 'population_session.h5'),
711
'demography': os.path.join(EXAMPLE_FILES_DIR, 'demography.h5')
812
}
913
AVAILABLE_EXAMPLE_FILES = os.listdir(EXAMPLE_FILES_DIR)
1014

15+
EXAMPLE_EXCEL_TEMPLATES_DIR = os.path.join(_TEST_DIR, 'excel_template')
16+
1117

1218
def get_example_filepath(fname):
1319
"""Return absolute path to an example file if exist.

0 commit comments

Comments
 (0)