merge REL_3_10_FINAL with trunk r1563413

git-svn-id: https://svn.apache.org/repos/asf/poi/tags/REL_3_10_FINAL@1563415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Yegor Kozlov 2014-02-01 13:20:42 +00:00
commit a9b59608cb
24 changed files with 1144 additions and 526 deletions

View File

@ -158,6 +158,10 @@ under the License.
<property name="asm.jar" location="${main.lib}/asm-all-4.0.jar"/> <property name="asm.jar" location="${main.lib}/asm-all-4.0.jar"/>
<property name="asm.url" value="${repository.m2}/maven2/org/ow2/asm/asm-all/4.0/asm-all-4.0.jar"/> <property name="asm.url" value="${repository.m2}/maven2/org/ow2/asm/asm-all/4.0/asm-all-4.0.jar"/>
<!-- license checks -->
<property name="rat.jar" location="${main.lib}/apache-rat-0.10.jar"/>
<property name="rat.url" value="${repository.m2}/maven2/org/apache/rat/apache-rat/0.10/apache-rat-0.10.jar"/>
<!-- See http://www.ecma-international.org/publications/standards/Ecma-376.htm --> <!-- See http://www.ecma-international.org/publications/standards/Ecma-376.htm -->
<!-- "Copy these file(s), free of charge" --> <!-- "Copy these file(s), free of charge" -->
<property name="ooxml.xsds.ozip" location="${ooxml.lib}/OfficeOpenXML-Part4.zip"/> <property name="ooxml.xsds.ozip" location="${ooxml.lib}/OfficeOpenXML-Part4.zip"/>
@ -172,7 +176,6 @@ under the License.
<property name="ooxml.encryption.src.jar" location="${ooxml.lib}/ooxml-encryption-src-1.1.jar"/> <property name="ooxml.encryption.src.jar" location="${ooxml.lib}/ooxml-encryption-src-1.1.jar"/>
<property name="ooxml.encryption.jar" location="${ooxml.lib}/ooxml-encryption-1.1.jar"/> <property name="ooxml.encryption.jar" location="${ooxml.lib}/ooxml-encryption-1.1.jar"/>
<property name="maven.ooxml.xsds.version.id" value="1.0"/> <property name="maven.ooxml.xsds.version.id" value="1.0"/>
<property name="maven.ooxml.xsds.jar" value="ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/> <property name="maven.ooxml.xsds.jar" value="ooxml-schemas-${maven.ooxml.xsds.version.id}.jar"/>
@ -181,6 +184,10 @@ under the License.
<!-- Exclude some uninteresting classes from coverage-instrumentation as we do not want to measure coverage in those packages anyway --> <!-- Exclude some uninteresting classes from coverage-instrumentation as we do not want to measure coverage in those packages anyway -->
<property name="coverage.excludes" value="org.openxmlformats.*:com.*:org.junit.*:junit.*:"/> <property name="coverage.excludes" value="org.openxmlformats.*:com.*:org.junit.*:junit.*:"/>
<!-- Apache RAT license check properties -->
<property name="rat.reportdir" value="build/rat"/>
<property name="rat.report" value="${rat.reportdir}/report.txt"/>
<!-- build and distro settings --> <!-- build and distro settings -->
<property name="jar.name" value="poi"/> <property name="jar.name" value="poi"/>
<property name="build.site" location="build/tmp/site/build/site"/> <property name="build.site" location="build/tmp/site/build/site"/>
@ -343,6 +350,7 @@ under the License.
<available file="${main.ant.jar}"/> <available file="${main.ant.jar}"/>
<available file="${asm.jar}"/> <available file="${asm.jar}"/>
<available file="${jacoco.zip}"/> <available file="${jacoco.zip}"/>
<available file="${rat.jar}"/>
</and> </and>
<isset property="disconnected"/> <isset property="disconnected"/>
</or> </or>
@ -389,6 +397,10 @@ under the License.
<include name="lib/*.jar"/> <include name="lib/*.jar"/>
</patternset> </patternset>
</unzip> </unzip>
<antcall target="downloadfile">
<param name="sourcefile" value="${rat.url}"/>
<param name="destfile" value="${rat.jar}"/>
</antcall>
</target> </target>
<target name="check-ooxml-jars"> <target name="check-ooxml-jars">
@ -1305,7 +1317,7 @@ under the License.
</target> </target>
<target name="gump" depends="compile-all, test-all, jar"/> <target name="gump" depends="compile-all, test-all, jar"/>
<target name="jenkins" depends="compile-all, test-all, jar, javadocs, assemble"/> <target name="jenkins" depends="compile-all, test-all, jar, javadocs, assemble, rat-check"/>
<available property="maven.ant.tasks.present" classname="org.apache.maven.artifact.ant.Pom"/> <available property="maven.ant.tasks.present" classname="org.apache.maven.artifact.ant.Pom"/>
<target name="maven.ant.tasks-check"> <target name="maven.ant.tasks-check">
@ -1345,10 +1357,13 @@ under the License.
<!-- which are missing the correct license headers --> <!-- which are missing the correct license headers -->
<!-- You need to download rat from http://incubator.apache.org/rat/ --> <!-- You need to download rat from http://incubator.apache.org/rat/ -->
<!-- and place the Rat jar into your ant lib before running --> <!-- and place the Rat jar into your ant lib before running -->
<target name="rat-check"> <target name="rat-check" depends="check-jars,fetch-jars">
<mkdir dir="${rat.reportdir}" />
<typedef resource="org/apache/rat/anttasks/antlib.xml" <typedef resource="org/apache/rat/anttasks/antlib.xml"
uri="antlib:org.apache.rat.anttasks"/> uri="antlib:org.apache.rat.anttasks"
<rat:report xmlns:rat="antlib:org.apache.rat.anttasks"> classpath="${main.lib}/apache-rat-0.10.jar" />
<rat:report xmlns:rat="antlib:org.apache.rat.anttasks" reportFile="${rat.report}">
<fileset dir="src/"> <fileset dir="src/">
<exclude name="documentation/content/xdocs/dtd/" /> <exclude name="documentation/content/xdocs/dtd/" />
<exclude name="documentation/content/xdocs/entity/" /> <exclude name="documentation/content/xdocs/entity/" />
@ -1359,6 +1374,11 @@ under the License.
<exclude name="examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt" /> <exclude name="examples/src/org/apache/poi/xslf/usermodel/pie-chart-data.txt" />
</fileset> </fileset>
</rat:report> </rat:report>
<loadfile property="rat.reportcontent" srcFile="${rat.report}"/>
<echo>${rat.reportcontent}</echo>
<!-- fail the build if at least one note is in the report -->
<fail><condition><matches pattern="[1-9][0-9]* Unknown Licens" string="${rat.reportcontent}"/></condition></fail>
</target> </target>
</project> </project>

View File

@ -164,6 +164,7 @@ public final class AnalysisToolPak implements UDFFinder {
r(m, "YIELD", null); r(m, "YIELD", null);
r(m, "YIELDDISC", null); r(m, "YIELDDISC", null);
r(m, "YIELDMAT", null); r(m, "YIELDMAT", null);
r(m, "COUNTIFS", Countifs.instance);
return m; return m;
} }

View File

@ -1,7 +1,26 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.formula.functions; package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext; import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*; import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
/** /**
* Implementation for Excel Bin2Dec() function.<p/> * Implementation for Excel Bin2Dec() function.<p/>

View File

@ -0,0 +1,55 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
* Implementation for the function COUNTIFS
* <p>
* Syntax: COUNTIFS(criteria_range1, criteria1, [criteria_range2, criteria2])
* </p>
*/
public class Countifs implements FreeRefFunction {
public static final FreeRefFunction instance = new Countifs();
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
Double result = null;
if (args.length == 0 || args.length % 2 > 0) {
return ErrorEval.VALUE_INVALID;
}
for (int i = 0; i < args.length; ) {
ValueEval firstArg = args[i];
ValueEval secondArg = args[i + 1];
i += 2;
NumberEval evaluate = (NumberEval) new Countif().evaluate(new ValueEval[]{firstArg, secondArg}, ec.getRowIndex(), ec.getColumnIndex());
if (result == null) {
result = evaluate.getNumberValue();
} else if (evaluate.getNumberValue() < result) {
result = evaluate.getNumberValue();
}
}
return new NumberEval(result == null ? 0 : result);
}
}

View File

@ -1,7 +1,27 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.formula.functions; package org.apache.poi.ss.formula.functions;
import org.apache.poi.ss.formula.OperationEvaluationContext; import org.apache.poi.ss.formula.OperationEvaluationContext;
import org.apache.poi.ss.formula.eval.*; import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.StringEval;
import org.apache.poi.ss.formula.eval.ValueEval;
/** /**
* Implementation for Excel Bin2Dec() function.<p/> * Implementation for Excel Bin2Dec() function.<p/>

View File

@ -42,7 +42,16 @@ import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.formula.FormulaShifter; import org.apache.poi.ss.formula.FormulaShifter;
import org.apache.poi.ss.formula.SheetNameFormatter; import org.apache.poi.ss.formula.SheetNameFormatter;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellRange;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.DataValidation;
import org.apache.poi.ss.usermodel.DataValidationHelper;
import org.apache.poi.ss.usermodel.Footer;
import org.apache.poi.ss.usermodel.Header;
import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.ss.util.CellReference; import org.apache.poi.ss.util.CellReference;
@ -58,7 +67,48 @@ import org.apache.poi.xssf.usermodel.helpers.XSSFRowShifter;
import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlOptions; import org.apache.xmlbeans.XmlOptions;
import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId; import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTAutoFilter;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBreak;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellFormula;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComment;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCommentList;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataValidation;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDataValidations;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDrawing;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHeaderFooter;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTHyperlink;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTLegacyDrawing;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTMergeCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTMergeCells;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTOutlinePr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageBreak;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageMargins;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageSetUpPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPane;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPrintOptions;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSelection;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetFormatPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetView;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetViews;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTablePart;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTTableParts;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellFormulaType;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPaneState;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STUnsignedShortHex;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorksheetDocument;
/** /**
* High level representation of a SpreadsheetML worksheet. * High level representation of a SpreadsheetML worksheet.
@ -1206,9 +1256,24 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
private void groupColumn1Based(int fromColumn, int toColumn) { private void groupColumn1Based(int fromColumn, int toColumn) {
CTCols ctCols=worksheet.getColsArray(0); CTCols ctCols=worksheet.getColsArray(0);
CTCol ctCol=CTCol.Factory.newInstance(); CTCol ctCol=CTCol.Factory.newInstance();
// copy attributes, as they might be removed by merging with the new column
// TODO: check if this fix is really necessary or if the sweeping algorithm
// in addCleanColIntoCols needs to be adapted ...
CTCol fixCol_before = this.columnHelper.getColumn1Based(toColumn, false);
if (fixCol_before != null) {
fixCol_before = (CTCol)fixCol_before.copy();
}
ctCol.setMin(fromColumn); ctCol.setMin(fromColumn);
ctCol.setMax(toColumn); ctCol.setMax(toColumn);
this.columnHelper.addCleanColIntoCols(ctCols, ctCol); this.columnHelper.addCleanColIntoCols(ctCols, ctCol);
CTCol fixCol_after = this.columnHelper.getColumn1Based(toColumn, false);
if (fixCol_before != null && fixCol_after != null) {
this.columnHelper.setColumnAttributes(fixCol_before, fixCol_after);
}
for(int index=fromColumn;index<=toColumn;index++){ for(int index=fromColumn;index<=toColumn;index++){
CTCol col=columnHelper.getColumn1Based(index, false); CTCol col=columnHelper.getColumn1Based(index, false);
//col must exist //col must exist

View File

@ -17,13 +17,18 @@
package org.apache.poi.xssf.usermodel.helpers; package org.apache.poi.xssf.usermodel.helpers;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.LinkedHashMap; import java.util.Comparator;
import java.util.Map; import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.TreeSet;
import org.apache.poi.ss.usermodel.CellStyle; import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.util.CTColComparator; import org.apache.poi.xssf.util.CTColComparator;
import org.apache.poi.xssf.util.NumericRanges;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet; import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
@ -44,30 +49,130 @@ public class ColumnHelper {
this.worksheet = worksheet; this.worksheet = worksheet;
cleanColumns(); cleanColumns();
} }
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
public void cleanColumns() { public void cleanColumns() {
this.newCols = CTCols.Factory.newInstance(); this.newCols = CTCols.Factory.newInstance();
CTCols[] colsArray = worksheet.getColsArray();
int i = 0; CTCols aggregateCols = CTCols.Factory.newInstance();
for (i = 0; i < colsArray.length; i++) { List<CTCols> colsList = worksheet.getColsList();
CTCols cols = colsArray[i]; if (colsList != null) {
CTCol[] colArray = cols.getColArray(); for (CTCols cols : colsList) {
for (int y = 0; y < colArray.length; y++) { for (CTCol col : cols.getColList()) {
CTCol col = colArray[y]; cloneCol(aggregateCols, col);
newCols = addCleanColIntoCols(newCols, col); }
} }
} }
sortColumns(aggregateCols);
CTCol[] colArray = new CTCol[aggregateCols.getColList().size()];
aggregateCols.getColList().toArray(colArray);
sweepCleanColumns(newCols, colArray, null);
int i = colsList.size();
for (int y = i - 1; y >= 0; y--) { for (int y = i - 1; y >= 0; y--) {
worksheet.removeCols(y); worksheet.removeCols(y);
} }
worksheet.addNewCols(); worksheet.addNewCols();
worksheet.setColsArray(0, newCols); worksheet.setColsArray(0, newCols);
} }
private static class CTColByMaxComparator implements Comparator<CTCol> {
public int compare(CTCol arg0, CTCol arg1) {
if (arg0.getMax() < arg1.getMax()) {
return -1;
} else {
if (arg0.getMax() > arg1.getMax()) return 1;
else return 0;
}
}
}
/**
* @see http://en.wikipedia.org/wiki/Sweep_line_algorithm
*/
private void sweepCleanColumns(CTCols cols, CTCol[] flattenedColsArray, CTCol overrideColumn) {
List<CTCol> flattenedCols = new ArrayList<CTCol>(Arrays.asList(flattenedColsArray));
TreeSet<CTCol> currentElements = new TreeSet<CTCol>(new CTColByMaxComparator());
ListIterator<CTCol> flIter = flattenedCols.listIterator();
CTCol haveOverrideColumn = null;
long lastMaxIndex = 0;
long currentMax = 0;
while (flIter.hasNext()) {
CTCol col = flIter.next();
long currentIndex = col.getMin();
long nextIndex = (col.getMax() > currentMax) ? col.getMax() : currentMax;
if (flIter.hasNext()) {
nextIndex = flIter.next().getMin();
flIter.previous();
}
Iterator<CTCol> iter = currentElements.iterator();
while (iter.hasNext()) {
CTCol elem = iter.next();
if (currentIndex <= elem.getMax()) break; // all passed elements have been purged
iter.remove();
}
if (!currentElements.isEmpty() && lastMaxIndex < currentIndex) {
// we need to process previous elements first
insertCol(cols, lastMaxIndex, currentIndex - 1, currentElements.toArray(new CTCol[]{}), true, haveOverrideColumn);
}
currentElements.add(col);
if (col.getMax() > currentMax) currentMax = col.getMax();
if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn;
while (currentIndex <= nextIndex && !currentElements.isEmpty()) {
Set<CTCol> currentIndexElements = new HashSet<CTCol>();
long currentElemIndex;
{
// narrow scope of currentElem
CTCol currentElem = currentElements.first();
currentElemIndex = currentElem.getMax();
currentIndexElements.add(currentElem);
for (CTCol cc : currentElements.tailSet(currentElem)) {
if (cc == null || cc.getMax() == currentElemIndex) break;
currentIndexElements.add(cc);
if (col.getMax() > currentMax) currentMax = col.getMax();
if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn;
}
// JDK 6 code
// while (currentElements.higher(currentElem) != null && currentElements.higher(currentElem).getMax() == currentElemIndex) {
// currentElem = currentElements.higher(currentElem);
// currentIndexElements.add(currentElem);
// if (col.getMax() > currentMax) currentMax = col.getMax();
// if (col.equals(overrideColumn)) haveOverrideColumn = overrideColumn;
// }
}
if (currentElemIndex < nextIndex || !flIter.hasNext()) {
insertCol(cols, currentIndex, currentElemIndex, currentElements.toArray(new CTCol[]{}), true, haveOverrideColumn);
if (flIter.hasNext()) {
if (nextIndex > currentElemIndex) {
currentElements.removeAll(currentIndexElements);
if (currentIndexElements.contains(overrideColumn)) haveOverrideColumn = null;
}
} else {
currentElements.removeAll(currentIndexElements);
if (currentIndexElements.contains(overrideColumn)) haveOverrideColumn = null;
}
lastMaxIndex = currentIndex = currentElemIndex + 1;
} else {
lastMaxIndex = currentIndex;
currentIndex = nextIndex + 1;
}
}
}
sortColumns(cols);
}
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
public static void sortColumns(CTCols newCols) { public static void sortColumns(CTCols newCols) {
CTCol[] colArray = newCols.getColArray(); CTCol[] colArray = new CTCol[newCols.getColList().size()];
newCols.getColList().toArray(colArray);
Arrays.sort(colArray, new CTColComparator()); Arrays.sort(colArray, new CTColComparator());
newCols.setColArray(colArray); newCols.setColArray(colArray);
} }
@ -84,8 +189,9 @@ public class ColumnHelper {
* Returns the Column at the given 0 based index * Returns the Column at the given 0 based index
*/ */
public CTCol getColumn(long index, boolean splitColumns) { public CTCol getColumn(long index, boolean splitColumns) {
return getColumn1Based(index+1, splitColumns); return getColumn1Based(index+1, splitColumns);
} }
/** /**
* Returns the Column at the given 1 based index. * Returns the Column at the given 1 based index.
* POI default is 0 based, but the file stores * POI default is 0 based, but the file stores
@ -93,119 +199,61 @@ public class ColumnHelper {
*/ */
public CTCol getColumn1Based(long index1, boolean splitColumns) { public CTCol getColumn1Based(long index1, boolean splitColumns) {
CTCols colsArray = worksheet.getColsArray(0); CTCols colsArray = worksheet.getColsArray(0);
for (int i = 0; i < colsArray.sizeOfColArray(); i++) { for (int i = 0; i < colsArray.sizeOfColArray(); i++) {
CTCol colArray = colsArray.getColArray(i); CTCol colArray = colsArray.getColArray(i);
if (colArray.getMin() <= index1 && colArray.getMax() >= index1) { if (colArray.getMin() <= index1 && colArray.getMax() >= index1) {
if (splitColumns) { if (splitColumns) {
if (colArray.getMin() < index1) { if (colArray.getMin() < index1) {
insertCol(colsArray, colArray.getMin(), (index1 - 1), new CTCol[]{colArray}); insertCol(colsArray, colArray.getMin(), (index1 - 1), new CTCol[]{colArray});
} }
if (colArray.getMax() > index1) { if (colArray.getMax() > index1) {
insertCol(colsArray, (index1 + 1), colArray.getMax(), new CTCol[]{colArray}); insertCol(colsArray, (index1 + 1), colArray.getMax(), new CTCol[]{colArray});
} }
colArray.setMin(index1); colArray.setMin(index1);
colArray.setMax(index1); colArray.setMax(index1);
} }
return colArray; return colArray;
} }
} }
return null; return null;
} }
public CTCols addCleanColIntoCols(CTCols cols, CTCol col) { public CTCols addCleanColIntoCols(CTCols cols, CTCol col) {
boolean colOverlaps = false; CTCols newCols = CTCols.Factory.newInstance();
// a Map to remember overlapping columns for (CTCol c : cols.getColList()) {
Map<Long, Boolean> overlappingCols = new LinkedHashMap<Long, Boolean>(); cloneCol(newCols, c);
int sizeOfColArray = cols.sizeOfColArray();
for (int i = 0; i < sizeOfColArray; i++) {
CTCol ithCol = cols.getColArray(i);
long[] range1 = { ithCol.getMin(), ithCol.getMax() };
long[] range2 = { col.getMin(), col.getMax() };
long[] overlappingRange = NumericRanges.getOverlappingRange(range1,
range2);
int overlappingType = NumericRanges.getOverlappingType(range1,
range2);
// different behavior required for each of the 4 different
// overlapping types
if (overlappingType == NumericRanges.OVERLAPS_1_MINOR) {
// move the max border of the ithCol
// and insert a new column within the overlappingRange with merged column attributes
ithCol.setMax(overlappingRange[0] - 1);
insertCol(cols, overlappingRange[0],
overlappingRange[1], new CTCol[] { ithCol, col });
i++;
} else if (overlappingType == NumericRanges.OVERLAPS_2_MINOR) {
// move the min border of the ithCol
// and insert a new column within the overlappingRange with merged column attributes
ithCol.setMin(overlappingRange[1] + 1);
insertCol(cols, overlappingRange[0],
overlappingRange[1], new CTCol[] { ithCol, col });
i++;
} else if (overlappingType == NumericRanges.OVERLAPS_2_WRAPS) {
// merge column attributes, no new column is needed
setColumnAttributes(col, ithCol);
} else if (overlappingType == NumericRanges.OVERLAPS_1_WRAPS) {
// split the ithCol in three columns: before the overlappingRange, overlappingRange, and after the overlappingRange
// before overlappingRange
if (col.getMin() != ithCol.getMin()) {
insertCol(cols, ithCol.getMin(), (col
.getMin() - 1), new CTCol[] { ithCol });
i++;
}
// after the overlappingRange
if (col.getMax() != ithCol.getMax()) {
insertCol(cols, (col.getMax() + 1),
ithCol.getMax(), new CTCol[] { ithCol });
i++;
}
// within the overlappingRange
ithCol.setMin(overlappingRange[0]);
ithCol.setMax(overlappingRange[1]);
setColumnAttributes(col, ithCol);
}
if (overlappingType != NumericRanges.NO_OVERLAPS) {
colOverlaps = true;
// remember overlapped columns
for (long j = overlappingRange[0]; j <= overlappingRange[1]; j++) {
overlappingCols.put(Long.valueOf(j), Boolean.TRUE);
}
}
} }
if (!colOverlaps) { cloneCol(newCols, col);
cloneCol(cols, col); sortColumns(newCols);
} else { CTCol[] colArray = new CTCol[newCols.getColList().size()];
// insert new columns for ranges without overlaps newCols.getColList().toArray(colArray);
long colMin = -1; CTCols returnCols = CTCols.Factory.newInstance();
for (long j = col.getMin(); j <= col.getMax(); j++) { sweepCleanColumns(returnCols, colArray, col);
if (!Boolean.TRUE.equals(overlappingCols.get(Long.valueOf(j)))) { colArray = new CTCol[returnCols.getColList().size()];
if (colMin < 0) { returnCols.getColList().toArray(colArray);
colMin = j; cols.setColArray(colArray);
} return returnCols;
if ((j + 1) > col.getMax() || Boolean.TRUE.equals(overlappingCols.get(Long.valueOf(j + 1)))) {
insertCol(cols, colMin, j, new CTCol[] { col });
colMin = -1;
}
}
}
}
sortColumns(cols);
return cols;
} }
/* /*
* Insert a new CTCol at position 0 into cols, setting min=min, max=max and * Insert a new CTCol at position 0 into cols, setting min=min, max=max and
* copying all the colsWithAttributes array cols attributes into newCol * copying all the colsWithAttributes array cols attributes into newCol
*/ */
private CTCol insertCol(CTCols cols, long min, long max, CTCol[] colsWithAttributes) {
return insertCol(cols, min, max, colsWithAttributes, false, null);
}
private CTCol insertCol(CTCols cols, long min, long max, private CTCol insertCol(CTCols cols, long min, long max,
CTCol[] colsWithAttributes) { CTCol[] colsWithAttributes, boolean ignoreExistsCheck, CTCol overrideColumn) {
if(!columnExists(cols,min,max)){ if(ignoreExistsCheck || !columnExists(cols,min,max)){
CTCol newCol = cols.insertNewCol(0); CTCol newCol = cols.insertNewCol(0);
newCol.setMin(min); newCol.setMin(min);
newCol.setMax(max); newCol.setMax(max);
for (CTCol col : colsWithAttributes) { for (CTCol col : colsWithAttributes) {
setColumnAttributes(col, newCol); setColumnAttributes(col, newCol);
} }
return newCol; if (overrideColumn != null) setColumnAttributes(overrideColumn, newCol);
return newCol;
} }
return null; return null;
} }
@ -215,7 +263,7 @@ public class ColumnHelper {
* in the supplied list of column definitions? * in the supplied list of column definitions?
*/ */
public boolean columnExists(CTCols cols, long index) { public boolean columnExists(CTCols cols, long index) {
return columnExists1Based(cols, index+1); return columnExists1Based(cols, index+1);
} }
private boolean columnExists1Based(CTCols cols, long index1) { private boolean columnExists1Based(CTCols cols, long index1) {
for (int i = 0; i < cols.sizeOfColArray(); i++) { for (int i = 0; i < cols.sizeOfColArray(); i++) {
@ -227,7 +275,7 @@ public class ColumnHelper {
} }
public void setColumnAttributes(CTCol fromCol, CTCol toCol) { public void setColumnAttributes(CTCol fromCol, CTCol toCol) {
if(fromCol.isSetBestFit()) toCol.setBestFit(fromCol.getBestFit()); if(fromCol.isSetBestFit()) toCol.setBestFit(fromCol.getBestFit());
if(fromCol.isSetCustomWidth()) toCol.setCustomWidth(fromCol.getCustomWidth()); if(fromCol.isSetCustomWidth()) toCol.setCustomWidth(fromCol.getCustomWidth());
if(fromCol.isSetHidden()) toCol.setHidden(fromCol.getHidden()); if(fromCol.isSetHidden()) toCol.setHidden(fromCol.getHidden());
if(fromCol.isSetStyle()) toCol.setStyle(fromCol.getStyle()); if(fromCol.isSetStyle()) toCol.setStyle(fromCol.getStyle());
@ -271,38 +319,38 @@ public class ColumnHelper {
return col; return col;
} }
public void setColDefaultStyle(long index, CellStyle style) { public void setColDefaultStyle(long index, CellStyle style) {
setColDefaultStyle(index, style.getIndex()); setColDefaultStyle(index, style.getIndex());
} }
public void setColDefaultStyle(long index, int styleId) { public void setColDefaultStyle(long index, int styleId) {
CTCol col = getOrCreateColumn1Based(index+1, true); CTCol col = getOrCreateColumn1Based(index+1, true);
col.setStyle(styleId); col.setStyle(styleId);
} }
// Returns -1 if no column is found for the given index // Returns -1 if no column is found for the given index
public int getColDefaultStyle(long index) { public int getColDefaultStyle(long index) {
if (getColumn(index, false) != null) { if (getColumn(index, false) != null) {
return (int) getColumn(index, false).getStyle(); return (int) getColumn(index, false).getStyle();
} }
return -1; return -1;
} }
private boolean columnExists(CTCols cols, long min, long max) { private boolean columnExists(CTCols cols, long min, long max) {
for (int i = 0; i < cols.sizeOfColArray(); i++) { for (int i = 0; i < cols.sizeOfColArray(); i++) {
if (cols.getColArray(i).getMin() == min && cols.getColArray(i).getMax() == max) { if (cols.getColArray(i).getMin() == min && cols.getColArray(i).getMax() == max) {
return true; return true;
} }
} }
return false; return false;
} }
public int getIndexOfColumn(CTCols cols, CTCol col) { public int getIndexOfColumn(CTCols cols, CTCol col) {
for (int i = 0; i < cols.sizeOfColArray(); i++) { for (int i = 0; i < cols.sizeOfColArray(); i++) {
if (cols.getColArray(i).getMin() == col.getMin() && cols.getColArray(i).getMax() == col.getMax()) { if (cols.getColArray(i).getMin() == col.getMin() && cols.getColArray(i).getMax() == col.getMax()) {
return i; return i;
} }
} }
return -1; return -1;
} }
} }

View File

@ -19,11 +19,16 @@
package org.apache.poi.xssf.streaming; package org.apache.poi.xssf.streaming;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import org.apache.poi.ss.usermodel.BaseTestSheet; import org.apache.poi.ss.usermodel.BaseTestSheet;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.SXSSFITestDataProvider; import org.apache.poi.xssf.SXSSFITestDataProvider;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.After;
import org.junit.Test;
public class TestSXSSFSheet extends BaseTestSheet { public class TestSXSSFSheet extends BaseTestSheet {
@ -33,7 +38,7 @@ public class TestSXSSFSheet extends BaseTestSheet {
} }
@Override @After
public void tearDown(){ public void tearDown(){
SXSSFITestDataProvider.instance.cleanup(); SXSSFITestDataProvider.instance.cleanup();
} }
@ -43,35 +48,30 @@ public class TestSXSSFSheet extends BaseTestSheet {
* cloning of sheets is not supported in SXSSF * cloning of sheets is not supported in SXSSF
*/ */
@Override @Override
public void testCloneSheet() { @Test
try { public void cloneSheet() {
super.testCloneSheet(); thrown.expect(RuntimeException.class);
fail("expected exception"); thrown.expectMessage("NotImplemented");
} catch (RuntimeException e){ super.cloneSheet();
assertEquals("NotImplemented", e.getMessage());
}
} }
@Override @Override
public void testCloneSheetMultipleTimes() { @Test
try { public void cloneSheetMultipleTimes() {
super.testCloneSheetMultipleTimes(); thrown.expect(RuntimeException.class);
fail("expected exception"); thrown.expectMessage("NotImplemented");
} catch (RuntimeException e){ super.cloneSheetMultipleTimes();
assertEquals("NotImplemented", e.getMessage());
}
} }
/** /**
* shifting rows is not supported in SXSSF * shifting rows is not supported in SXSSF
*/ */
@Override @Override
public void testShiftMerged(){ @Test
try { public void shiftMerged(){
super.testShiftMerged(); thrown.expect(RuntimeException.class);
fail("expected exception"); thrown.expectMessage("NotImplemented");
} catch (RuntimeException e){ super.shiftMerged();
assertEquals("NotImplemented", e.getMessage());
}
} }
/** /**
@ -80,21 +80,21 @@ public class TestSXSSFSheet extends BaseTestSheet {
* The test is disabled because cloning of sheets is not supported in SXSSF * The test is disabled because cloning of sheets is not supported in SXSSF
*/ */
@Override @Override
public void test35084(){ @Test
try { public void bug35084(){
super.test35084(); thrown.expect(RuntimeException.class);
fail("expected exception"); thrown.expectMessage("NotImplemented");
} catch (RuntimeException e){ super.bug35084();
assertEquals("NotImplemented", e.getMessage());
}
} }
@Override @Override
public void testDefaultColumnStyle() { @Test
public void defaultColumnStyle() {
//TODO column styles are not yet supported by XSSF //TODO column styles are not yet supported by XSSF
} }
public void testOverrideFlushedRows() { @Test
public void overrideFlushedRows() {
Workbook wb = new SXSSFWorkbook(3); Workbook wb = new SXSSFWorkbook(3);
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -102,16 +102,14 @@ public class TestSXSSFSheet extends BaseTestSheet {
sheet.createRow(2); sheet.createRow(2);
sheet.createRow(3); sheet.createRow(3);
sheet.createRow(4); sheet.createRow(4);
try {
sheet.createRow(1);
fail("expected exception");
} catch (Throwable e){
assertEquals("Attempting to write a row[1] in the range [0,1] that is already written to disk.", e.getMessage());
}
thrown.expect(Throwable.class);
thrown.expectMessage("Attempting to write a row[1] in the range [0,1] that is already written to disk.");
sheet.createRow(1);
} }
public void testOverrideRowsInTemplate() { @Test
public void overrideRowsInTemplate() {
XSSFWorkbook template = new XSSFWorkbook(); XSSFWorkbook template = new XSSFWorkbook();
template.createSheet().createRow(1); template.createSheet().createRow(1);

View File

@ -17,6 +17,15 @@
package org.apache.poi.xssf.usermodel; package org.apache.poi.xssf.usermodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.List; import java.util.List;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
@ -39,10 +48,21 @@ import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.streaming.SXSSFSheet; import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook; import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.helpers.ColumnHelper; import org.apache.poi.xssf.usermodel.helpers.ColumnHelper;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.*; import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCol;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCols;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTComments;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetData;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetProtection;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPane;
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
public final class TestXSSFSheet extends BaseTestSheet { public final class TestXSSFSheet extends BaseTestSheet {
private static final int ROW_COUNT = 40000; private static final int ROW_COUNT = 40000;
@ -52,16 +72,18 @@ public final class TestXSSFSheet extends BaseTestSheet {
} }
//TODO column styles are not yet supported by XSSF //TODO column styles are not yet supported by XSSF
@Override @Test
public void testDefaultColumnStyle() { public void defaultColumnStyle() {
//super.testDefaultColumnStyle(); //super.defaultColumnStyle();
} }
public void testTestGetSetMargin() { @Test
public void getSetMargin() {
baseTestGetSetMargin(new double[]{0.7, 0.7, 0.75, 0.75, 0.3, 0.3}); baseTestGetSetMargin(new double[]{0.7, 0.7, 0.75, 0.75, 0.3, 0.3});
} }
public void testExistingHeaderFooter() { @Test
public void existingHeaderFooter() {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("45540_classic_Header.xlsx"); XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("45540_classic_Header.xlsx");
XSSFOddHeader hdr; XSSFOddHeader hdr;
XSSFOddFooter ftr; XSSFOddFooter ftr;
@ -117,7 +139,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals("", ftr.getRight()); assertEquals("", ftr.getRight());
} }
public void testGetAllHeadersFooters() { @Test
public void getAllHeadersFooters() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sheet 1"); XSSFSheet sheet = workbook.createSheet("Sheet 1");
assertNotNull(sheet.getOddFooter()); assertNotNull(sheet.getOddFooter());
@ -156,7 +179,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals("odd header center", sheet.getHeader().getCenter()); assertEquals("odd header center", sheet.getHeader().getCenter());
} }
public void testAutoSizeColumn() { @Test
public void autoSizeColumn() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sheet 1"); XSSFSheet sheet = workbook.createSheet("Sheet 1");
sheet.createRow(0).createCell(13).setCellValue("test"); sheet.createRow(0).createCell(13).setCellValue("test");
@ -171,7 +195,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
/** /**
* XSSFSheet autoSizeColumn() on empty RichTextString fails * XSSFSheet autoSizeColumn() on empty RichTextString fails
*/ */
public void test48325() { @Test
public void bug48325() {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Test"); XSSFSheet sheet = wb.createSheet("Test");
CreationHelper factory = wb.getCreationHelper(); CreationHelper factory = wb.getCreationHelper();
@ -187,7 +212,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
sheet.autoSizeColumn(0); sheet.autoSizeColumn(0);
} }
public void testGetCellComment() { @Test
public void getCellComment() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
XSSFDrawing dg = sheet.createDrawingPatriarch(); XSSFDrawing dg = sheet.createDrawingPatriarch();
@ -200,7 +226,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals("test C10 author", sheet.getCellComment(9, 2).getAuthor()); assertEquals("test C10 author", sheet.getCellComment(9, 2).getAuthor());
} }
public void testSetCellComment() { @Test
public void setCellComment() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
@ -217,7 +244,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals("test A1 author", comments.getAuthor((int) ctComments.getCommentList().getCommentArray(0).getAuthorId())); assertEquals("test A1 author", comments.getAuthor((int) ctComments.getCommentList().getCommentArray(0).getAuthorId()));
} }
public void testGetActiveCell() { @Test
public void getActiveCell() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
sheet.setActiveCell("R5"); sheet.setActiveCell("R5");
@ -226,7 +254,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
} }
public void testCreateFreezePane_XSSF() { @Test
public void createFreezePane_XSSF() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
CTWorksheet ctWorksheet = sheet.getCTWorksheet(); CTWorksheet ctWorksheet = sheet.getCTWorksheet();
@ -243,7 +272,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane()); assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
} }
public void testNewMergedRegionAt() { @Test
public void newMergedRegionAt() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
CellRangeAddress region = CellRangeAddress.valueOf("B2:D4"); CellRangeAddress region = CellRangeAddress.valueOf("B2:D4");
@ -252,7 +282,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(1, sheet.getNumMergedRegions()); assertEquals(1, sheet.getNumMergedRegions());
} }
public void testRemoveMergedRegion_lowlevel() { @Test
public void removeMergedRegion_lowlevel() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
CTWorksheet ctWorksheet = sheet.getCTWorksheet(); CTWorksheet ctWorksheet = sheet.getCTWorksheet();
@ -274,7 +305,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
"region on the sheet.", sheet.getCTWorksheet().getMergeCells()); "region on the sheet.", sheet.getCTWorksheet().getMergeCells());
} }
public void testSetDefaultColumnStyle() { @Test
public void setDefaultColumnStyle() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
CTWorksheet ctWorksheet = sheet.getCTWorksheet(); CTWorksheet ctWorksheet = sheet.getCTWorksheet();
@ -299,7 +331,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
} }
public void testGroupUngroupColumn() { @Test
public void groupUngroupColumn() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
@ -308,41 +341,41 @@ public final class TestXSSFSheet extends BaseTestSheet {
sheet.groupColumn(10, 11); sheet.groupColumn(10, 11);
CTCols cols = sheet.getCTWorksheet().getColsArray(0); CTCols cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(2, cols.sizeOfColArray()); assertEquals(2, cols.sizeOfColArray());
CTCol[] colArray = cols.getColArray(); List<CTCol> colArray = cols.getColList();
assertNotNull(colArray); assertNotNull(colArray);
assertEquals(2 + 1, colArray[0].getMin()); // 1 based assertEquals(2 + 1, colArray.get(0).getMin()); // 1 based
assertEquals(7 + 1, colArray[0].getMax()); // 1 based assertEquals(7 + 1, colArray.get(0).getMax()); // 1 based
assertEquals(1, colArray[0].getOutlineLevel()); assertEquals(1, colArray.get(0).getOutlineLevel());
//two level //two level
sheet.groupColumn(1, 2); sheet.groupColumn(1, 2);
cols = sheet.getCTWorksheet().getColsArray(0); cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(4, cols.sizeOfColArray()); assertEquals(4, cols.sizeOfColArray());
colArray = cols.getColArray(); colArray = cols.getColList();
assertEquals(2, colArray[1].getOutlineLevel()); assertEquals(2, colArray.get(1).getOutlineLevel());
//three level //three level
sheet.groupColumn(6, 8); sheet.groupColumn(6, 8);
sheet.groupColumn(2, 3); sheet.groupColumn(2, 3);
cols = sheet.getCTWorksheet().getColsArray(0); cols = sheet.getCTWorksheet().getColsArray(0);
assertEquals(7, cols.sizeOfColArray()); assertEquals(7, cols.sizeOfColArray());
colArray = cols.getColArray(); colArray = cols.getColList();
assertEquals(3, colArray[1].getOutlineLevel()); assertEquals(3, colArray.get(1).getOutlineLevel());
assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol()); assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
sheet.ungroupColumn(8, 10); sheet.ungroupColumn(8, 10);
colArray = cols.getColArray(); colArray = cols.getColList();
//assertEquals(3, colArray[1].getOutlineLevel()); //assertEquals(3, colArray[1].getOutlineLevel());
sheet.ungroupColumn(4, 6); sheet.ungroupColumn(4, 6);
sheet.ungroupColumn(2, 2); sheet.ungroupColumn(2, 2);
colArray = cols.getColArray(); colArray = cols.getColList();
assertEquals(4, colArray.length); assertEquals(4, colArray.size());
assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol()); assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
} }
@Test
public void testGroupUngroupRow() { public void groupUngroupRow() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
@ -376,7 +409,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(1, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow()); assertEquals(1, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow());
} }
public void testSetZoom() { @Test
public void setZoom() {
XSSFWorkbook workBook = new XSSFWorkbook(); XSSFWorkbook workBook = new XSSFWorkbook();
XSSFSheet sheet1 = workBook.createSheet("new sheet"); XSSFSheet sheet1 = workBook.createSheet("new sheet");
sheet1.setZoom(3, 4); // 75 percent magnification sheet1.setZoom(3, 4); // 75 percent magnification
@ -401,7 +435,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
* be doing... Someone who understands the goals a little * be doing... Someone who understands the goals a little
* better should really review this! * better should really review this!
*/ */
public void testSetColumnGroupCollapsed(){ @Test
public void setColumnGroupCollapsed(){
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
XSSFSheet sheet1 =(XSSFSheet) wb.createSheet(); XSSFSheet sheet1 =(XSSFSheet) wb.createSheet();
@ -501,7 +536,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(true,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(true, cols.getColArray(2).isSetHidden()); assertEquals(true, cols.getColArray(2).isSetHidden());
@ -536,7 +571,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(true,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
@ -565,7 +600,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(true,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
@ -604,7 +639,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(5, cols.getColArray(0).getMin()); // 1 based assertEquals(5, cols.getColArray(0).getMin()); // 1 based
assertEquals(8, cols.getColArray(0).getMax()); // 1 based assertEquals(8, cols.getColArray(0).getMax()); // 1 based
assertEquals(false,cols.getColArray(1).isSetHidden()); assertEquals(false,cols.getColArray(1).isSetHidden());
assertEquals(false,cols.getColArray(1).isSetCollapsed()); assertEquals(true,cols.getColArray(1).isSetCollapsed());
assertEquals(9, cols.getColArray(1).getMin()); // 1 based assertEquals(9, cols.getColArray(1).getMin()); // 1 based
assertEquals(9, cols.getColArray(1).getMax()); // 1 based assertEquals(9, cols.getColArray(1).getMax()); // 1 based
assertEquals(false,cols.getColArray(2).isSetHidden()); assertEquals(false,cols.getColArray(2).isSetHidden());
@ -631,7 +666,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
* be doing... Someone who understands the goals a little * be doing... Someone who understands the goals a little
* better should really review this! * better should really review this!
*/ */
public void testSetRowGroupCollapsed(){ @Test
public void setRowGroupCollapsed(){
Workbook wb = new XSSFWorkbook(); Workbook wb = new XSSFWorkbook();
XSSFSheet sheet1 = (XSSFSheet)wb.createSheet(); XSSFSheet sheet1 = (XSSFSheet)wb.createSheet();
@ -707,7 +743,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
/** /**
* Get / Set column width and check the actual values of the underlying XML beans * Get / Set column width and check the actual values of the underlying XML beans
*/ */
public void testColumnWidth_lowlevel() { @Test
public void columnWidth_lowlevel() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sheet 1"); XSSFSheet sheet = workbook.createSheet("Sheet 1");
sheet.setColumnWidth(1, 22 * 256); sheet.setColumnWidth(1, 22 * 256);
@ -718,9 +755,9 @@ public final class TestXSSFSheet extends BaseTestSheet {
XSSFSheet xs = sheet; XSSFSheet xs = sheet;
CTWorksheet cts = xs.getCTWorksheet(); CTWorksheet cts = xs.getCTWorksheet();
CTCols[] cols_s = cts.getColsArray(); List<CTCols> cols_s = cts.getColsList();
assertEquals(1, cols_s.length); assertEquals(1, cols_s.size());
CTCols cols = cols_s[0]; CTCols cols = cols_s.get(0);
assertEquals(1, cols.sizeOfColArray()); assertEquals(1, cols.sizeOfColArray());
CTCol col = cols.getColArray(0); CTCol col = cols.getColArray(0);
@ -733,9 +770,9 @@ public final class TestXSSFSheet extends BaseTestSheet {
// Now set another // Now set another
sheet.setColumnWidth(3, 33 * 256); sheet.setColumnWidth(3, 33 * 256);
cols_s = cts.getColsArray(); cols_s = cts.getColsList();
assertEquals(1, cols_s.length); assertEquals(1, cols_s.size());
cols = cols_s[0]; cols = cols_s.get(0);
assertEquals(2, cols.sizeOfColArray()); assertEquals(2, cols.sizeOfColArray());
col = cols.getColArray(0); col = cols.getColArray(0);
@ -754,7 +791,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
/** /**
* Setting width of a column included in a column span * Setting width of a column included in a column span
*/ */
public void test47862() { @Test
public void bug47862() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47862.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47862.xlsx");
XSSFSheet sheet = wb.getSheetAt(0); XSSFSheet sheet = wb.getSheetAt(0);
CTCols cols = sheet.getCTWorksheet().getColsArray(0); CTCols cols = sheet.getCTWorksheet().getColsArray(0);
@ -810,7 +848,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
/** /**
* Hiding a column included in a column span * Hiding a column included in a column span
*/ */
public void test47804() { @Test
public void bug47804() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47804.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47804.xlsx");
XSSFSheet sheet = wb.getSheetAt(0); XSSFSheet sheet = wb.getSheetAt(0);
CTCols cols = sheet.getCTWorksheet().getColsArray(0); CTCols cols = sheet.getCTWorksheet().getColsArray(0);
@ -877,7 +916,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertFalse(sheet.isColumnHidden(5)); assertFalse(sheet.isColumnHidden(5));
} }
public void testCommentsTable() { @Test
public void commentsTable() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet1 = workbook.createSheet(); XSSFSheet sheet1 = workbook.createSheet();
CommentsTable comment1 = sheet1.getCommentsTable(false); CommentsTable comment1 = sheet1.getCommentsTable(false);
@ -916,7 +956,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
* Rows and cells can be created in random order, * Rows and cells can be created in random order,
* but CTRows are kept in ascending order * but CTRows are kept in ascending order
*/ */
public void testCreateRowA() { @Test
public void createRow() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
CTWorksheet wsh = sheet.getCTWorksheet(); CTWorksheet wsh = sheet.getCTWorksheet();
@ -939,27 +980,27 @@ public final class TestXSSFSheet extends BaseTestSheet {
row3.createCell(5); row3.createCell(5);
CTRow[] xrow = sheetData.getRowArray(); List<CTRow> xrow = sheetData.getRowList();
assertEquals(3, xrow.length); assertEquals(3, xrow.size());
//rows are sorted: {0, 1, 2} //rows are sorted: {0, 1, 2}
assertEquals(4, xrow[0].sizeOfCArray()); assertEquals(4, xrow.get(0).sizeOfCArray());
assertEquals(1, xrow[0].getR()); assertEquals(1, xrow.get(0).getR());
assertTrue(xrow[0].equals(row3.getCTRow())); assertTrue(xrow.get(0).equals(row3.getCTRow()));
assertEquals(3, xrow[1].sizeOfCArray()); assertEquals(3, xrow.get(1).sizeOfCArray());
assertEquals(2, xrow[1].getR()); assertEquals(2, xrow.get(1).getR());
assertTrue(xrow[1].equals(row2.getCTRow())); assertTrue(xrow.get(1).equals(row2.getCTRow()));
assertEquals(2, xrow[2].sizeOfCArray()); assertEquals(2, xrow.get(2).sizeOfCArray());
assertEquals(3, xrow[2].getR()); assertEquals(3, xrow.get(2).getR());
assertTrue(xrow[2].equals(row1.getCTRow())); assertTrue(xrow.get(2).equals(row1.getCTRow()));
CTCell[] xcell = xrow[0].getCArray(); List<CTCell> xcell = xrow.get(0).getCList();
assertEquals("D1", xcell[0].getR()); assertEquals("D1", xcell.get(0).getR());
assertEquals("A1", xcell[1].getR()); assertEquals("A1", xcell.get(1).getR());
assertEquals("C1", xcell[2].getR()); assertEquals("C1", xcell.get(2).getR());
assertEquals("F1", xcell[3].getR()); assertEquals("F1", xcell.get(3).getR());
//re-creating a row does NOT add extra data to the parent //re-creating a row does NOT add extra data to the parent
row2 = sheet.createRow(1); row2 = sheet.createRow(1);
@ -971,29 +1012,30 @@ public final class TestXSSFSheet extends BaseTestSheet {
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook); workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
sheet = workbook.getSheetAt(0); sheet = workbook.getSheetAt(0);
wsh = sheet.getCTWorksheet(); wsh = sheet.getCTWorksheet();
xrow = sheetData.getRowArray(); xrow = sheetData.getRowList();
assertEquals(3, xrow.length); assertEquals(3, xrow.size());
//rows are sorted: {0, 1, 2} //rows are sorted: {0, 1, 2}
assertEquals(4, xrow[0].sizeOfCArray()); assertEquals(4, xrow.get(0).sizeOfCArray());
assertEquals(1, xrow[0].getR()); assertEquals(1, xrow.get(0).getR());
//cells are now sorted //cells are now sorted
xcell = xrow[0].getCArray(); xcell = xrow.get(0).getCList();
assertEquals("A1", xcell[0].getR()); assertEquals("A1", xcell.get(0).getR());
assertEquals("C1", xcell[1].getR()); assertEquals("C1", xcell.get(1).getR());
assertEquals("D1", xcell[2].getR()); assertEquals("D1", xcell.get(2).getR());
assertEquals("F1", xcell[3].getR()); assertEquals("F1", xcell.get(3).getR());
assertEquals(0, xrow[1].sizeOfCArray()); assertEquals(0, xrow.get(1).sizeOfCArray());
assertEquals(2, xrow[1].getR()); assertEquals(2, xrow.get(1).getR());
assertEquals(2, xrow[2].sizeOfCArray()); assertEquals(2, xrow.get(2).sizeOfCArray());
assertEquals(3, xrow[2].getR()); assertEquals(3, xrow.get(2).getR());
} }
public void testSetAutoFilter() { @Test
public void setAutoFilter() {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("new sheet"); XSSFSheet sheet = wb.createSheet("new sheet");
sheet.setAutoFilter(CellRangeAddress.valueOf("A1:D100")); sheet.setAutoFilter(CellRangeAddress.valueOf("A1:D100"));
@ -1010,10 +1052,10 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals("'new sheet'!$A$1:$D$100", nm.getCTName().getStringValue()); assertEquals("'new sheet'!$A$1:$D$100", nm.getCTName().getStringValue());
} }
public void testProtectSheet_lowlevel() { @Test
public void protectSheet_lowlevel() {
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet(); XSSFSheet sheet = wb.createSheet();
CTSheetProtection pr = sheet.getCTWorksheet().getSheetProtection(); CTSheetProtection pr = sheet.getCTWorksheet().getSheetProtection();
assertNull("CTSheetProtection should be null by default", pr); assertNull("CTSheetProtection should be null by default", pr);
String password = "Test"; String password = "Test";
@ -1031,7 +1073,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
} }
public void test49966() { @Test
public void bug49966() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49966.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49966.xlsx");
CalculationChain calcChain = wb.getCalculationChain(); CalculationChain calcChain = wb.getCalculationChain();
assertNotNull(wb.getCalculationChain()); assertNotNull(wb.getCalculationChain());
@ -1053,14 +1096,15 @@ public final class TestXSSFSheet extends BaseTestSheet {
/** /**
* See bug #50829 * See bug #50829
*/ */
public void testTables() { @Test
public void tables() {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithTable.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithTable.xlsx");
assertEquals(3, wb.getNumberOfSheets()); assertEquals(3, wb.getNumberOfSheets());
// Check the table sheet // Check the table sheet
XSSFSheet s1 = wb.getSheetAt(0); XSSFSheet s1 = wb.getSheetAt(0);
assertEquals("a", s1.getRow(0).getCell(0).getRichStringCellValue().toString()); assertEquals("a", s1.getRow(0).getCell(0).getRichStringCellValue().toString());
assertEquals(1.0, s1.getRow(1).getCell(0).getNumericCellValue()); assertEquals(1.0, s1.getRow(1).getCell(0).getNumericCellValue(), 0);
List<XSSFTable> tables = s1.getTables(); List<XSSFTable> tables = s1.getTables();
assertNotNull(tables); assertNotNull(tables);
@ -1080,7 +1124,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
/** /**
* Test to trigger OOXML-LITE generating to include org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr * Test to trigger OOXML-LITE generating to include org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetCalcPr
*/ */
public void testSetForceFormulaRecalculation() { @Test
public void setForceFormulaRecalculation() {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sheet 1"); XSSFSheet sheet = workbook.createSheet("Sheet 1");
@ -1103,104 +1148,107 @@ public final class TestXSSFSheet extends BaseTestSheet {
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook); workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
sheet = workbook.getSheet("Sheet 1"); sheet = workbook.getSheet("Sheet 1");
assertEquals(false, sheet.getForceFormulaRecalculation()); assertEquals(false, sheet.getForceFormulaRecalculation());
}
public void test54607() {
// run with the file provided in the Bug-Report
runGetTopRow("54607.xlsx", true, 1, 0, 0);
runGetLeftCol("54607.xlsx", true, 0, 0, 0);
// run with some other flie to see
runGetTopRow("54436.xlsx", true, 0);
runGetLeftCol("54436.xlsx", true, 0);
runGetTopRow("TwoSheetsNoneHidden.xlsx", true, 0, 0);
runGetLeftCol("TwoSheetsNoneHidden.xlsx", true, 0, 0);
runGetTopRow("TwoSheetsNoneHidden.xls", false, 0, 0);
runGetLeftCol("TwoSheetsNoneHidden.xls", false, 0, 0);
} }
private void runGetTopRow(String file, boolean isXSSF, int... topRows) { @Test
final Workbook wb; public void bug54607() {
if(isXSSF) { // run with the file provided in the Bug-Report
wb = XSSFTestDataSamples.openSampleWorkbook(file); runGetTopRow("54607.xlsx", true, 1, 0, 0);
} else { runGetLeftCol("54607.xlsx", true, 0, 0, 0);
wb = HSSFTestDataSamples.openSampleWorkbook(file);
}
for (int si = 0; si < wb.getNumberOfSheets(); si++) {
Sheet sh = wb.getSheetAt(si);
assertNotNull(sh.getSheetName());
assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow());
}
// for XSSF also test with SXSSF // run with some other flie to see
if(isXSSF) { runGetTopRow("54436.xlsx", true, 0);
Workbook swb = new SXSSFWorkbook((XSSFWorkbook) wb); runGetLeftCol("54436.xlsx", true, 0);
for (int si = 0; si < swb.getNumberOfSheets(); si++) { runGetTopRow("TwoSheetsNoneHidden.xlsx", true, 0, 0);
Sheet sh = swb.getSheetAt(si); runGetLeftCol("TwoSheetsNoneHidden.xlsx", true, 0, 0);
assertNotNull(sh.getSheetName()); runGetTopRow("TwoSheetsNoneHidden.xls", false, 0, 0);
assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow()); runGetLeftCol("TwoSheetsNoneHidden.xls", false, 0, 0);
} }
}
}
private void runGetLeftCol(String file, boolean isXSSF, int... topRows) { private void runGetTopRow(String file, boolean isXSSF, int... topRows) {
final Workbook wb; final Workbook wb;
if(isXSSF) { if(isXSSF) {
wb = XSSFTestDataSamples.openSampleWorkbook(file); wb = XSSFTestDataSamples.openSampleWorkbook(file);
} else { } else {
wb = HSSFTestDataSamples.openSampleWorkbook(file); wb = HSSFTestDataSamples.openSampleWorkbook(file);
} }
for (int si = 0; si < wb.getNumberOfSheets(); si++) { for (int si = 0; si < wb.getNumberOfSheets(); si++) {
Sheet sh = wb.getSheetAt(si); Sheet sh = wb.getSheetAt(si);
assertNotNull(sh.getSheetName()); assertNotNull(sh.getSheetName());
assertEquals("Did not match for sheet " + si, topRows[si], sh.getLeftCol()); assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow());
} }
// for XSSF also test with SXSSF // for XSSF also test with SXSSF
if(isXSSF) { if(isXSSF) {
Workbook swb = new SXSSFWorkbook((XSSFWorkbook) wb); Workbook swb = new SXSSFWorkbook((XSSFWorkbook) wb);
for (int si = 0; si < swb.getNumberOfSheets(); si++) { for (int si = 0; si < swb.getNumberOfSheets(); si++) {
Sheet sh = swb.getSheetAt(si); Sheet sh = swb.getSheetAt(si);
assertNotNull(sh.getSheetName()); assertNotNull(sh.getSheetName());
assertEquals("Did not match for sheet " + si, topRows[si], sh.getLeftCol()); assertEquals("Did not match for sheet " + si, topRows[si], sh.getTopRow());
} }
} }
} }
public void testShowInPaneManyRowsBug55248() { private void runGetLeftCol(String file, boolean isXSSF, int... topRows) {
XSSFWorkbook workbook = new XSSFWorkbook(); final Workbook wb;
XSSFSheet sheet = workbook.createSheet("Sheet 1"); if(isXSSF) {
wb = XSSFTestDataSamples.openSampleWorkbook(file);
} else {
wb = HSSFTestDataSamples.openSampleWorkbook(file);
}
for (int si = 0; si < wb.getNumberOfSheets(); si++) {
Sheet sh = wb.getSheetAt(si);
assertNotNull(sh.getSheetName());
assertEquals("Did not match for sheet " + si, topRows[si], sh.getLeftCol());
}
// for XSSF also test with SXSSF
if(isXSSF) {
Workbook swb = new SXSSFWorkbook((XSSFWorkbook) wb);
for (int si = 0; si < swb.getNumberOfSheets(); si++) {
Sheet sh = swb.getSheetAt(si);
assertNotNull(sh.getSheetName());
assertEquals("Did not match for sheet " + si, topRows[si], sh.getLeftCol());
}
}
}
@Test
public void showInPaneManyRowsBug55248() {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Sheet 1");
sheet.showInPane(0, 0);
sheet.showInPane(0, 0);
for(int i = ROW_COUNT/2;i < ROW_COUNT;i++) { for(int i = ROW_COUNT/2;i < ROW_COUNT;i++) {
sheet.createRow(i); sheet.createRow(i);
sheet.showInPane(i, 0); sheet.showInPane(i, 0);
// this one fails: sheet.showInPane((short)i, 0); // this one fails: sheet.showInPane((short)i, 0);
} }
short i = 0; int i = 0;
sheet.showInPane(i, i); sheet.showInPane(i, i);
XSSFWorkbook wb = XSSFTestDataSamples.writeOutAndReadBack(workbook); XSSFWorkbook wb = XSSFTestDataSamples.writeOutAndReadBack(workbook);
checkRowCount(wb); checkRowCount(wb);
} }
public void testShowInPaneManyRowsBug55248SXSSF() { @Test
public void showInPaneManyRowsBug55248SXSSF() {
SXSSFWorkbook workbook = new SXSSFWorkbook(new XSSFWorkbook()); SXSSFWorkbook workbook = new SXSSFWorkbook(new XSSFWorkbook());
SXSSFSheet sheet = (SXSSFSheet) workbook.createSheet("Sheet 1"); SXSSFSheet sheet = (SXSSFSheet) workbook.createSheet("Sheet 1");
sheet.showInPane(0, 0); sheet.showInPane(0, 0);
for(int i = ROW_COUNT/2;i < ROW_COUNT;i++) { for(int i = ROW_COUNT/2;i < ROW_COUNT;i++) {
sheet.createRow(i); sheet.createRow(i);
sheet.showInPane(i, 0); sheet.showInPane(i, 0);
// this one fails: sheet.showInPane((short)i, 0); // this one fails: sheet.showInPane((short)i, 0);
} }
short i = 0; int i = 0;
sheet.showInPane(i, i); sheet.showInPane(i, i);
Workbook wb = SXSSFITestDataProvider.instance.writeOutAndReadBack(workbook); Workbook wb = SXSSFITestDataProvider.instance.writeOutAndReadBack(workbook);
checkRowCount(wb); checkRowCount(wb);
} }
@ -1212,12 +1260,13 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertEquals(ROW_COUNT-1, sh.getLastRowNum()); assertEquals(ROW_COUNT-1, sh.getLastRowNum());
} }
public static void test55745() throws Exception { @Test
public void bug55745() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("55745.xlsx"); XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("55745.xlsx");
XSSFSheet sheet = wb.getSheetAt(0); XSSFSheet sheet = wb.getSheetAt(0);
List<XSSFTable> tables = sheet.getTables(); List<XSSFTable> tables = sheet.getTables();
/*System.out.println(tables.size()); /*System.out.println(tables.size());
for(XSSFTable table : tables) { for(XSSFTable table : tables) {
System.out.println("XPath: " + table.getCommonXpath()); System.out.println("XPath: " + table.getCommonXpath());
System.out.println("Name: " + table.getName()); System.out.println("Name: " + table.getName());
@ -1230,7 +1279,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
assertNotNull("Sheet should contain a comments table", sheet.getCommentsTable(false)); assertNotNull("Sheet should contain a comments table", sheet.getCommentsTable(false));
} }
public void testBug55723b(){ @Test
public void bug55723b(){
XSSFWorkbook wb = new XSSFWorkbook(); XSSFWorkbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -1240,19 +1290,25 @@ public final class TestXSSFSheet extends BaseTestSheet {
CellRangeAddress range = CellRangeAddress.valueOf("A:B"); CellRangeAddress range = CellRangeAddress.valueOf("A:B");
AutoFilter filter = sheet.setAutoFilter(range); AutoFilter filter = sheet.setAutoFilter(range);
assertNotNull(filter); assertNotNull(filter);
// stored with a special name // stored with a special name
XSSFName name = wb.getBuiltInName(XSSFName.BUILTIN_FILTER_DB, 0); XSSFName name = wb.getBuiltInName(XSSFName.BUILTIN_FILTER_DB, 0);
assertNotNull(name); assertNotNull(name);
assertEquals("Sheet0!$A:$B", name.getRefersToFormula()); assertEquals("Sheet0!$A:$B", name.getRefersToFormula());
range = CellRangeAddress.valueOf("B:C"); range = CellRangeAddress.valueOf("B:C");
filter = sheet.setAutoFilter(range); filter = sheet.setAutoFilter(range);
assertNotNull(filter); assertNotNull(filter);
// stored with a special name // stored with a special name
name = wb.getBuiltInName(XSSFName.BUILTIN_FILTER_DB, 0); name = wb.getBuiltInName(XSSFName.BUILTIN_FILTER_DB, 0);
assertNotNull(name); assertNotNull(name);
assertEquals("Sheet0!$B:$C", name.getRefersToFormula()); assertEquals("Sheet0!$B:$C", name.getRefersToFormula());
} }
}
@Test(timeout=180000)
public void bug51585(){
XSSFTestDataSamples.openSampleWorkbook("51585.xlsx");
}
}

View File

@ -1,8 +1,34 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.xssf.usermodel.charts; package org.apache.poi.xssf.usermodel.charts;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.usermodel.charts.*; import org.apache.poi.ss.usermodel.Chart;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.Drawing;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.charts.AxisPosition;
import org.apache.poi.ss.usermodel.charts.ChartAxis;
import org.apache.poi.ss.usermodel.charts.ChartDataSource;
import org.apache.poi.ss.usermodel.charts.DataSources;
import org.apache.poi.ss.usermodel.charts.LineChartData;
import org.apache.poi.ss.usermodel.charts.LineChartSerie;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.SheetBuilder; import org.apache.poi.ss.util.SheetBuilder;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.xwpf; package org.apache.poi.xwpf;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hmef; package org.apache.poi.hmef;
import junit.framework.TestCase; import junit.framework.TestCase;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import java.io.File; import java.io.File;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import java.io.File; import java.io.File;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import java.io.File; import java.io.File;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import java.io.File; import java.io.File;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.hssf.dev; package org.apache.poi.hssf.dev;
import java.io.File; import java.io.File;

View File

@ -17,20 +17,44 @@
package org.apache.poi.hssf.usermodel; package org.apache.poi.hssf.usermodel;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.util.List; import java.util.List;
import junit.framework.AssertionFailedError;
import org.apache.poi.ddf.EscherDgRecord; import org.apache.poi.ddf.EscherDgRecord;
import org.apache.poi.hssf.HSSFITestDataProvider; import org.apache.poi.hssf.HSSFITestDataProvider;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.model.DrawingManager2; import org.apache.poi.hssf.model.DrawingManager2;
import org.apache.poi.hssf.model.InternalSheet; import org.apache.poi.hssf.model.InternalSheet;
import org.apache.poi.hssf.model.InternalWorkbook; import org.apache.poi.hssf.model.InternalWorkbook;
import org.apache.poi.hssf.record.*; import org.apache.poi.hssf.record.AutoFilterInfoRecord;
import org.apache.poi.hssf.record.CommonObjectDataSubRecord;
import org.apache.poi.hssf.record.DimensionsRecord;
import org.apache.poi.hssf.record.FtCblsSubRecord;
import org.apache.poi.hssf.record.GridsetRecord;
import org.apache.poi.hssf.record.HCenterRecord;
import org.apache.poi.hssf.record.LbsDataSubRecord;
import org.apache.poi.hssf.record.NameRecord;
import org.apache.poi.hssf.record.ObjRecord;
import org.apache.poi.hssf.record.ObjectProtectRecord;
import org.apache.poi.hssf.record.PasswordRecord;
import org.apache.poi.hssf.record.ProtectRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.SCLRecord;
import org.apache.poi.hssf.record.ScenarioProtectRecord;
import org.apache.poi.hssf.record.SubRecord;
import org.apache.poi.hssf.record.VCenterRecord;
import org.apache.poi.hssf.record.WSBoolRecord;
import org.apache.poi.hssf.record.WindowTwoRecord;
import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock; import org.apache.poi.hssf.record.aggregates.WorksheetProtectionBlock;
import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector; import org.apache.poi.hssf.usermodel.RecordInspector.RecordCollector;
import org.apache.poi.ss.formula.ptg.Area3DPtg; import org.apache.poi.ss.formula.ptg.Area3DPtg;
@ -46,6 +70,7 @@ import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellRangeAddressList; import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.util.TempFile; import org.apache.poi.util.TempFile;
import org.junit.Test;
/** /**
* Tests HSSFSheet. This test case is very incomplete at the moment. * Tests HSSFSheet. This test case is very incomplete at the moment.
@ -65,7 +90,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
* Test for Bugzilla #29747. * Test for Bugzilla #29747.
* Moved from TestHSSFWorkbook#testSetRepeatingRowsAndColumns(). * Moved from TestHSSFWorkbook#testSetRepeatingRowsAndColumns().
*/ */
public void testSetRepeatingRowsAndColumnsBug29747() { @Test
public void setRepeatingRowsAndColumnsBug29747() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
wb.createSheet(); wb.createSheet();
wb.createSheet(); wb.createSheet();
@ -76,14 +102,16 @@ public final class TestHSSFSheet extends BaseTestSheet {
} }
public void testTestGetSetMargin() { @Test
public void getSetMargin() {
baseTestGetSetMargin(new double[]{0.75, 0.75, 1.0, 1.0, 0.3, 0.3}); baseTestGetSetMargin(new double[]{0.75, 0.75, 1.0, 1.0, 0.3, 0.3});
} }
/** /**
* Test the gridset field gets set as expected. * Test the gridset field gets set as expected.
*/ */
public void testBackupRecord() { @Test
public void backupRecord() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
GridsetRecord gridsetRec = s.getSheet().getGridsetRecord(); GridsetRecord gridsetRec = s.getSheet().getGridsetRecord();
@ -96,7 +124,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
* Test vertically centered output. * Test vertically centered output.
*/ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void testVerticallyCenter() { @Test
public void verticallyCenter() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
VCenterRecord record = s.getSheet().getPageSettings().getVCenter(); VCenterRecord record = s.getSheet().getPageSettings().getVCenter();
@ -115,7 +144,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Test horizontally centered output. * Test horizontally centered output.
*/ */
public void testHorizontallyCenter() { @Test
public void horizontallyCenter() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
HCenterRecord record = s.getSheet().getPageSettings().getHCenter(); HCenterRecord record = s.getSheet().getPageSettings().getHCenter();
@ -129,7 +159,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Test WSBboolRecord fields get set in the user model. * Test WSBboolRecord fields get set in the user model.
*/ */
public void testWSBool() { @Test
public void wsBool() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
WSBoolRecord record = WSBoolRecord record =
@ -177,7 +208,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Setting landscape and portrait stuff on existing sheets * Setting landscape and portrait stuff on existing sheets
*/ */
public void testPrintSetupLandscapeExisting() { @Test
public void printSetupLandscapeExisting() {
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls"); HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls");
assertEquals(3, workbook.getNumberOfSheets()); assertEquals(3, workbook.getNumberOfSheets());
@ -218,7 +250,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals(1, sheetLS.getPrintSetup().getCopies()); assertEquals(1, sheetLS.getPrintSetup().getCopies());
} }
public void testGroupRows() { @Test
public void groupRows() {
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet s = workbook.createSheet(); HSSFSheet s = workbook.createSheet();
HSSFRow r1 = s.createRow(0); HSSFRow r1 = s.createRow(0);
@ -258,7 +291,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals(0, r5.getOutlineLevel()); assertEquals(0, r5.getOutlineLevel());
} }
public void testGroupRowsExisting() { @Test
public void groupRowsExisting() {
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("NoGutsRecords.xls"); HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("NoGutsRecords.xls");
HSSFSheet s = workbook.getSheetAt(0); HSSFSheet s = workbook.getSheetAt(0);
@ -290,7 +324,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
try { try {
workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook); workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook);
} catch (OutOfMemoryError e) { } catch (OutOfMemoryError e) {
throw new AssertionFailedError("Identified bug 39903"); fail("Identified bug 39903");
} }
s = workbook.getSheetAt(0); s = workbook.getSheetAt(0);
@ -309,7 +343,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals(0, r6.getOutlineLevel()); assertEquals(0, r6.getOutlineLevel());
} }
public void testCreateDrawings() { @Test
public void createDrawings() {
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet(); HSSFSheet sheet = workbook.createSheet();
HSSFPatriarch p1 = sheet.createDrawingPatriarch(); HSSFPatriarch p1 = sheet.createDrawingPatriarch();
@ -317,7 +352,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertSame(p1, p2); assertSame(p1, p2);
} }
public void testGetDrawings() { @Test
public void getDrawings() {
HSSFWorkbook wb1c = HSSFTestDataSamples.openSampleWorkbook("WithChart.xls"); HSSFWorkbook wb1c = HSSFTestDataSamples.openSampleWorkbook("WithChart.xls");
HSSFWorkbook wb2c = HSSFTestDataSamples.openSampleWorkbook("WithTwoCharts.xls"); HSSFWorkbook wb2c = HSSFTestDataSamples.openSampleWorkbook("WithTwoCharts.xls");
@ -341,7 +377,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Test that the ProtectRecord is included when creating or cloning a sheet * Test that the ProtectRecord is included when creating or cloning a sheet
*/ */
public void testCloneWithProtect() { @Test
public void cloneWithProtect() {
String passwordA = "secrect"; String passwordA = "secrect";
int expectedHashA = -6810; int expectedHashA = -6810;
String passwordB = "admin"; String passwordB = "admin";
@ -369,7 +406,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash()); assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash());
} }
public void testProtectSheetA() { @Test
public void protectSheetA() {
int expectedHash = (short)0xfef1; int expectedHash = (short)0xfef1;
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
@ -385,7 +423,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
* {@link PasswordRecord} belongs with the rest of the Worksheet Protection Block * {@link PasswordRecord} belongs with the rest of the Worksheet Protection Block
* (which should be before {@link DimensionsRecord}). * (which should be before {@link DimensionsRecord}).
*/ */
public void testProtectSheetRecordOrder_bug47363a() { @Test
public void protectSheetRecordOrder_bug47363a() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
s.protectSheet("secret"); s.protectSheet("secret");
@ -394,7 +433,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
Record[] recs = rc.getRecords(); Record[] recs = rc.getRecords();
int nRecs = recs.length; int nRecs = recs.length;
if (recs[nRecs-2] instanceof PasswordRecord && recs[nRecs-5] instanceof DimensionsRecord) { if (recs[nRecs-2] instanceof PasswordRecord && recs[nRecs-5] instanceof DimensionsRecord) {
throw new AssertionFailedError("Identified bug 47363a - PASSWORD after DIMENSION"); fail("Identified bug 47363a - PASSWORD after DIMENSION");
} }
// Check that protection block is together, and before DIMENSION // Check that protection block is together, and before DIMENSION
confirmRecordClass(recs, nRecs-4, DimensionsRecord.class); confirmRecordClass(recs, nRecs-4, DimensionsRecord.class);
@ -406,8 +445,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
private static void confirmRecordClass(Record[] recs, int index, Class<? extends Record> cls) { private static void confirmRecordClass(Record[] recs, int index, Class<? extends Record> cls) {
if (recs.length <= index) { if (recs.length <= index) {
throw new AssertionFailedError("Expected (" + cls.getName() + ") at index " fail("Expected (" + cls.getName() + ") at index "
+ index + " but array length is " + recs.length + "."); + index + " but array length is " + recs.length + ".");
} }
assertEquals(cls, recs[index].getClass()); assertEquals(cls, recs[index].getClass());
} }
@ -415,7 +454,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* There should be no problem with adding data validations after sheet protection * There should be no problem with adding data validations after sheet protection
*/ */
public void testDvProtectionOrder_bug47363b() { @Test
public void dvProtectionOrder_bug47363b() {
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("Sheet1"); HSSFSheet sheet = workbook.createSheet("Sheet1");
sheet.protectSheet("secret"); sheet.protectSheet("secret");
@ -429,7 +469,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
String expMsg = "Unexpected (org.apache.poi.hssf.record.PasswordRecord) while looking for DV Table insert pos"; String expMsg = "Unexpected (org.apache.poi.hssf.record.PasswordRecord) while looking for DV Table insert pos";
if (expMsg.equals(e.getMessage())) { if (expMsg.equals(e.getMessage())) {
throw new AssertionFailedError("Identified bug 47363b"); fail("Identified bug 47363b");
} }
throw e; throw e;
} }
@ -446,7 +486,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals(4, nRecsWithProtection - nRecsWithoutProtection); assertEquals(4, nRecsWithProtection - nRecsWithoutProtection);
} }
public void testZoom() { @Test
public void zoom() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet(); HSSFSheet sheet = wb.createSheet();
assertEquals(-1, sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid)); assertEquals(-1, sheet.getSheet().findFirstRecordLocBySid(SCLRecord.sid));
@ -490,13 +531,10 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* When removing one merged region, it would break * When removing one merged region, it would break
*
*/
/**
* Make sure the excel file loads work * Make sure the excel file loads work
*
*/ */
public void testPageBreakFiles() { @Test
public void pageBreakFiles() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls"); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls");
HSSFSheet sheet = wb.getSheetAt(0); HSSFSheet sheet = wb.getSheetAt(0);
@ -524,7 +562,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals("column breaks number", 2, sheet.getColumnBreaks().length); assertEquals("column breaks number", 2, sheet.getColumnBreaks().length);
} }
public void testDBCSName () { @Test
public void dbcsName () {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DBCSSheetName.xls"); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DBCSSheetName.xls");
wb.getSheetAt(1); wb.getSheetAt(1);
assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" ); assertEquals ("DBCS Sheet Name 2", wb.getSheetName(1),"\u090f\u0915" );
@ -536,7 +575,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
* parameter to allow setting the toprow in the visible view * parameter to allow setting the toprow in the visible view
* of the sheet when it is first opened. * of the sheet when it is first opened.
*/ */
public void testTopRow() { @Test
public void topRow() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls"); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls");
HSSFSheet sheet = wb.getSheetAt(0); HSSFSheet sheet = wb.getSheetAt(0);
@ -549,10 +589,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol()); assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol());
} }
/** @Test
* public void addEmptyRow() {
*/
public void testAddEmptyRow() {
//try to add 5 empty rows to a new sheet //try to add 5 empty rows to a new sheet
HSSFWorkbook workbook = new HSSFWorkbook(); HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet(); HSSFSheet sheet = workbook.createSheet();
@ -572,7 +610,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void testAutoSizeColumn() { @Test
public void autoSizeColumn() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("43902.xls"); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("43902.xls");
String sheetName = "my sheet"; String sheetName = "my sheet";
HSSFSheet sheet = wb.getSheet(sheetName); HSSFSheet sheet = wb.getSheet(sheetName);
@ -614,7 +653,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertTrue(sheet3.getColumnWidth(0) <= maxWithRow1And2); assertTrue(sheet3.getColumnWidth(0) <= maxWithRow1And2);
} }
public void testAutoSizeDate() throws Exception { @Test
public void autoSizeDate() throws Exception {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet("Sheet1"); HSSFSheet s = wb.createSheet("Sheet1");
HSSFRow r = s.createRow(0); HSSFRow r = s.createRow(0);
@ -654,7 +694,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Setting ForceFormulaRecalculation on sheets * Setting ForceFormulaRecalculation on sheets
*/ */
public void testForceRecalculation() throws Exception { @Test
public void forceRecalculation() throws Exception {
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("UncalcedRecord.xls"); HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("UncalcedRecord.xls");
HSSFSheet sheet = workbook.getSheetAt(0); HSSFSheet sheet = workbook.getSheetAt(0);
@ -721,7 +762,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertTrue(wb3.getSheetAt(3).getForceFormulaRecalculation()); assertTrue(wb3.getSheetAt(3).getForceFormulaRecalculation());
} }
public void testColumnWidthA() { @Test
public void columnWidthA() {
//check we can correctly read column widths from a reference workbook //check we can correctly read column widths from a reference workbook
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("colwidth.xls"); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("colwidth.xls");
@ -781,7 +823,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
} }
public void testDefaultColumnWidth() { @Test
public void defaultColumnWidth() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook( "12843-1.xls" ); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook( "12843-1.xls" );
HSSFSheet sheet = wb.getSheetAt( 7 ); HSSFSheet sheet = wb.getSheetAt( 7 );
// shall not be NPE // shall not be NPE
@ -807,16 +850,17 @@ public final class TestHSSFSheet extends BaseTestSheet {
* Excel, ooo, and google docs are OK with this. * Excel, ooo, and google docs are OK with this.
* Now POI is too. * Now POI is too.
*/ */
public void testMissingRowRecords_bug41187() { @Test
public void missingRowRecords_bug41187() {
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex41187-19267.xls"); HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex41187-19267.xls");
HSSFSheet sheet = wb.getSheetAt(0); HSSFSheet sheet = wb.getSheetAt(0);
HSSFRow row = sheet.getRow(0); HSSFRow row = sheet.getRow(0);
if(row == null) { if(row == null) {
throw new AssertionFailedError("Identified bug 41187 a"); fail("Identified bug 41187 a");
} }
if (row.getHeight() == 0) { if (row.getHeight() == 0) {
throw new AssertionFailedError("Identified bug 41187 b"); fail("Identified bug 41187 b");
} }
assertEquals("Hi Excel!", row.getCell(0).getRichStringCellValue().getString()); assertEquals("Hi Excel!", row.getCell(0).getRichStringCellValue().getString());
// check row height for 'default' flag // check row height for 'default' flag
@ -831,7 +875,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
* *
* See bug #45720. * See bug #45720.
*/ */
public void testCloneSheetWithDrawings() { @Test
public void cloneSheetWithDrawings() {
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("45720.xls"); HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("45720.xls");
HSSFSheet sheet1 = wb1.getSheetAt(0); HSSFSheet sheet1 = wb1.getSheetAt(0);
@ -865,14 +910,15 @@ public final class TestHSSFSheet extends BaseTestSheet {
* Since Excel silently truncates to 31, make sure that POI enforces uniqueness on the first * Since Excel silently truncates to 31, make sure that POI enforces uniqueness on the first
* 31 chars. * 31 chars.
*/ */
public void testLongSheetNames() { @Test
public void longSheetNames() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
final String SAME_PREFIX = "A123456789B123456789C123456789"; // 30 chars final String SAME_PREFIX = "A123456789B123456789C123456789"; // 30 chars
wb.createSheet(SAME_PREFIX + "Dxxxx"); wb.createSheet(SAME_PREFIX + "Dxxxx");
try { try {
wb.createSheet(SAME_PREFIX + "Dyyyy"); // identical up to the 32nd char wb.createSheet(SAME_PREFIX + "Dyyyy"); // identical up to the 32nd char
throw new AssertionFailedError("Expected exception not thrown"); fail("Expected exception not thrown");
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
assertEquals("The workbook already contains a sheet of this name", e.getMessage()); assertEquals("The workbook already contains a sheet of this name", e.getMessage());
} }
@ -882,7 +928,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Tests that we can read existing column styles * Tests that we can read existing column styles
*/ */
public void testReadColumnStyles() { @Test
public void readColumnStyles() {
HSSFWorkbook wbNone = HSSFTestDataSamples.openSampleWorkbook("ColumnStyleNone.xls"); HSSFWorkbook wbNone = HSSFTestDataSamples.openSampleWorkbook("ColumnStyleNone.xls");
HSSFWorkbook wbSimple = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dp.xls"); HSSFWorkbook wbSimple = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dp.xls");
HSSFWorkbook wbComplex = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dpColoured.xls"); HSSFWorkbook wbComplex = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dpColoured.xls");
@ -921,7 +968,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
/** /**
* Tests the arabic setting * Tests the arabic setting
*/ */
public void testArabic() { @Test
public void arabic() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet(); HSSFSheet s = wb.createSheet();
@ -930,7 +978,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertTrue(s.isRightToLeft()); assertTrue(s.isRightToLeft());
} }
public void testAutoFilter(){ @Test
public void autoFilter(){
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sh = wb.createSheet(); HSSFSheet sh = wb.createSheet();
InternalWorkbook iwb = wb.getWorkbook(); InternalWorkbook iwb = wb.getWorkbook();
@ -979,14 +1028,16 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertTrue(subRecords.get(2) instanceof LbsDataSubRecord ); assertTrue(subRecords.get(2) instanceof LbsDataSubRecord );
} }
public void testGetSetColumnHiddenShort() { @Test
public void getSetColumnHiddenShort() {
Workbook workbook = new HSSFWorkbook(); Workbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1"); Sheet sheet = workbook.createSheet("Sheet 1");
sheet.setColumnHidden((short)2, true); sheet.setColumnHidden((short)2, true);
assertTrue(sheet.isColumnHidden((short)2)); assertTrue(sheet.isColumnHidden((short)2));
} }
public void testColumnWidthShort() { @Test
public void columnWidthShort() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -1045,20 +1096,19 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertEquals(40000, sheet.getColumnWidth((short)10)); assertEquals(40000, sheet.getColumnWidth((short)10));
} }
public void testShowInPane() { @Test
public void showInPane() {
Workbook wb = new HSSFWorkbook(); Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
sheet.showInPane(2, 3); sheet.showInPane(2, 3);
try { thrown.expect(IllegalArgumentException.class);
sheet.showInPane(Integer.MAX_VALUE, 3); thrown.expectMessage("Maximum row number is 65535");
fail("Should catch exception here"); sheet.showInPane(Integer.MAX_VALUE, 3);
} catch (IllegalArgumentException e) {
assertEquals("Maximum row number is 65535", e.getMessage());
}
} }
public void testDrawingRecords() { @Test
public void drawingRecords() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet(); HSSFSheet sheet = wb.createSheet();
@ -1068,7 +1118,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
assertNull(sheet.getDrawingEscherAggregate()); assertNull(sheet.getDrawingEscherAggregate());
} }
public void testBug55723b() { @Test
public void bug55723b() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();

View File

@ -0,0 +1,66 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.formula.functions;
import junit.framework.TestCase;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.formula.atp.AnalysisToolPak;
import org.apache.poi.ss.usermodel.*;
public class CountifsTests extends TestCase {
public void testCallFunction() {
HSSFWorkbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet("test");
Row row1 = sheet.createRow(0);
Cell cellA1 = row1.createCell(0, Cell.CELL_TYPE_FORMULA);
Cell cellB1 = row1.createCell(1, Cell.CELL_TYPE_NUMERIC);
Cell cellC1 = row1.createCell(2, Cell.CELL_TYPE_NUMERIC);
Cell cellD1 = row1.createCell(3, Cell.CELL_TYPE_NUMERIC);
Cell cellE1 = row1.createCell(4, Cell.CELL_TYPE_NUMERIC);
cellB1.setCellValue(1);
cellC1.setCellValue(1);
cellD1.setCellValue(2);
cellE1.setCellValue(4);
cellA1.setCellFormula("COUNTIFS(B1:C1,1, D1:E1,2)");
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
CellValue evaluate = evaluator.evaluate(cellA1);
assertEquals(1.0d, evaluate.getNumberValue());
}
public void testCallFunction_invalidArgs() {
HSSFWorkbook workbook = new HSSFWorkbook();
Sheet sheet = workbook.createSheet("test");
Row row1 = sheet.createRow(0);
Cell cellA1 = row1.createCell(0, Cell.CELL_TYPE_FORMULA);
cellA1.setCellFormula("COUNTIFS()");
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
CellValue evaluate = evaluator.evaluate(cellA1);
assertEquals(15, evaluate.getErrorValue());
cellA1.setCellFormula("COUNTIFS(A1:C1)");
evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluate = evaluator.evaluate(cellA1);
assertEquals(15, evaluate.getErrorValue());
cellA1.setCellFormula("COUNTIFS(A1:C1,2,2)");
evaluator = workbook.getCreationHelper().createFormulaEvaluator();
evaluate = evaluator.evaluate(cellA1);
assertEquals(15, evaluate.getErrorValue());
}
}

View File

@ -1,3 +1,19 @@
/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
package org.apache.poi.ss.formula.functions; package org.apache.poi.ss.formula.functions;
/** /**

View File

@ -17,29 +17,41 @@
package org.apache.poi.ss.usermodel; package org.apache.poi.ss.usermodel;
import java.util.Iterator; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import junit.framework.TestCase; import java.util.Iterator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.PaneInformation; import org.apache.poi.hssf.util.PaneInformation;
import org.apache.poi.ss.ITestDataProvider; import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
/** /**
* Common superclass for testing {@link org.apache.poi.xssf.usermodel.XSSFCell} and * Common superclass for testing {@link org.apache.poi.xssf.usermodel.XSSFCell} and
* {@link org.apache.poi.hssf.usermodel.HSSFCell} * {@link org.apache.poi.hssf.usermodel.HSSFCell}
*/ */
public abstract class BaseTestSheet extends TestCase { public abstract class BaseTestSheet {
@Rule
public ExpectedException thrown = ExpectedException.none();
private final ITestDataProvider _testDataProvider; private final ITestDataProvider _testDataProvider;
protected BaseTestSheet(ITestDataProvider testDataProvider) { protected BaseTestSheet(ITestDataProvider testDataProvider) {
_testDataProvider = testDataProvider; _testDataProvider = testDataProvider;
} }
public void testCreateRow() { @Test
public void createRow() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet(); Sheet sheet = workbook.createSheet();
assertEquals(0, sheet.getPhysicalNumberOfRows()); assertEquals(0, sheet.getPhysicalNumberOfRows());
@ -79,7 +91,8 @@ public abstract class BaseTestSheet extends TestCase {
} }
public void testRemoveRow() { @Test
public void removeRow() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet1 = workbook.createSheet(); Sheet sheet1 = workbook.createSheet();
assertEquals(0, sheet1.getPhysicalNumberOfRows()); assertEquals(0, sheet1.getPhysicalNumberOfRows());
@ -112,15 +125,14 @@ public abstract class BaseTestSheet extends TestCase {
Row row3 = sheet1.createRow(3); Row row3 = sheet1.createRow(3);
Sheet sheet2 = workbook.createSheet(); Sheet sheet2 = workbook.createSheet();
try {
sheet2.removeRow(row3); thrown.expect(IllegalArgumentException.class);
fail("Expected exception"); thrown.expectMessage("Specified row does not belong to this sheet");
} catch (IllegalArgumentException e){ sheet2.removeRow(row3);
assertEquals("Specified row does not belong to this sheet", e.getMessage());
}
} }
public void testCloneSheet() { @Test
public void cloneSheet() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
CreationHelper factory = workbook.getCreationHelper(); CreationHelper factory = workbook.getCreationHelper();
Sheet sheet = workbook.createSheet("Test Clone"); Sheet sheet = workbook.createSheet("Test Clone");
@ -152,7 +164,8 @@ public abstract class BaseTestSheet extends TestCase {
/** tests that the sheet name for multiple clones of the same sheet is unique /** tests that the sheet name for multiple clones of the same sheet is unique
* BUG 37416 * BUG 37416
*/ */
public void testCloneSheetMultipleTimes() { @Test
public void cloneSheetMultipleTimes() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
CreationHelper factory = workbook.getCreationHelper(); CreationHelper factory = workbook.getCreationHelper();
Sheet sheet = workbook.createSheet("Test Clone"); Sheet sheet = workbook.createSheet("Test Clone");
@ -179,7 +192,8 @@ public abstract class BaseTestSheet extends TestCase {
/** /**
* Setting landscape and portrait stuff on new sheets * Setting landscape and portrait stuff on new sheets
*/ */
public void testPrintSetupLandscapeNew() { @Test
public void printSetupLandscapeNew() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheetL = workbook.createSheet("LandscapeS"); Sheet sheetL = workbook.createSheet("LandscapeS");
Sheet sheetP = workbook.createSheet("LandscapeP"); Sheet sheetP = workbook.createSheet("LandscapeP");
@ -216,7 +230,8 @@ public abstract class BaseTestSheet extends TestCase {
* then an IllegalArgumentException should be thrown * then an IllegalArgumentException should be thrown
* *
*/ */
public void testAddMerged() { @Test
public void addMerged() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
assertEquals(0, sheet.getNumMergedRegions()); assertEquals(0, sheet.getNumMergedRegions());
@ -231,7 +246,7 @@ public abstract class BaseTestSheet extends TestCase {
sheet.addMergedRegion(region); sheet.addMergedRegion(region);
fail("Expected exception"); fail("Expected exception");
} catch (IllegalArgumentException e){ } catch (IllegalArgumentException e){
// TODO assertEquals("Minimum row number is 0.", e.getMessage()); // TODO: assertEquals("Minimum row number is 0.", e.getMessage());
} }
try { try {
region = new CellRangeAddress(0, 0, 0, ssVersion.getLastColumnIndex() + 1); region = new CellRangeAddress(0, 0, 0, ssVersion.getLastColumnIndex() + 1);
@ -254,7 +269,8 @@ public abstract class BaseTestSheet extends TestCase {
* When removing one merged region, it would break * When removing one merged region, it would break
* *
*/ */
public void testRemoveMerged() { @Test
public void removeMerged() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
CellRangeAddress region = new CellRangeAddress(0, 1, 0, 1); CellRangeAddress region = new CellRangeAddress(0, 1, 0, 1);
@ -288,7 +304,8 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals("the merged row to doesnt match the one we put in ", 4, region.getLastRow()); assertEquals("the merged row to doesnt match the one we put in ", 4, region.getLastRow());
} }
public void testShiftMerged() { @Test
public void shiftMerged() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
CreationHelper factory = wb.getCreationHelper(); CreationHelper factory = wb.getCreationHelper();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -313,7 +330,8 @@ public abstract class BaseTestSheet extends TestCase {
* Tests the display of gridlines, formulas, and rowcolheadings. * Tests the display of gridlines, formulas, and rowcolheadings.
* @author Shawn Laubach (slaubach at apache dot org) * @author Shawn Laubach (slaubach at apache dot org)
*/ */
public void testDisplayOptions() { @Test
public void displayOptions() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -336,7 +354,8 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals(sheet.isDisplayZeros(), false); assertEquals(sheet.isDisplayZeros(), false);
} }
public void testColumnWidth() { @Test
public void columnWidth() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -396,7 +415,8 @@ public abstract class BaseTestSheet extends TestCase {
} }
public void testDefaultRowHeight() { @Test
public void defaultRowHeight() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet(); Sheet sheet = workbook.createSheet();
sheet.setDefaultRowHeightInPoints(15); sheet.setDefaultRowHeightInPoints(15);
@ -424,7 +444,8 @@ public abstract class BaseTestSheet extends TestCase {
} }
/** cell with formula becomes null on cloning a sheet*/ /** cell with formula becomes null on cloning a sheet*/
public void test35084() { @Test
public void bug35084() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet("Sheet1"); Sheet s = wb.createSheet("Sheet1");
Row r = s.createRow(0); Row r = s.createRow(0);
@ -438,7 +459,8 @@ public abstract class BaseTestSheet extends TestCase {
} }
/** test that new default column styles get applied */ /** test that new default column styles get applied */
public void testDefaultColumnStyle() { @Test
public void defaultColumnStyle() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
CellStyle style = wb.createCellStyle(); CellStyle style = wb.createCellStyle();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -453,7 +475,8 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals("style should match", style.getIndex(), style2.getIndex()); assertEquals("style should match", style.getIndex(), style2.getIndex());
} }
public void testOutlineProperties() { @Test
public void outlineProperties() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -483,7 +506,8 @@ public abstract class BaseTestSheet extends TestCase {
/** /**
* Test basic display properties * Test basic display properties
*/ */
public void testSheetProperties() { @Test
public void sheetProperties() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -565,15 +589,13 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals(11.5, sheet.getMargin(Sheet.HeaderMargin), 0.0); assertEquals(11.5, sheet.getMargin(Sheet.HeaderMargin), 0.0);
// incorrect margin constant // incorrect margin constant
try { thrown.expect(IllegalArgumentException.class);
sheet.setMargin((short) 65, 15); thrown.expectMessage("Unknown margin constant: 65");
fail("Expected exception"); sheet.setMargin((short) 65, 15);
} catch (IllegalArgumentException e){
assertEquals("Unknown margin constant: 65", e.getMessage());
}
} }
public void testRowBreaks() { @Test
public void rowBreaks() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet(); Sheet sheet = workbook.createSheet();
//Sheet#getRowBreaks() returns an empty array if no row breaks are defined //Sheet#getRowBreaks() returns an empty array if no row breaks are defined
@ -601,7 +623,8 @@ public abstract class BaseTestSheet extends TestCase {
assertFalse(sheet.isRowBroken(15)); assertFalse(sheet.isRowBroken(15));
} }
public void testColumnBreaks() { @Test
public void columnBreaks() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet(); Sheet sheet = workbook.createSheet();
assertNotNull(sheet.getColumnBreaks()); assertNotNull(sheet.getColumnBreaks());
@ -628,7 +651,8 @@ public abstract class BaseTestSheet extends TestCase {
assertFalse(sheet.isColumnBroken(12)); assertFalse(sheet.isColumnBroken(12));
} }
public void testGetFirstLastRowNum() { @Test
public void getFirstLastRowNum() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1"); Sheet sheet = workbook.createSheet("Sheet 1");
sheet.createRow(9); sheet.createRow(9);
@ -638,7 +662,8 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals(9, sheet.getLastRowNum()); assertEquals(9, sheet.getLastRowNum());
} }
public void testGetFooter() { @Test
public void getFooter() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1"); Sheet sheet = workbook.createSheet("Sheet 1");
assertNotNull(sheet.getFooter()); assertNotNull(sheet.getFooter());
@ -646,26 +671,28 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals("test center footer", sheet.getFooter().getCenter()); assertEquals("test center footer", sheet.getFooter().getCenter());
} }
public void testGetSetColumnHidden() { @Test
public void getSetColumnHidden() {
Workbook workbook = _testDataProvider.createWorkbook(); Workbook workbook = _testDataProvider.createWorkbook();
Sheet sheet = workbook.createSheet("Sheet 1"); Sheet sheet = workbook.createSheet("Sheet 1");
sheet.setColumnHidden(2, true); sheet.setColumnHidden(2, true);
assertTrue(sheet.isColumnHidden(2)); assertTrue(sheet.isColumnHidden(2));
} }
public void testProtectSheet() { @Test
public void protectSheet() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
assertFalse(sheet.getProtect());
sheet.protectSheet("Test");
assertTrue(sheet.getProtect());
sheet.protectSheet(null);
assertFalse(sheet.getProtect()); assertFalse(sheet.getProtect());
sheet.protectSheet("Test");
assertTrue(sheet.getProtect());
sheet.protectSheet(null);
assertFalse(sheet.getProtect());
} }
public void testCreateFreezePane() { @Test
public void createFreezePane() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
// create a workbook // create a workbook
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -715,7 +742,8 @@ public abstract class BaseTestSheet extends TestCase {
} }
public void testGetRepeatingRowsAndColumns() { @Test
public void getRepeatingRowsAndColumns() {
Workbook wb = _testDataProvider.openSampleWorkbook( Workbook wb = _testDataProvider.openSampleWorkbook(
"RepeatingRowsCols." "RepeatingRowsCols."
+ _testDataProvider.getStandardFileNameExtension()); + _testDataProvider.getStandardFileNameExtension());
@ -727,7 +755,8 @@ public abstract class BaseTestSheet extends TestCase {
} }
public void testSetRepeatingRowsAndColumnsBug47294(){ @Test
public void setRepeatingRowsAndColumnsBug47294(){
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet1 = wb.createSheet(); Sheet sheet1 = wb.createSheet();
sheet1.setRepeatingRows(CellRangeAddress.valueOf("1:4")); sheet1.setRepeatingRows(CellRangeAddress.valueOf("1:4"));
@ -739,56 +768,58 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals("1:4", sheet2.getRepeatingRows().formatAsString()); assertEquals("1:4", sheet2.getRepeatingRows().formatAsString());
} }
public void testSetRepeatingRowsAndColumns() { @Test
Workbook wb = _testDataProvider.createWorkbook(); public void setRepeatingRowsAndColumns() {
Sheet sheet1 = wb.createSheet("Sheet1"); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet2 = wb.createSheet("Sheet2"); Sheet sheet1 = wb.createSheet("Sheet1");
Sheet sheet3 = wb.createSheet("Sheet3"); Sheet sheet2 = wb.createSheet("Sheet2");
Sheet sheet3 = wb.createSheet("Sheet3");
checkRepeatingRowsAndColumns(sheet1, null, null);
checkRepeatingRowsAndColumns(sheet1, null, null);
sheet1.setRepeatingRows(CellRangeAddress.valueOf("4:5"));
sheet2.setRepeatingColumns(CellRangeAddress.valueOf("A:C")); sheet1.setRepeatingRows(CellRangeAddress.valueOf("4:5"));
sheet3.setRepeatingRows(CellRangeAddress.valueOf("1:4")); sheet2.setRepeatingColumns(CellRangeAddress.valueOf("A:C"));
sheet3.setRepeatingColumns(CellRangeAddress.valueOf("A:A")); sheet3.setRepeatingRows(CellRangeAddress.valueOf("1:4"));
sheet3.setRepeatingColumns(CellRangeAddress.valueOf("A:A"));
checkRepeatingRowsAndColumns(sheet1, "4:5", null);
checkRepeatingRowsAndColumns(sheet2, null, "A:C"); checkRepeatingRowsAndColumns(sheet1, "4:5", null);
checkRepeatingRowsAndColumns(sheet3, "1:4", "A:A"); checkRepeatingRowsAndColumns(sheet2, null, "A:C");
checkRepeatingRowsAndColumns(sheet3, "1:4", "A:A");
// write out, read back, and test refrain...
wb = _testDataProvider.writeOutAndReadBack(wb); // write out, read back, and test refrain...
sheet1 = wb.getSheetAt(0); wb = _testDataProvider.writeOutAndReadBack(wb);
sheet2 = wb.getSheetAt(1); sheet1 = wb.getSheetAt(0);
sheet3 = wb.getSheetAt(2); sheet2 = wb.getSheetAt(1);
sheet3 = wb.getSheetAt(2);
checkRepeatingRowsAndColumns(sheet1, "4:5", null);
checkRepeatingRowsAndColumns(sheet2, null, "A:C"); checkRepeatingRowsAndColumns(sheet1, "4:5", null);
checkRepeatingRowsAndColumns(sheet3, "1:4", "A:A"); checkRepeatingRowsAndColumns(sheet2, null, "A:C");
checkRepeatingRowsAndColumns(sheet3, "1:4", "A:A");
// check removing repeating rows and columns
sheet3.setRepeatingRows(null); // check removing repeating rows and columns
checkRepeatingRowsAndColumns(sheet3, null, "A:A"); sheet3.setRepeatingRows(null);
checkRepeatingRowsAndColumns(sheet3, null, "A:A");
sheet3.setRepeatingColumns(null);
checkRepeatingRowsAndColumns(sheet3, null, null); sheet3.setRepeatingColumns(null);
checkRepeatingRowsAndColumns(sheet3, null, null);
} }
private void checkRepeatingRowsAndColumns( private void checkRepeatingRowsAndColumns(
Sheet s, String expectedRows, String expectedCols) { Sheet s, String expectedRows, String expectedCols) {
if (expectedRows == null) { if (expectedRows == null) {
assertNull(s.getRepeatingRows()); assertNull(s.getRepeatingRows());
} else { } else {
assertEquals(expectedRows, s.getRepeatingRows().formatAsString()); assertEquals(expectedRows, s.getRepeatingRows().formatAsString());
} }
if (expectedCols == null) { if (expectedCols == null) {
assertNull(s.getRepeatingColumns()); assertNull(s.getRepeatingColumns());
} else { } else {
assertEquals(expectedCols, s.getRepeatingColumns().formatAsString()); assertEquals(expectedCols, s.getRepeatingColumns().formatAsString());
} }
} }
public void testBaseZoom() { @Test
public void baseZoom() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -796,14 +827,15 @@ public abstract class BaseTestSheet extends TestCase {
sheet.setZoom(3,4); sheet.setZoom(3,4);
} }
public void testBaseShowInPane() { @Test
public void baseShowInPane() {
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
sheet.showInPane(2, 3); sheet.showInPane(2, 3);
} }
@Test
public void testBug55723(){ public void bug55723(){
Workbook wb = _testDataProvider.createWorkbook(); Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -818,7 +850,8 @@ public abstract class BaseTestSheet extends TestCase {
// there seems to be currently no generic way to check the setting... // there seems to be currently no generic way to check the setting...
} }
public void testBug55723_Rows() { @Test
public void bug55723_Rows() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();
@ -827,8 +860,8 @@ public abstract class BaseTestSheet extends TestCase {
assertNotNull(filter); assertNotNull(filter);
} }
@Test
public void testBug55723d_RowsOver65k() { public void bug55723d_RowsOver65k() {
HSSFWorkbook wb = new HSSFWorkbook(); HSSFWorkbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet(); Sheet sheet = wb.createSheet();

Binary file not shown.