Support page range conversion in xlsx documents
Problem
MsExcelDocumentBackend declares supports_pagination() = True and maps each worksheet to a sequential page number, but its convert() / _convert_workbook() methods do not respect the page_range parameter from in_doc.limits.page_range. All sheets are always processed regardless of the configured page range.
This is inconsistent with MsPowerpointDocumentBackend, which correctly applies page_range to filter slides during conversion.
Expected Behavior
When a user calls:
result = converter.convert("workbook.xlsx", page_range=(2, 4))
Only sheets 2–4 should be processed (where sheets are numbered sequentially starting from 1).
Proposed Implementation
In _convert_workbook(), apply page_range filtering to the sheet iteration, similar to how MsPowerpointDocumentBackend uses list slicing:
start_page, end_page = self.page_range
sheets = list(enumerate(workbook.worksheets))
selected_sheets = sheets[start_page - 1 : end_page]
This should also interact correctly with the existing sheet_names filter in MsExcelBackendOptions (i.e., page_range would apply to the filtered sheet list if sheet_names is set, or to all sheets otherwise).
Context
MsExcelDocumentBackendsource: docling/backend/ms_excel_backend.py- Reference implementation:
MsPowerpointDocumentBackendpage_range handling - The infrastructure for passing
page_rangeto the backend already exists viaInputDocument.limits.page_range
Hi Mr @ceberam, I'd love to work on this
My plan is to store self.page_range = in_doc.limits.page_range in __init__ (like the PPTX backend), then in _convert_workbook() apply the range after the existing sheet_names filter, so it stays consistent with page_count() (which already counts the filtered sheets). I'll keep iterating workbook.sheetnames and add tests covering page_range with and without sheet_names.
One quick question: should selected sheets keep their original page numbers (e.g. (2, 4) → pages 2, 3, 4, matching the PPTX backend), or be renumbered from 1? I'll go with preserving them unless you prefer otherwise. Thank you very much!
Thanks @DanielNg0729 ! I like the plan you described and I agree with keeping the original page numbers.