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

add an option for RangeCopier.copyRange() also clone styles #179

wants to merge 4 commits into from


Copy link

@xjlin0 xjlin0 commented Apr 30, 2020

Found out that currently RangeCopier.copyRange() only copy values and formulas, however it always pass hardcoded null styleMap to RangeCopier.cloneCellContent(), therefore no styles were copied. Not so sure why, so I added a boolean option for RangeCopier.copyRange() to copy styles.

The MR provides an additional argument on the current RangeCopier.copyRange(), while passing the boolean argument is optional. So it will be compatible with all existing codes using RangeCopier.copyRange().

myRangeCopier.copyRange(originalDataRange, destinationDataRange, true);
// the additional true enables style copying

myRangeCopier.copyRange(originalDataRange, destinationDataRange);
// works as before, copy range without copying styles

Tested in my company and the cell styles can be copied by copyRange(). Somehow we also need to include compile("org.apache.commons:commons-math3:3.0") for it to copy range with styles, probably due to local jar files including.

Copy link

centic9 commented May 1, 2020

Can you add a test-case which verifies the new option?

Copy link

xjlin0 commented May 1, 2020

Sure, I updated a test case. Here is the passing results: Tests passed: 15 of 15 tests - 2s 304ms.

22 actionable tasks: 13 executed, 9 up-to-date
3:38:39 PM: Task execution finished ' :main:test --tests "org.apache.poi.hssf.usermodel.TestHSSFRangeCopier" :ooxml:test --tests "" --continue'.

One follow up question for you @centic9 , I found out that the RangeCopier.copyRange() not only cannot copy styles but also cannot copy merged cells. So I am adding options to that function. Do you think the following signature looks good? Where could I also update the document? Thanks!

   CellRangeAddress tilePatternRange,
   CellRangeAddress tileDestRange,
   boolean copyStyles,
   boolean copyMergedRanges

Or should we just forget about the boolean option, make it always copy styles & merged ranges?

@asfgit asfgit closed this in 9bddb87 May 15, 2020
Copy link

Thanks - merged

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet
3 participants