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

Accept workbook as an object #32

Open
aprasai opened this issue Jan 10, 2022 · 1 comment
Open

Accept workbook as an object #32

aprasai opened this issue Jan 10, 2022 · 1 comment

Comments

@aprasai
Copy link

aprasai commented Jan 10, 2022

At the moment, xlsx2html function loads the workbook and reads an excel. This works fine if it is a small workbook, or only one sheet within the workbook that needs to be rendered. If we have a big excel workbook where multiple sheets need to be rendered from the same workbook, it will re-reads the workbook significantly adding time to it. However, if a openpyxl workbook object is accepted as an optional parameter, then it gets around the issue of reloading the workbook each time, if we need to render multiple sheets.

if workbook is None:
wb = openpyxl.load_workbook(filepath, data_only=True)
else:
wb=workbook

Apkawa added a commit that referenced this issue Jan 13, 2022
@Apkawa
Copy link
Owner

Apkawa commented Jan 13, 2022

Hello
You can use dev version
pip install -e "git+https://github.com/Apkawa/xlsx2html.git@dev#egg=xlsx2html"

import openpyxl
from xlsx2html import xlsx2html

XLSX_FILE = 'path/to/example.xlsx'

# Simple, but no work with parse_formula=True
out_file = xlsx2html(load_workbook(XLSX_FILE, data_only=True))

# Use converter

converter = XLSX2HTMLConverter(
    filepath=load_workbook(XLSX_FILE, data_only=True),
    parse_formula=True,
    formula_wb=load_workbook(XLSX_FILE, data_only=False),
)
out_file = converter.get_html_stream()

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

No branches or pull requests

2 participants