Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New links to download excel export and word report #34

Closed
shapiromatron opened this issue Jul 8, 2020 · 2 comments · Fixed by #36
Closed

New links to download excel export and word report #34

shapiromatron opened this issue Jul 8, 2020 · 2 comments · Fixed by #36
Assignees

Comments

@shapiromatron
Copy link
Owner

shapiromatron commented Jul 8, 2020

A major requirement of the application is the ability to download the results of a bmds assessment in reports. We have some preliminary code that can generate these word and excel reports, but the purpose of this PR is just to stub out how users can access them and not actually connect them.

On the backend:

On the frontend:

  • create a new hamburger on the top-right on the lower "blue" navbar. A user should be able to click thew links to download Excel or Download Word. The reports should download succesfully.

Python-docx: https://python-docx.readthedocs.io/en/latest/

@shapiromatron
Copy link
Owner Author

shapiromatron commented Jul 20, 2020

Mock excel and word reports:

import io
from pathlib import Path
from docx import Document
import pandas as pd

# write excel file
df = pd.DataFrame(data=dict(a=[1,2,3],b=[4,5,6]))
f = io.BytesIO()
df.to_excel(f, index=False)
Path('~/Desktop/test.xlsx').expanduser().write_bytes(f.getvalue())

# write word file
f = io.BytesIO()
document = Document()
document.add_heading('Hello world', 0)
document.save(f)
Path('~/Desktop/test.docx').expanduser().write_bytes(f.getvalue())

In both cases, f is a file-like object, and f.getvalue() are the bytes for the excel/word object.

@bishwobhandari
Copy link
Contributor

PR merged in.

@shapiromatron shapiromatron linked a pull request Jul 21, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants