IDE warnings, tried to reproduce Bug 58927, but could not
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1845434 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1d3abff9cb
commit
0cc8ec178f
@ -132,7 +132,7 @@ public class CellReference {
|
|||||||
if (rowRef.length() == 0) {
|
if (rowRef.length() == 0) {
|
||||||
_rowIndex = -1;
|
_rowIndex = -1;
|
||||||
} else {
|
} else {
|
||||||
// throws NumberFormatException if rowRef is not convertable to an int
|
// throws NumberFormatException if rowRef is not convertible to an int
|
||||||
_rowIndex = Integer.parseInt(rowRef)-1; // -1 to convert 1-based to zero-based
|
_rowIndex = Integer.parseInt(rowRef)-1; // -1 to convert 1-based to zero-based
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -336,10 +336,10 @@ public class CellReference {
|
|||||||
if(colStr.toUpperCase(Locale.ROOT).compareTo(lastCol) > 0) {
|
if(colStr.toUpperCase(Locale.ROOT).compareTo(lastCol) > 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} /*else {
|
||||||
// apparent column name has less chars than max
|
// apparent column name has less chars than max
|
||||||
// no need to check range
|
// no need to check range
|
||||||
}
|
}*/
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -426,7 +426,7 @@ public class CellReference {
|
|||||||
// AreaReference.separateAreaRefs()
|
// AreaReference.separateAreaRefs()
|
||||||
// SheetNameFormatter.format() (inverse)
|
// SheetNameFormatter.format() (inverse)
|
||||||
|
|
||||||
StringBuffer sb = new StringBuffer(indexOfSheetNameDelimiter);
|
StringBuilder sb = new StringBuilder(indexOfSheetNameDelimiter);
|
||||||
|
|
||||||
for(int i=1; i<lastQuotePos; i++) { // Note boundaries - skip outer quotes
|
for(int i=1; i<lastQuotePos; i++) { // Note boundaries - skip outer quotes
|
||||||
char ch = reference.charAt(i);
|
char ch = reference.charAt(i);
|
||||||
@ -495,11 +495,7 @@ public class CellReference {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuffer sb = new StringBuffer(64);
|
return getClass().getName() + " [" + formatAsString() + "]";
|
||||||
sb.append(getClass().getName()).append(" [");
|
|
||||||
sb.append(formatAsString());
|
|
||||||
sb.append("]");
|
|
||||||
return sb.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -147,6 +147,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument;
|
|||||||
* contain text, numbers, dates, and formulas. Cells can also be formatted.
|
* contain text, numbers, dates, and formulas. Cells can also be formatted.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||||
private static final POILogger logger = POILogFactory.getLogger(XSSFSheet.class);
|
private static final POILogger logger = POILogFactory.getLogger(XSSFSheet.class);
|
||||||
|
|
||||||
@ -472,7 +473,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
/**
|
/**
|
||||||
* Verify that candidate region does not intersect with an existing merged region in this sheet
|
* Verify that candidate region does not intersect with an existing merged region in this sheet
|
||||||
*
|
*
|
||||||
* @param candidateRegion
|
* @param candidateRegion the range of cells to verify
|
||||||
* @throws IllegalStateException if candidate region intersects an existing merged region in this sheet (or candidateRegion is already merged in this sheet)
|
* @throws IllegalStateException if candidate region intersects an existing merged region in this sheet (or candidateRegion is already merged in this sheet)
|
||||||
*/
|
*/
|
||||||
private void validateMergedRegions(CellRangeAddress candidateRegion) {
|
private void validateMergedRegions(CellRangeAddress candidateRegion) {
|
||||||
@ -855,8 +856,8 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
/**
|
/**
|
||||||
* Get a Hyperlink in this sheet anchored at row, column
|
* Get a Hyperlink in this sheet anchored at row, column
|
||||||
*
|
*
|
||||||
* @param row
|
* @param row The row where the hyperlink is anchored
|
||||||
* @param column
|
* @param column The column where the hyperlinkn is anchored
|
||||||
* @return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
|
* @return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@ -1480,8 +1481,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*
|
*
|
||||||
* @param startRowNum the first row number in this sheet to return
|
* @param startRowNum the first row number in this sheet to return
|
||||||
* @param endRowNum the last row number in this sheet to return
|
* @param endRowNum the last row number in this sheet to return
|
||||||
* @param createRowIfMissing
|
* @param createRowIfMissing If missing rows should be created.
|
||||||
* @return All rows between startRow and endRow, inclusive
|
* @return All rows between startRow and endRow, inclusive. If createRowIfMissing is false,
|
||||||
|
* only previously existing rows are returned, otherwise empty rows are added as necessary
|
||||||
* @throws IllegalArgumentException if startRowNum and endRowNum are not in ascending order
|
* @throws IllegalArgumentException if startRowNum and endRowNum are not in ascending order
|
||||||
*/
|
*/
|
||||||
private List<XSSFRow> getRows(int startRowNum, int endRowNum, boolean createRowIfMissing) {
|
private List<XSSFRow> getRows(int startRowNum, int endRowNum, boolean createRowIfMissing) {
|
||||||
@ -2472,7 +2474,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* 'Collapsed' state is stored in a single column col info record
|
* 'Collapsed' state is stored in a single column col info record
|
||||||
* immediately after the outline group
|
* immediately after the outline group
|
||||||
*
|
*
|
||||||
* @param idx
|
* @param idx The column-index to check
|
||||||
* @return a boolean represented if the column is collapsed
|
* @return a boolean represented if the column is collapsed
|
||||||
*/
|
*/
|
||||||
private boolean isColumnGroupCollapsed(int idx) {
|
private boolean isColumnGroupCollapsed(int idx) {
|
||||||
@ -3052,7 +3054,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
rebuildRows();
|
rebuildRows();
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void rebuildRows() {
|
private void rebuildRows() {
|
||||||
//rebuild the _rows map
|
//rebuild the _rows map
|
||||||
List<XSSFRow> rowList = new ArrayList<>(_rows.values());
|
List<XSSFRow> rowList = new ArrayList<>(_rows.values());
|
||||||
_rows.clear();
|
_rows.clear();
|
||||||
@ -3114,25 +3116,22 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
// then do the actual moving and also adjust comments/rowHeight
|
// then do the actual moving and also adjust comments/rowHeight
|
||||||
// we need to sort it in a way so the shifting does not mess up the structures,
|
// we need to sort it in a way so the shifting does not mess up the structures,
|
||||||
// i.e. when shifting down, start from down and go up, when shifting up, vice-versa
|
// i.e. when shifting down, start from down and go up, when shifting up, vice-versa
|
||||||
SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>(new Comparator<XSSFComment>() {
|
SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>((o1, o2) -> {
|
||||||
@Override
|
int row1 = o1.getRow();
|
||||||
public int compare(XSSFComment o1, XSSFComment o2) {
|
int row2 = o2.getRow();
|
||||||
int row1 = o1.getRow();
|
|
||||||
int row2 = o2.getRow();
|
|
||||||
|
|
||||||
if (row1 == row2) {
|
if (row1 == row2) {
|
||||||
// ordering is not important when row is equal, but don't return zero to still
|
// ordering is not important when row is equal, but don't return zero to still
|
||||||
// get multiple comments per row into the map
|
// get multiple comments per row into the map
|
||||||
return o1.hashCode() - o2.hashCode();
|
return o1.hashCode() - o2.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// when shifting down, sort higher row-values first
|
// when shifting down, sort higher row-values first
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
return row1 < row2 ? 1 : -1;
|
return row1 < row2 ? 1 : -1;
|
||||||
} else {
|
} else {
|
||||||
// sort lower-row values first when shifting up
|
// sort lower-row values first when shifting up
|
||||||
return row1 > row2 ? 1 : -1;
|
return row1 > row2 ? 1 : -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -3211,25 +3210,22 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
// then do the actual moving and also adjust comments/rowHeight
|
// then do the actual moving and also adjust comments/rowHeight
|
||||||
// we need to sort it in a way so the shifting does not mess up the structures,
|
// we need to sort it in a way so the shifting does not mess up the structures,
|
||||||
// i.e. when shifting down, start from down and go up, when shifting up, vice-versa
|
// i.e. when shifting down, start from down and go up, when shifting up, vice-versa
|
||||||
SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>(new Comparator<XSSFComment>() {
|
SortedMap<XSSFComment, Integer> commentsToShift = new TreeMap<>((o1, o2) -> {
|
||||||
@Override
|
int column1 = o1.getColumn();
|
||||||
public int compare(XSSFComment o1, XSSFComment o2) {
|
int column2 = o2.getColumn();
|
||||||
int column1 = o1.getColumn();
|
|
||||||
int column2 = o2.getColumn();
|
|
||||||
|
|
||||||
if (column1 == column2) {
|
if (column1 == column2) {
|
||||||
// ordering is not important when row is equal, but don't return zero to still
|
// ordering is not important when row is equal, but don't return zero to still
|
||||||
// get multiple comments per row into the map
|
// get multiple comments per row into the map
|
||||||
return o1.hashCode() - o2.hashCode();
|
return o1.hashCode() - o2.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
// when shifting down, sort higher row-values first
|
// when shifting down, sort higher row-values first
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
return column1 < column2 ? 1 : -1;
|
return column1 < column2 ? 1 : -1;
|
||||||
} else {
|
} else {
|
||||||
// sort lower-row values first when shifting up
|
// sort lower-row values first when shifting up
|
||||||
return column1 > column2 ? 1 : -1;
|
return column1 > column2 ? 1 : -1;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -4096,7 +4092,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
* Creates a new Table, and associates it with this Sheet.
|
* Creates a new Table, and associates it with this Sheet.
|
||||||
*
|
*
|
||||||
* @param tableArea
|
* @param tableArea
|
||||||
* the area that the table should cover, should not be {@null}
|
* the area that the table should cover, should not be null
|
||||||
* @return the created table
|
* @return the created table
|
||||||
* @since 4.0.0
|
* @since 4.0.0
|
||||||
*/
|
*/
|
||||||
@ -4421,18 +4417,15 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
+ "defined source sheet " + sourceSheet.getSheetName() + ".");
|
+ "defined source sheet " + sourceSheet.getSheetName() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
return createPivotTable(position, sourceSheet, new PivotTableReferenceConfigurator() {
|
return createPivotTable(position, sourceSheet, wsSource -> {
|
||||||
@Override
|
final String[] firstCell = source.getFirstCell().getCellRefParts();
|
||||||
public void configureReference(CTWorksheetSource wsSource) {
|
final String firstRow = firstCell[1];
|
||||||
final String[] firstCell = source.getFirstCell().getCellRefParts();
|
final String firstCol = firstCell[2];
|
||||||
final String firstRow = firstCell[1];
|
final String[] lastCell = source.getLastCell().getCellRefParts();
|
||||||
final String firstCol = firstCell[2];
|
final String lastRow = lastCell[1];
|
||||||
final String[] lastCell = source.getLastCell().getCellRefParts();
|
final String lastCol = lastCell[2];
|
||||||
final String lastRow = lastCell[1];
|
final String ref = firstCol+firstRow+':'+lastCol+lastRow; //or just source.formatAsString()
|
||||||
final String lastCol = lastCell[2];
|
wsSource.setRef(ref);
|
||||||
final String ref = firstCol+firstRow+':'+lastCol+lastRow; //or just source.formatAsString()
|
|
||||||
wsSource.setRef(ref);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4494,12 +4487,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
+ "defined source sheet " + sourceSheet.getSheetName() + ".");
|
+ "defined source sheet " + sourceSheet.getSheetName() + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
return createPivotTable(position, sourceSheet, new PivotTableReferenceConfigurator() {
|
return createPivotTable(position, sourceSheet, wsSource -> wsSource.setName(source.getNameName()));
|
||||||
@Override
|
|
||||||
public void configureReference(CTWorksheetSource wsSource) {
|
|
||||||
wsSource.setName(source.getNameName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4523,12 +4511,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
*/
|
*/
|
||||||
@Beta
|
@Beta
|
||||||
public XSSFPivotTable createPivotTable(final Table source, CellReference position) {
|
public XSSFPivotTable createPivotTable(final Table source, CellReference position) {
|
||||||
return createPivotTable(position, getWorkbook().getSheet(source.getSheetName()), new PivotTableReferenceConfigurator() {
|
return createPivotTable(position, getWorkbook().getSheet(source.getSheetName()), wsSource -> wsSource.setName(source.getName()));
|
||||||
@Override
|
|
||||||
public void configureReference(CTWorksheetSource wsSource) {
|
|
||||||
wsSource.setName(source.getName());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -4621,7 +4604,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* when a cell with a 'master' shared formula is removed, the next cell in the range becomes the master
|
* when a cell with a 'master' shared formula is removed, the next cell in the range becomes the master
|
||||||
* @param cell
|
* @param cell The cell that is removed
|
||||||
* @param evalWb BaseXSSFEvaluationWorkbook in use, if one exists
|
* @param evalWb BaseXSSFEvaluationWorkbook in use, if one exists
|
||||||
*/
|
*/
|
||||||
protected void onDeleteFormula(XSSFCell cell, BaseXSSFEvaluationWorkbook evalWb){
|
protected void onDeleteFormula(XSSFCell cell, BaseXSSFEvaluationWorkbook evalWb){
|
||||||
|
@ -50,7 +50,7 @@ public class ColumnHelper {
|
|||||||
TreeSet<CTCol> trackedCols = new TreeSet<>(CTColComparator.BY_MIN_MAX);
|
TreeSet<CTCol> trackedCols = new TreeSet<>(CTColComparator.BY_MIN_MAX);
|
||||||
CTCols newCols = CTCols.Factory.newInstance();
|
CTCols newCols = CTCols.Factory.newInstance();
|
||||||
CTCols[] colsArray = worksheet.getColsArray();
|
CTCols[] colsArray = worksheet.getColsArray();
|
||||||
int i = 0;
|
int i;
|
||||||
for (i = 0; i < colsArray.length; i++) {
|
for (i = 0; i < colsArray.length; i++) {
|
||||||
CTCols cols = colsArray[i];
|
CTCols cols = colsArray[i];
|
||||||
for (CTCol col : cols.getColList()) {
|
for (CTCol col : cols.getColList()) {
|
||||||
@ -61,7 +61,7 @@ public class ColumnHelper {
|
|||||||
worksheet.removeCols(y);
|
worksheet.removeCols(y);
|
||||||
}
|
}
|
||||||
|
|
||||||
newCols.setColArray(trackedCols.toArray(new CTCol[trackedCols.size()]));
|
newCols.setColArray(trackedCols.toArray(new CTCol[0]));
|
||||||
worksheet.addNewCols();
|
worksheet.addNewCols();
|
||||||
worksheet.setColsArray(0, newCols);
|
worksheet.setColsArray(0, newCols);
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,9 @@ import static org.junit.Assert.assertTrue;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
import org.apache.poi.xssf.model.StylesTable;
|
import org.apache.poi.xssf.model.StylesTable;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
@ -192,14 +195,14 @@ public final class TestColumnHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddCleanColIntoColsExactOverlap() throws Exception {
|
public void testAddCleanColIntoColsExactOverlap() {
|
||||||
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 1, 1, 1);
|
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 1, 1, 1);
|
||||||
assertEquals(1, cols.sizeOfColArray());
|
assertEquals(1, cols.sizeOfColArray());
|
||||||
assertMinMaxHiddenBestFit(cols, 0, 1, 1, true, true);
|
assertMinMaxHiddenBestFit(cols, 0, 1, 1, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddCleanColIntoColsOverlapsOverhangingBothSides() throws Exception {
|
public void testAddCleanColIntoColsOverlapsOverhangingBothSides() {
|
||||||
CTCols cols = createHiddenAndBestFitColsWithHelper(2, 2, 1, 3);
|
CTCols cols = createHiddenAndBestFitColsWithHelper(2, 2, 1, 3);
|
||||||
assertEquals(3, cols.sizeOfColArray());
|
assertEquals(3, cols.sizeOfColArray());
|
||||||
assertMinMaxHiddenBestFit(cols, 0, 1, 1, false, true);
|
assertMinMaxHiddenBestFit(cols, 0, 1, 1, false, true);
|
||||||
@ -208,7 +211,7 @@ public final class TestColumnHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddCleanColIntoColsOverlapsCompletelyNested() throws Exception {
|
public void testAddCleanColIntoColsOverlapsCompletelyNested() {
|
||||||
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 3, 2, 2);
|
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 3, 2, 2);
|
||||||
assertEquals(3, cols.sizeOfColArray());
|
assertEquals(3, cols.sizeOfColArray());
|
||||||
assertMinMaxHiddenBestFit(cols, 0, 1, 1, true, false);
|
assertMinMaxHiddenBestFit(cols, 0, 1, 1, true, false);
|
||||||
@ -217,7 +220,7 @@ public final class TestColumnHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddCleanColIntoColsNewOverlapsOverhangingLeftNotRightExactRight() throws Exception {
|
public void testAddCleanColIntoColsNewOverlapsOverhangingLeftNotRightExactRight() {
|
||||||
CTCols cols = createHiddenAndBestFitColsWithHelper(2, 3, 1, 3);
|
CTCols cols = createHiddenAndBestFitColsWithHelper(2, 3, 1, 3);
|
||||||
assertEquals(2, cols.sizeOfColArray());
|
assertEquals(2, cols.sizeOfColArray());
|
||||||
assertMinMaxHiddenBestFit(cols, 0, 1, 1, false, true);
|
assertMinMaxHiddenBestFit(cols, 0, 1, 1, false, true);
|
||||||
@ -225,7 +228,7 @@ public final class TestColumnHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddCleanColIntoColsNewOverlapsOverhangingRightNotLeftExactLeft() throws Exception {
|
public void testAddCleanColIntoColsNewOverlapsOverhangingRightNotLeftExactLeft() {
|
||||||
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 2, 1, 3);
|
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 2, 1, 3);
|
||||||
assertEquals(2, cols.sizeOfColArray());
|
assertEquals(2, cols.sizeOfColArray());
|
||||||
assertMinMaxHiddenBestFit(cols, 0, 1, 2, true, true);
|
assertMinMaxHiddenBestFit(cols, 0, 1, 2, true, true);
|
||||||
@ -233,7 +236,7 @@ public final class TestColumnHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddCleanColIntoColsNewOverlapsOverhangingLeftNotRight() throws Exception {
|
public void testAddCleanColIntoColsNewOverlapsOverhangingLeftNotRight() {
|
||||||
CTCols cols = createHiddenAndBestFitColsWithHelper(2, 3, 1, 2);
|
CTCols cols = createHiddenAndBestFitColsWithHelper(2, 3, 1, 2);
|
||||||
assertEquals(3, cols.sizeOfColArray());
|
assertEquals(3, cols.sizeOfColArray());
|
||||||
assertMinMaxHiddenBestFit(cols, 0, 1, 1, false, true);
|
assertMinMaxHiddenBestFit(cols, 0, 1, 1, false, true);
|
||||||
@ -242,7 +245,7 @@ public final class TestColumnHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testAddCleanColIntoColsNewOverlapsOverhangingRightNotLeft() throws Exception {
|
public void testAddCleanColIntoColsNewOverlapsOverhangingRightNotLeft() {
|
||||||
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 2, 2, 3);
|
CTCols cols = createHiddenAndBestFitColsWithHelper(1, 2, 2, 3);
|
||||||
assertEquals(3, cols.sizeOfColArray());
|
assertEquals(3, cols.sizeOfColArray());
|
||||||
assertMinMaxHiddenBestFit(cols, 0, 1, 1, true, false);
|
assertMinMaxHiddenBestFit(cols, 0, 1, 1, true, false);
|
||||||
@ -402,4 +405,36 @@ public final class TestColumnHelper {
|
|||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("deprecation")
|
||||||
|
@Test
|
||||||
|
public void testColumnsCollapsed() {
|
||||||
|
Workbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet = wb.createSheet("test");
|
||||||
|
Row row = sheet.createRow(0);
|
||||||
|
row.createCell(0);
|
||||||
|
row.createCell(1);
|
||||||
|
row.createCell(2);
|
||||||
|
|
||||||
|
sheet.setColumnWidth(0, 10);
|
||||||
|
sheet.setColumnWidth(1, 10);
|
||||||
|
sheet.setColumnWidth(2, 10);
|
||||||
|
|
||||||
|
sheet.groupColumn(0, 1);
|
||||||
|
sheet.setColumnGroupCollapsed(0, true);
|
||||||
|
|
||||||
|
CTCols ctCols = ((XSSFSheet) sheet).getCTWorksheet().getColsArray()[0];
|
||||||
|
assertEquals(3, ctCols.sizeOfColArray());
|
||||||
|
assertTrue(ctCols.getColArray(0).isSetCollapsed());
|
||||||
|
assertTrue(ctCols.getColArray(1).isSetCollapsed());
|
||||||
|
assertTrue(ctCols.getColArray(2).isSetCollapsed());
|
||||||
|
|
||||||
|
ColumnHelper helper = new ColumnHelper(CTWorksheet.Factory.newInstance());
|
||||||
|
helper.setColumnAttributes(ctCols.getColArray(1), ctCols.getColArray(2));
|
||||||
|
|
||||||
|
ctCols = ((XSSFSheet) sheet).getCTWorksheet().getColsArray()[0];
|
||||||
|
assertTrue(ctCols.getColArray(0).isSetCollapsed());
|
||||||
|
assertTrue(ctCols.getColArray(1).isSetCollapsed());
|
||||||
|
assertTrue(ctCols.getColArray(2).isSetCollapsed());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user