Skip to content

Proposal: Support for multiple XLSX sheets via @ExcelSheet annotation #2

Description

@enirsilvaferraz

Hi there! 👋

First of all, I want to say thank you for this amazing library! FileMapper-KMP is a fantastic tool and it’s extremely useful for the KMP community, especially for those of us who need a lightweight and multiplatform way to handle Excel files without heavy dependencies. It really fills a gap in the ecosystem!

The Scenario

While working with the library, I came across a use case that I think could make this project even more powerful. Currently, the XLSX engine seems to be fixed on reading only the first sheet of the file (sheet1.xml).

In many real-world projects, we often receive Excel files with multiple tabs (e.g., one tab for "Employees", another for "Products", etc.). Being able to choose which tab to map to a specific Kotlin Data Class would be a game-changer.

Proposed Improvement

My suggestion is to introduce a declarative way to handle this using a new annotation, something like @ExcelSheet(name = "SheetName").

  1. Declarative Mapping: By annotating a Data Class, the engine would know exactly which tab to look for in the XLSX structure.
  2. Dynamic Sheet Resolution: Instead of a hardcoded path, the engine could look into xl/workbook.xml and xl/_rels/workbook.xml.rels to resolve the sheet name to its internal file path.
  3. Improved Robustness: I also noticed that some Excel files use inlineStr (using the <t> tag) instead of sharedStrings. Adding support for both would make the library much more robust and compatible with different Excel generators.

Ready to Contribute

I’ve been exploring the codebase and I've already prototyped a solution that keeps the API clean and 100% backward compatible (falling back to the first sheet if no annotation is present).

If you feel this feature aligns with your vision for the project, I’d be more than happy to work on this and submit a Pull Request!
Let me know what you think. Keep up the great work with this library! 🚀

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions