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

Automatic row height feature #344

Open
luca-vercelli opened this issue Jan 14, 2025 · 2 comments
Open

Automatic row height feature #344

luca-vercelli opened this issue Jan 14, 2025 · 2 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@luca-vercelli
Copy link

If I am not wrong, there is no easy way to adjust rows height automatically.
I found a solution on stackoverflow. You have to create a new class AutoRowHeightCommand extends AbstractCommand. What about putting this class inside jxls itself?

Please note that this command only works for POI-based jxls:

@Override
public Size applyAt(CellRef cellRef, Context context) {
    Size size = this.area.applyAt(cellRef, context);

    PoiTransformer transformer = (PoiTransformer) area.getTransformer();
    Row row = transformer.getWorkbook().getSheet(cellRef.getSheetName()).getRow(cellRef.getRow());
    row.setHeight((short) -1);

    return size;
}

If you agree I could prepare a PR.

@luca-vercelli luca-vercelli added the enhancement New feature or request label Jan 14, 2025
@SoltauFintel
Copy link
Member

Yes, it would be nice if you could submit a PR. With test case and documentation?

@SoltauFintel SoltauFintel added this to the 3.1.0 milestone Jan 14, 2025
luca-vercelli pushed a commit to luca-vercelli/jxls that referenced this issue Jan 14, 2025
luca-vercelli pushed a commit to luca-vercelli/jxls that referenced this issue Jan 15, 2025
@luca-vercelli
Copy link
Author

I pushed both code and doc, however I need some help for tests.

https://github.com/luca-vercelli/jxls/blob/def0effd6b394da9bd2689f1ef8c52535e1a2ea9/jxls-poi/src/test/java/org/jxls3/AutoRowHeightTest.java#L33

Height in rows appears not set. According to implementation of XSSFRow::getHeightInPoints, if height is not set the function returns a default value. So I have no idea how to check that height is correct. Any idea? Thank you.

luca-vercelli pushed a commit to luca-vercelli/jxls that referenced this issue Jan 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants