mirror of
https://github.com/apache/poi.git
synced 2026-02-27 12:30:08 +08:00
Do not call getColumn() twice
It always iterates over the array of columns, so we should reuse the result here.
This commit is contained in:
parent
ae3ed57baa
commit
62ae400993
@ -38,7 +38,7 @@ import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
|
||||
*/
|
||||
public class ColumnHelper {
|
||||
|
||||
private CTWorksheet worksheet;
|
||||
private final CTWorksheet worksheet;
|
||||
|
||||
public ColumnHelper(CTWorksheet worksheet) {
|
||||
super();
|
||||
@ -303,10 +303,15 @@ public class ColumnHelper {
|
||||
col.setStyle(styleId);
|
||||
}
|
||||
|
||||
// Returns -1 if no column is found for the given index
|
||||
/**
|
||||
* Get the default style index for the given column index
|
||||
*
|
||||
* @return The style-index or -1 if no column is found for the given index
|
||||
*/
|
||||
public int getColDefaultStyle(long index) {
|
||||
if (getColumn(index, false) != null) {
|
||||
return (int) getColumn(index, false).getStyle();
|
||||
final CTCol column = getColumn(index, false);
|
||||
if (column != null) {
|
||||
return (int) column.getStyle();
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -252,7 +252,7 @@ public final class TestColumnHelper {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and adds a hidden column and then a best fit column with the given min/max pairs.
|
||||
* Creates and adds a hidden column and then the best fit column with the given min/max pairs.
|
||||
* Suitable for testing handling of overlap.
|
||||
*/
|
||||
private static CTCols createHiddenAndBestFitColsWithHelper(int hiddenMin, int hiddenMax, int bestFitMin, int bestFitMax) {
|
||||
@ -404,7 +404,6 @@ public final class TestColumnHelper {
|
||||
return count;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Test
|
||||
void testColumnsCollapsed() throws IOException {
|
||||
try (XSSFWorkbook wb = new XSSFWorkbook()) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user