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

#259: Merged cells are split #299

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions jxls-poi/src/test/java/org/jxls/TestWorkbook.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,11 @@ public void close() {
}
}
}

/**
* @return all merged cell regions of current sheet
*/
public List<CellRangeAddress> getMergedRegions() {
return sheet.getMergedRegions();
}
}
33 changes: 33 additions & 0 deletions jxls-poi/src/test/java/org/jxls3/Issue259Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.jxls3;

import static org.junit.Assert.assertTrue;

import java.util.HashMap;
import java.util.List;

import org.apache.poi.ss.util.CellRangeAddress;
import org.junit.Test;
import org.jxls.Jxls3Tester;
import org.jxls.TestWorkbook;
import org.jxls.transform.poi.JxlsPoiTemplateFillerBuilder;

/**
* Merged cell region outside jx:area is missing
*/
public class Issue259Test {

@Test
public void test() {
// Test
Jxls3Tester tester = Jxls3Tester.xlsx(getClass());
tester.test(new HashMap<>(), JxlsPoiTemplateFillerBuilder.newInstance());

// Verify
try (TestWorkbook w = tester.getWorkbook()) {
w.selectSheet(0);
List<CellRangeAddress> mergedRegions = w.getMergedRegions();
assertTrue("Missing merged region B5:C5", mergedRegions.stream().anyMatch(i -> "B5:C5".equals(i.formatAsString())));
assertTrue("Missing merged region A1:C3", mergedRegions.stream().anyMatch(i -> "A1:C3".equals(i.formatAsString())));
}
}
}
Binary file not shown.
Loading