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:
commit
a9b59608cb
32
build.xml
32
build.xml
@ -158,6 +158,10 @@ under the License.
|
||||
<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"/>
|
||||
|
||||
<!-- 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 -->
|
||||
<!-- "Copy these file(s), free of charge" -->
|
||||
<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.jar" location="${ooxml.lib}/ooxml-encryption-1.1.jar"/>
|
||||
|
||||
|
||||
<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"/>
|
||||
|
||||
@ -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 -->
|
||||
<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 -->
|
||||
<property name="jar.name" value="poi"/>
|
||||
<property name="build.site" location="build/tmp/site/build/site"/>
|
||||
@ -343,6 +350,7 @@ under the License.
|
||||
<available file="${main.ant.jar}"/>
|
||||
<available file="${asm.jar}"/>
|
||||
<available file="${jacoco.zip}"/>
|
||||
<available file="${rat.jar}"/>
|
||||
</and>
|
||||
<isset property="disconnected"/>
|
||||
</or>
|
||||
@ -389,6 +397,10 @@ under the License.
|
||||
<include name="lib/*.jar"/>
|
||||
</patternset>
|
||||
</unzip>
|
||||
<antcall target="downloadfile">
|
||||
<param name="sourcefile" value="${rat.url}"/>
|
||||
<param name="destfile" value="${rat.jar}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
|
||||
<target name="check-ooxml-jars">
|
||||
@ -1305,7 +1317,7 @@ under the License.
|
||||
</target>
|
||||
|
||||
<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"/>
|
||||
<target name="maven.ant.tasks-check">
|
||||
@ -1345,10 +1357,13 @@ under the License.
|
||||
<!-- which are missing the correct license headers -->
|
||||
<!-- You need to download rat from http://incubator.apache.org/rat/ -->
|
||||
<!-- 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"
|
||||
uri="antlib:org.apache.rat.anttasks"/>
|
||||
<rat:report xmlns:rat="antlib:org.apache.rat.anttasks">
|
||||
uri="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/">
|
||||
<exclude name="documentation/content/xdocs/dtd/" />
|
||||
<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" />
|
||||
</fileset>
|
||||
</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>
|
||||
</project>
|
||||
|
||||
|
@ -164,6 +164,7 @@ public final class AnalysisToolPak implements UDFFinder {
|
||||
r(m, "YIELD", null);
|
||||
r(m, "YIELDDISC", null);
|
||||
r(m, "YIELDMAT", null);
|
||||
r(m, "COUNTIFS", Countifs.instance);
|
||||
|
||||
return m;
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
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/>
|
||||
|
55
src/java/org/apache/poi/ss/formula/functions/Countifs.java
Normal file
55
src/java/org/apache/poi/ss/formula/functions/Countifs.java
Normal 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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
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/>
|
||||
|
@ -42,7 +42,16 @@ import org.apache.poi.openxml4j.opc.PackageRelationshipCollection;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
import org.apache.poi.ss.formula.FormulaShifter;
|
||||
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.CellRangeAddressList;
|
||||
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.XmlOptions;
|
||||
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.
|
||||
@ -1206,9 +1256,24 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
|
||||
private void groupColumn1Based(int fromColumn, int toColumn) {
|
||||
CTCols ctCols=worksheet.getColsArray(0);
|
||||
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.setMax(toColumn);
|
||||
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++){
|
||||
CTCol col=columnHelper.getColumn1Based(index, false);
|
||||
//col must exist
|
||||
|
@ -17,13 +17,18 @@
|
||||
|
||||
package org.apache.poi.xssf.usermodel.helpers;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Comparator;
|
||||
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.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.CTCols;
|
||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
|
||||
@ -45,19 +50,26 @@ public class ColumnHelper {
|
||||
cleanColumns();
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||
public void cleanColumns() {
|
||||
this.newCols = CTCols.Factory.newInstance();
|
||||
CTCols[] colsArray = worksheet.getColsArray();
|
||||
int i = 0;
|
||||
for (i = 0; i < colsArray.length; i++) {
|
||||
CTCols cols = colsArray[i];
|
||||
CTCol[] colArray = cols.getColArray();
|
||||
for (int y = 0; y < colArray.length; y++) {
|
||||
CTCol col = colArray[y];
|
||||
newCols = addCleanColIntoCols(newCols, col);
|
||||
|
||||
CTCols aggregateCols = CTCols.Factory.newInstance();
|
||||
List<CTCols> colsList = worksheet.getColsList();
|
||||
if (colsList != null) {
|
||||
for (CTCols cols : colsList) {
|
||||
for (CTCol col : cols.getColList()) {
|
||||
cloneCol(aggregateCols, 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--) {
|
||||
worksheet.removeCols(y);
|
||||
}
|
||||
@ -65,9 +77,102 @@ public class ColumnHelper {
|
||||
worksheet.setColsArray(0, newCols);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation") //YK: getXYZArray() array accessors are deprecated in xmlbeans with JDK 1.5 support
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
newCols.setColArray(colArray);
|
||||
}
|
||||
@ -86,6 +191,7 @@ public class ColumnHelper {
|
||||
public CTCol getColumn(long index, boolean splitColumns) {
|
||||
return getColumn1Based(index+1, splitColumns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Column at the given 1 based index.
|
||||
* POI default is 0 based, but the file stores
|
||||
@ -113,98 +219,40 @@ public class ColumnHelper {
|
||||
}
|
||||
|
||||
public CTCols addCleanColIntoCols(CTCols cols, CTCol col) {
|
||||
boolean colOverlaps = false;
|
||||
// a Map to remember overlapping columns
|
||||
Map<Long, Boolean> overlappingCols = new LinkedHashMap<Long, Boolean>();
|
||||
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++;
|
||||
CTCols newCols = CTCols.Factory.newInstance();
|
||||
for (CTCol c : cols.getColList()) {
|
||||
cloneCol(newCols, c);
|
||||
}
|
||||
// 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(cols, col);
|
||||
} else {
|
||||
// insert new columns for ranges without overlaps
|
||||
long colMin = -1;
|
||||
for (long j = col.getMin(); j <= col.getMax(); j++) {
|
||||
if (!Boolean.TRUE.equals(overlappingCols.get(Long.valueOf(j)))) {
|
||||
if (colMin < 0) {
|
||||
colMin = j;
|
||||
}
|
||||
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;
|
||||
cloneCol(newCols, col);
|
||||
sortColumns(newCols);
|
||||
CTCol[] colArray = new CTCol[newCols.getColList().size()];
|
||||
newCols.getColList().toArray(colArray);
|
||||
CTCols returnCols = CTCols.Factory.newInstance();
|
||||
sweepCleanColumns(returnCols, colArray, col);
|
||||
colArray = new CTCol[returnCols.getColList().size()];
|
||||
returnCols.getColList().toArray(colArray);
|
||||
cols.setColArray(colArray);
|
||||
return returnCols;
|
||||
}
|
||||
|
||||
/*
|
||||
* Insert a new CTCol at position 0 into cols, setting min=min, max=max and
|
||||
* 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,
|
||||
CTCol[] colsWithAttributes) {
|
||||
if(!columnExists(cols,min,max)){
|
||||
CTCol[] colsWithAttributes, boolean ignoreExistsCheck, CTCol overrideColumn) {
|
||||
if(ignoreExistsCheck || !columnExists(cols,min,max)){
|
||||
CTCol newCol = cols.insertNewCol(0);
|
||||
newCol.setMin(min);
|
||||
newCol.setMax(max);
|
||||
for (CTCol col : colsWithAttributes) {
|
||||
setColumnAttributes(col, newCol);
|
||||
}
|
||||
if (overrideColumn != null) setColumnAttributes(overrideColumn, newCol);
|
||||
return newCol;
|
||||
}
|
||||
return null;
|
||||
|
@ -19,11 +19,16 @@
|
||||
|
||||
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.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.xssf.SXSSFITestDataProvider;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.junit.After;
|
||||
import org.junit.Test;
|
||||
|
||||
|
||||
public class TestSXSSFSheet extends BaseTestSheet {
|
||||
@ -33,7 +38,7 @@ public class TestSXSSFSheet extends BaseTestSheet {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown(){
|
||||
SXSSFITestDataProvider.instance.cleanup();
|
||||
}
|
||||
@ -43,35 +48,30 @@ public class TestSXSSFSheet extends BaseTestSheet {
|
||||
* cloning of sheets is not supported in SXSSF
|
||||
*/
|
||||
@Override
|
||||
public void testCloneSheet() {
|
||||
try {
|
||||
super.testCloneSheet();
|
||||
fail("expected exception");
|
||||
} catch (RuntimeException e){
|
||||
assertEquals("NotImplemented", e.getMessage());
|
||||
}
|
||||
@Test
|
||||
public void cloneSheet() {
|
||||
thrown.expect(RuntimeException.class);
|
||||
thrown.expectMessage("NotImplemented");
|
||||
super.cloneSheet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testCloneSheetMultipleTimes() {
|
||||
try {
|
||||
super.testCloneSheetMultipleTimes();
|
||||
fail("expected exception");
|
||||
} catch (RuntimeException e){
|
||||
assertEquals("NotImplemented", e.getMessage());
|
||||
}
|
||||
@Test
|
||||
public void cloneSheetMultipleTimes() {
|
||||
thrown.expect(RuntimeException.class);
|
||||
thrown.expectMessage("NotImplemented");
|
||||
super.cloneSheetMultipleTimes();
|
||||
}
|
||||
|
||||
/**
|
||||
* shifting rows is not supported in SXSSF
|
||||
*/
|
||||
@Override
|
||||
public void testShiftMerged(){
|
||||
try {
|
||||
super.testShiftMerged();
|
||||
fail("expected exception");
|
||||
} catch (RuntimeException e){
|
||||
assertEquals("NotImplemented", e.getMessage());
|
||||
}
|
||||
@Test
|
||||
public void shiftMerged(){
|
||||
thrown.expect(RuntimeException.class);
|
||||
thrown.expectMessage("NotImplemented");
|
||||
super.shiftMerged();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,21 +80,21 @@ public class TestSXSSFSheet extends BaseTestSheet {
|
||||
* The test is disabled because cloning of sheets is not supported in SXSSF
|
||||
*/
|
||||
@Override
|
||||
public void test35084(){
|
||||
try {
|
||||
super.test35084();
|
||||
fail("expected exception");
|
||||
} catch (RuntimeException e){
|
||||
assertEquals("NotImplemented", e.getMessage());
|
||||
}
|
||||
@Test
|
||||
public void bug35084(){
|
||||
thrown.expect(RuntimeException.class);
|
||||
thrown.expectMessage("NotImplemented");
|
||||
super.bug35084();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void testDefaultColumnStyle() {
|
||||
@Test
|
||||
public void defaultColumnStyle() {
|
||||
//TODO column styles are not yet supported by XSSF
|
||||
}
|
||||
|
||||
public void testOverrideFlushedRows() {
|
||||
@Test
|
||||
public void overrideFlushedRows() {
|
||||
Workbook wb = new SXSSFWorkbook(3);
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
@ -102,16 +102,14 @@ public class TestSXSSFSheet extends BaseTestSheet {
|
||||
sheet.createRow(2);
|
||||
sheet.createRow(3);
|
||||
sheet.createRow(4);
|
||||
try {
|
||||
|
||||
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);
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void testOverrideRowsInTemplate() {
|
||||
@Test
|
||||
public void overrideRowsInTemplate() {
|
||||
XSSFWorkbook template = new XSSFWorkbook();
|
||||
template.createSheet().createRow(1);
|
||||
|
||||
|
@ -17,6 +17,15 @@
|
||||
|
||||
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 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.SXSSFWorkbook;
|
||||
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 {
|
||||
|
||||
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
|
||||
@Override
|
||||
public void testDefaultColumnStyle() {
|
||||
//super.testDefaultColumnStyle();
|
||||
@Test
|
||||
public void defaultColumnStyle() {
|
||||
//super.defaultColumnStyle();
|
||||
}
|
||||
|
||||
public void testTestGetSetMargin() {
|
||||
@Test
|
||||
public void getSetMargin() {
|
||||
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");
|
||||
XSSFOddHeader hdr;
|
||||
XSSFOddFooter ftr;
|
||||
@ -117,7 +139,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals("", ftr.getRight());
|
||||
}
|
||||
|
||||
public void testGetAllHeadersFooters() {
|
||||
@Test
|
||||
public void getAllHeadersFooters() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
||||
assertNotNull(sheet.getOddFooter());
|
||||
@ -156,7 +179,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals("odd header center", sheet.getHeader().getCenter());
|
||||
}
|
||||
|
||||
public void testAutoSizeColumn() {
|
||||
@Test
|
||||
public void autoSizeColumn() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
||||
sheet.createRow(0).createCell(13).setCellValue("test");
|
||||
@ -171,7 +195,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
/**
|
||||
* XSSFSheet autoSizeColumn() on empty RichTextString fails
|
||||
*/
|
||||
public void test48325() {
|
||||
@Test
|
||||
public void bug48325() {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet sheet = wb.createSheet("Test");
|
||||
CreationHelper factory = wb.getCreationHelper();
|
||||
@ -187,7 +212,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
sheet.autoSizeColumn(0);
|
||||
}
|
||||
|
||||
public void testGetCellComment() {
|
||||
@Test
|
||||
public void getCellComment() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
XSSFDrawing dg = sheet.createDrawingPatriarch();
|
||||
@ -200,7 +226,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals("test C10 author", sheet.getCellComment(9, 2).getAuthor());
|
||||
}
|
||||
|
||||
public void testSetCellComment() {
|
||||
@Test
|
||||
public void setCellComment() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
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()));
|
||||
}
|
||||
|
||||
public void testGetActiveCell() {
|
||||
@Test
|
||||
public void getActiveCell() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
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();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
CTWorksheet ctWorksheet = sheet.getCTWorksheet();
|
||||
@ -243,7 +272,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals(STPane.BOTTOM_RIGHT, ctWorksheet.getSheetViews().getSheetViewArray(0).getPane().getActivePane());
|
||||
}
|
||||
|
||||
public void testNewMergedRegionAt() {
|
||||
@Test
|
||||
public void newMergedRegionAt() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
CellRangeAddress region = CellRangeAddress.valueOf("B2:D4");
|
||||
@ -252,7 +282,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals(1, sheet.getNumMergedRegions());
|
||||
}
|
||||
|
||||
public void testRemoveMergedRegion_lowlevel() {
|
||||
@Test
|
||||
public void removeMergedRegion_lowlevel() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
CTWorksheet ctWorksheet = sheet.getCTWorksheet();
|
||||
@ -274,7 +305,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
"region on the sheet.", sheet.getCTWorksheet().getMergeCells());
|
||||
}
|
||||
|
||||
public void testSetDefaultColumnStyle() {
|
||||
@Test
|
||||
public void setDefaultColumnStyle() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
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();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
|
||||
@ -308,41 +341,41 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
sheet.groupColumn(10, 11);
|
||||
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
assertEquals(2, cols.sizeOfColArray());
|
||||
CTCol[] colArray = cols.getColArray();
|
||||
List<CTCol> colArray = cols.getColList();
|
||||
assertNotNull(colArray);
|
||||
assertEquals(2 + 1, colArray[0].getMin()); // 1 based
|
||||
assertEquals(7 + 1, colArray[0].getMax()); // 1 based
|
||||
assertEquals(1, colArray[0].getOutlineLevel());
|
||||
assertEquals(2 + 1, colArray.get(0).getMin()); // 1 based
|
||||
assertEquals(7 + 1, colArray.get(0).getMax()); // 1 based
|
||||
assertEquals(1, colArray.get(0).getOutlineLevel());
|
||||
|
||||
//two level
|
||||
sheet.groupColumn(1, 2);
|
||||
cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
assertEquals(4, cols.sizeOfColArray());
|
||||
colArray = cols.getColArray();
|
||||
assertEquals(2, colArray[1].getOutlineLevel());
|
||||
colArray = cols.getColList();
|
||||
assertEquals(2, colArray.get(1).getOutlineLevel());
|
||||
|
||||
//three level
|
||||
sheet.groupColumn(6, 8);
|
||||
sheet.groupColumn(2, 3);
|
||||
cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
assertEquals(7, cols.sizeOfColArray());
|
||||
colArray = cols.getColArray();
|
||||
assertEquals(3, colArray[1].getOutlineLevel());
|
||||
colArray = cols.getColList();
|
||||
assertEquals(3, colArray.get(1).getOutlineLevel());
|
||||
assertEquals(3, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
||||
|
||||
sheet.ungroupColumn(8, 10);
|
||||
colArray = cols.getColArray();
|
||||
colArray = cols.getColList();
|
||||
//assertEquals(3, colArray[1].getOutlineLevel());
|
||||
|
||||
sheet.ungroupColumn(4, 6);
|
||||
sheet.ungroupColumn(2, 2);
|
||||
colArray = cols.getColArray();
|
||||
assertEquals(4, colArray.length);
|
||||
colArray = cols.getColList();
|
||||
assertEquals(4, colArray.size());
|
||||
assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelCol());
|
||||
}
|
||||
|
||||
|
||||
public void testGroupUngroupRow() {
|
||||
@Test
|
||||
public void groupUngroupRow() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
|
||||
@ -376,7 +409,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals(1, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow());
|
||||
}
|
||||
|
||||
public void testSetZoom() {
|
||||
@Test
|
||||
public void setZoom() {
|
||||
XSSFWorkbook workBook = new XSSFWorkbook();
|
||||
XSSFSheet sheet1 = workBook.createSheet("new sheet");
|
||||
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
|
||||
* better should really review this!
|
||||
*/
|
||||
public void testSetColumnGroupCollapsed(){
|
||||
@Test
|
||||
public void setColumnGroupCollapsed(){
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
XSSFSheet sheet1 =(XSSFSheet) wb.createSheet();
|
||||
|
||||
@ -501,7 +536,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals(5, cols.getColArray(0).getMin()); // 1 based
|
||||
assertEquals(8, cols.getColArray(0).getMax()); // 1 based
|
||||
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).getMax()); // 1 based
|
||||
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(8, cols.getColArray(0).getMax()); // 1 based
|
||||
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).getMax()); // 1 based
|
||||
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(8, cols.getColArray(0).getMax()); // 1 based
|
||||
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).getMax()); // 1 based
|
||||
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(8, cols.getColArray(0).getMax()); // 1 based
|
||||
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).getMax()); // 1 based
|
||||
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
|
||||
* better should really review this!
|
||||
*/
|
||||
public void testSetRowGroupCollapsed(){
|
||||
@Test
|
||||
public void setRowGroupCollapsed(){
|
||||
Workbook wb = new XSSFWorkbook();
|
||||
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
|
||||
*/
|
||||
public void testColumnWidth_lowlevel() {
|
||||
@Test
|
||||
public void columnWidth_lowlevel() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
||||
sheet.setColumnWidth(1, 22 * 256);
|
||||
@ -718,9 +755,9 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
XSSFSheet xs = sheet;
|
||||
CTWorksheet cts = xs.getCTWorksheet();
|
||||
|
||||
CTCols[] cols_s = cts.getColsArray();
|
||||
assertEquals(1, cols_s.length);
|
||||
CTCols cols = cols_s[0];
|
||||
List<CTCols> cols_s = cts.getColsList();
|
||||
assertEquals(1, cols_s.size());
|
||||
CTCols cols = cols_s.get(0);
|
||||
assertEquals(1, cols.sizeOfColArray());
|
||||
CTCol col = cols.getColArray(0);
|
||||
|
||||
@ -733,9 +770,9 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
// Now set another
|
||||
sheet.setColumnWidth(3, 33 * 256);
|
||||
|
||||
cols_s = cts.getColsArray();
|
||||
assertEquals(1, cols_s.length);
|
||||
cols = cols_s[0];
|
||||
cols_s = cts.getColsList();
|
||||
assertEquals(1, cols_s.size());
|
||||
cols = cols_s.get(0);
|
||||
assertEquals(2, cols.sizeOfColArray());
|
||||
|
||||
col = cols.getColArray(0);
|
||||
@ -754,7 +791,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
/**
|
||||
* Setting width of a column included in a column span
|
||||
*/
|
||||
public void test47862() {
|
||||
@Test
|
||||
public void bug47862() {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47862.xlsx");
|
||||
XSSFSheet sheet = wb.getSheetAt(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
|
||||
*/
|
||||
public void test47804() {
|
||||
@Test
|
||||
public void bug47804() {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("47804.xlsx");
|
||||
XSSFSheet sheet = wb.getSheetAt(0);
|
||||
CTCols cols = sheet.getCTWorksheet().getColsArray(0);
|
||||
@ -877,7 +916,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertFalse(sheet.isColumnHidden(5));
|
||||
}
|
||||
|
||||
public void testCommentsTable() {
|
||||
@Test
|
||||
public void commentsTable() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet1 = workbook.createSheet();
|
||||
CommentsTable comment1 = sheet1.getCommentsTable(false);
|
||||
@ -916,7 +956,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
* Rows and cells can be created in random order,
|
||||
* but CTRows are kept in ascending order
|
||||
*/
|
||||
public void testCreateRowA() {
|
||||
@Test
|
||||
public void createRow() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet();
|
||||
CTWorksheet wsh = sheet.getCTWorksheet();
|
||||
@ -939,27 +980,27 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
row3.createCell(5);
|
||||
|
||||
|
||||
CTRow[] xrow = sheetData.getRowArray();
|
||||
assertEquals(3, xrow.length);
|
||||
List<CTRow> xrow = sheetData.getRowList();
|
||||
assertEquals(3, xrow.size());
|
||||
|
||||
//rows are sorted: {0, 1, 2}
|
||||
assertEquals(4, xrow[0].sizeOfCArray());
|
||||
assertEquals(1, xrow[0].getR());
|
||||
assertTrue(xrow[0].equals(row3.getCTRow()));
|
||||
assertEquals(4, xrow.get(0).sizeOfCArray());
|
||||
assertEquals(1, xrow.get(0).getR());
|
||||
assertTrue(xrow.get(0).equals(row3.getCTRow()));
|
||||
|
||||
assertEquals(3, xrow[1].sizeOfCArray());
|
||||
assertEquals(2, xrow[1].getR());
|
||||
assertTrue(xrow[1].equals(row2.getCTRow()));
|
||||
assertEquals(3, xrow.get(1).sizeOfCArray());
|
||||
assertEquals(2, xrow.get(1).getR());
|
||||
assertTrue(xrow.get(1).equals(row2.getCTRow()));
|
||||
|
||||
assertEquals(2, xrow[2].sizeOfCArray());
|
||||
assertEquals(3, xrow[2].getR());
|
||||
assertTrue(xrow[2].equals(row1.getCTRow()));
|
||||
assertEquals(2, xrow.get(2).sizeOfCArray());
|
||||
assertEquals(3, xrow.get(2).getR());
|
||||
assertTrue(xrow.get(2).equals(row1.getCTRow()));
|
||||
|
||||
CTCell[] xcell = xrow[0].getCArray();
|
||||
assertEquals("D1", xcell[0].getR());
|
||||
assertEquals("A1", xcell[1].getR());
|
||||
assertEquals("C1", xcell[2].getR());
|
||||
assertEquals("F1", xcell[3].getR());
|
||||
List<CTCell> xcell = xrow.get(0).getCList();
|
||||
assertEquals("D1", xcell.get(0).getR());
|
||||
assertEquals("A1", xcell.get(1).getR());
|
||||
assertEquals("C1", xcell.get(2).getR());
|
||||
assertEquals("F1", xcell.get(3).getR());
|
||||
|
||||
//re-creating a row does NOT add extra data to the parent
|
||||
row2 = sheet.createRow(1);
|
||||
@ -971,29 +1012,30 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
workbook = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||
sheet = workbook.getSheetAt(0);
|
||||
wsh = sheet.getCTWorksheet();
|
||||
xrow = sheetData.getRowArray();
|
||||
assertEquals(3, xrow.length);
|
||||
xrow = sheetData.getRowList();
|
||||
assertEquals(3, xrow.size());
|
||||
|
||||
//rows are sorted: {0, 1, 2}
|
||||
assertEquals(4, xrow[0].sizeOfCArray());
|
||||
assertEquals(1, xrow[0].getR());
|
||||
assertEquals(4, xrow.get(0).sizeOfCArray());
|
||||
assertEquals(1, xrow.get(0).getR());
|
||||
//cells are now sorted
|
||||
xcell = xrow[0].getCArray();
|
||||
assertEquals("A1", xcell[0].getR());
|
||||
assertEquals("C1", xcell[1].getR());
|
||||
assertEquals("D1", xcell[2].getR());
|
||||
assertEquals("F1", xcell[3].getR());
|
||||
xcell = xrow.get(0).getCList();
|
||||
assertEquals("A1", xcell.get(0).getR());
|
||||
assertEquals("C1", xcell.get(1).getR());
|
||||
assertEquals("D1", xcell.get(2).getR());
|
||||
assertEquals("F1", xcell.get(3).getR());
|
||||
|
||||
|
||||
assertEquals(0, xrow[1].sizeOfCArray());
|
||||
assertEquals(2, xrow[1].getR());
|
||||
assertEquals(0, xrow.get(1).sizeOfCArray());
|
||||
assertEquals(2, xrow.get(1).getR());
|
||||
|
||||
assertEquals(2, xrow[2].sizeOfCArray());
|
||||
assertEquals(3, xrow[2].getR());
|
||||
assertEquals(2, xrow.get(2).sizeOfCArray());
|
||||
assertEquals(3, xrow.get(2).getR());
|
||||
|
||||
}
|
||||
|
||||
public void testSetAutoFilter() {
|
||||
@Test
|
||||
public void setAutoFilter() {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet sheet = wb.createSheet("new sheet");
|
||||
sheet.setAutoFilter(CellRangeAddress.valueOf("A1:D100"));
|
||||
@ -1010,8 +1052,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals("'new sheet'!$A$1:$D$100", nm.getCTName().getStringValue());
|
||||
}
|
||||
|
||||
public void testProtectSheet_lowlevel() {
|
||||
|
||||
@Test
|
||||
public void protectSheet_lowlevel() {
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
XSSFSheet sheet = wb.createSheet();
|
||||
CTSheetProtection pr = sheet.getCTWorksheet().getSheetProtection();
|
||||
@ -1031,7 +1073,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
}
|
||||
|
||||
|
||||
public void test49966() {
|
||||
@Test
|
||||
public void bug49966() {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49966.xlsx");
|
||||
CalculationChain calcChain = wb.getCalculationChain();
|
||||
assertNotNull(wb.getCalculationChain());
|
||||
@ -1053,14 +1096,15 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
/**
|
||||
* See bug #50829
|
||||
*/
|
||||
public void testTables() {
|
||||
@Test
|
||||
public void tables() {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("WithTable.xlsx");
|
||||
assertEquals(3, wb.getNumberOfSheets());
|
||||
|
||||
// Check the table sheet
|
||||
XSSFSheet s1 = wb.getSheetAt(0);
|
||||
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();
|
||||
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
|
||||
*/
|
||||
public void testSetForceFormulaRecalculation() {
|
||||
@Test
|
||||
public void setForceFormulaRecalculation() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
||||
|
||||
@ -1105,7 +1150,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals(false, sheet.getForceFormulaRecalculation());
|
||||
}
|
||||
|
||||
public void test54607() {
|
||||
@Test
|
||||
public void bug54607() {
|
||||
// run with the file provided in the Bug-Report
|
||||
runGetTopRow("54607.xlsx", true, 1, 0, 0);
|
||||
runGetLeftCol("54607.xlsx", true, 0, 0, 0);
|
||||
@ -1167,7 +1213,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
}
|
||||
}
|
||||
|
||||
public void testShowInPaneManyRowsBug55248() {
|
||||
@Test
|
||||
public void showInPaneManyRowsBug55248() {
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
XSSFSheet sheet = workbook.createSheet("Sheet 1");
|
||||
|
||||
@ -1179,14 +1226,15 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
// this one fails: sheet.showInPane((short)i, 0);
|
||||
}
|
||||
|
||||
short i = 0;
|
||||
int i = 0;
|
||||
sheet.showInPane(i, i);
|
||||
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||
checkRowCount(wb);
|
||||
}
|
||||
|
||||
public void testShowInPaneManyRowsBug55248SXSSF() {
|
||||
@Test
|
||||
public void showInPaneManyRowsBug55248SXSSF() {
|
||||
SXSSFWorkbook workbook = new SXSSFWorkbook(new XSSFWorkbook());
|
||||
SXSSFSheet sheet = (SXSSFSheet) workbook.createSheet("Sheet 1");
|
||||
|
||||
@ -1198,7 +1246,7 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
// this one fails: sheet.showInPane((short)i, 0);
|
||||
}
|
||||
|
||||
short i = 0;
|
||||
int i = 0;
|
||||
sheet.showInPane(i, i);
|
||||
|
||||
Workbook wb = SXSSFITestDataProvider.instance.writeOutAndReadBack(workbook);
|
||||
@ -1212,7 +1260,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertEquals(ROW_COUNT-1, sh.getLastRowNum());
|
||||
}
|
||||
|
||||
public static void test55745() throws Exception {
|
||||
@Test
|
||||
public void bug55745() throws Exception {
|
||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("55745.xlsx");
|
||||
XSSFSheet sheet = wb.getSheetAt(0);
|
||||
List<XSSFTable> tables = sheet.getTables();
|
||||
@ -1230,7 +1279,8 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertNotNull("Sheet should contain a comments table", sheet.getCommentsTable(false));
|
||||
}
|
||||
|
||||
public void testBug55723b(){
|
||||
@Test
|
||||
public void bug55723b(){
|
||||
XSSFWorkbook wb = new XSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
@ -1255,4 +1305,10 @@ public final class TestXSSFSheet extends BaseTestSheet {
|
||||
assertNotNull(name);
|
||||
assertEquals("Sheet0!$B:$C", name.getRefersToFormula());
|
||||
}
|
||||
|
||||
@Test(timeout=180000)
|
||||
public void bug51585(){
|
||||
XSSFTestDataSamples.openSampleWorkbook("51585.xlsx");
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
|
||||
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.SheetBuilder;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
@ -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;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
@ -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;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
@ -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;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -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;
|
||||
|
||||
import java.io.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;
|
||||
|
||||
import java.io.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;
|
||||
|
||||
import java.io.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;
|
||||
|
||||
import java.io.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;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
@ -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;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -17,20 +17,44 @@
|
||||
|
||||
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.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
import org.apache.poi.ddf.EscherDgRecord;
|
||||
import org.apache.poi.hssf.HSSFITestDataProvider;
|
||||
import org.apache.poi.hssf.HSSFTestDataSamples;
|
||||
import org.apache.poi.hssf.model.DrawingManager2;
|
||||
import org.apache.poi.hssf.model.InternalSheet;
|
||||
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.usermodel.RecordInspector.RecordCollector;
|
||||
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.CellRangeAddressList;
|
||||
import org.apache.poi.util.TempFile;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* Moved from TestHSSFWorkbook#testSetRepeatingRowsAndColumns().
|
||||
*/
|
||||
public void testSetRepeatingRowsAndColumnsBug29747() {
|
||||
@Test
|
||||
public void setRepeatingRowsAndColumnsBug29747() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
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});
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the gridset field gets set as expected.
|
||||
*/
|
||||
public void testBackupRecord() {
|
||||
@Test
|
||||
public void backupRecord() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet s = wb.createSheet();
|
||||
GridsetRecord gridsetRec = s.getSheet().getGridsetRecord();
|
||||
@ -96,7 +124,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
* Test vertically centered output.
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testVerticallyCenter() {
|
||||
@Test
|
||||
public void verticallyCenter() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet s = wb.createSheet();
|
||||
VCenterRecord record = s.getSheet().getPageSettings().getVCenter();
|
||||
@ -115,7 +144,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
/**
|
||||
* Test horizontally centered output.
|
||||
*/
|
||||
public void testHorizontallyCenter() {
|
||||
@Test
|
||||
public void horizontallyCenter() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet s = wb.createSheet();
|
||||
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.
|
||||
*/
|
||||
public void testWSBool() {
|
||||
@Test
|
||||
public void wsBool() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet s = wb.createSheet();
|
||||
WSBoolRecord record =
|
||||
@ -177,7 +208,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
/**
|
||||
* Setting landscape and portrait stuff on existing sheets
|
||||
*/
|
||||
public void testPrintSetupLandscapeExisting() {
|
||||
@Test
|
||||
public void printSetupLandscapeExisting() {
|
||||
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls");
|
||||
|
||||
assertEquals(3, workbook.getNumberOfSheets());
|
||||
@ -218,7 +250,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals(1, sheetLS.getPrintSetup().getCopies());
|
||||
}
|
||||
|
||||
public void testGroupRows() {
|
||||
@Test
|
||||
public void groupRows() {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet s = workbook.createSheet();
|
||||
HSSFRow r1 = s.createRow(0);
|
||||
@ -258,7 +291,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals(0, r5.getOutlineLevel());
|
||||
}
|
||||
|
||||
public void testGroupRowsExisting() {
|
||||
@Test
|
||||
public void groupRowsExisting() {
|
||||
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("NoGutsRecords.xls");
|
||||
|
||||
HSSFSheet s = workbook.getSheetAt(0);
|
||||
@ -290,7 +324,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
try {
|
||||
workbook = HSSFTestDataSamples.writeOutAndReadBack(workbook);
|
||||
} catch (OutOfMemoryError e) {
|
||||
throw new AssertionFailedError("Identified bug 39903");
|
||||
fail("Identified bug 39903");
|
||||
}
|
||||
|
||||
s = workbook.getSheetAt(0);
|
||||
@ -309,7 +343,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals(0, r6.getOutlineLevel());
|
||||
}
|
||||
|
||||
public void testCreateDrawings() {
|
||||
@Test
|
||||
public void createDrawings() {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet();
|
||||
HSSFPatriarch p1 = sheet.createDrawingPatriarch();
|
||||
@ -317,7 +352,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertSame(p1, p2);
|
||||
}
|
||||
|
||||
public void testGetDrawings() {
|
||||
@Test
|
||||
public void getDrawings() {
|
||||
HSSFWorkbook wb1c = HSSFTestDataSamples.openSampleWorkbook("WithChart.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
|
||||
*/
|
||||
public void testCloneWithProtect() {
|
||||
@Test
|
||||
public void cloneWithProtect() {
|
||||
String passwordA = "secrect";
|
||||
int expectedHashA = -6810;
|
||||
String passwordB = "admin";
|
||||
@ -369,7 +406,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals(expectedHashA, sheet2.getSheet().getProtectionBlock().getPasswordHash());
|
||||
}
|
||||
|
||||
public void testProtectSheetA() {
|
||||
@Test
|
||||
public void protectSheetA() {
|
||||
int expectedHash = (short)0xfef1;
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
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
|
||||
* (which should be before {@link DimensionsRecord}).
|
||||
*/
|
||||
public void testProtectSheetRecordOrder_bug47363a() {
|
||||
@Test
|
||||
public void protectSheetRecordOrder_bug47363a() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet s = wb.createSheet();
|
||||
s.protectSheet("secret");
|
||||
@ -394,7 +433,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
Record[] recs = rc.getRecords();
|
||||
int nRecs = recs.length;
|
||||
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
|
||||
confirmRecordClass(recs, nRecs-4, DimensionsRecord.class);
|
||||
@ -406,7 +445,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
|
||||
private static void confirmRecordClass(Record[] recs, int index, Class<? extends Record> cls) {
|
||||
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 + ".");
|
||||
}
|
||||
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
|
||||
*/
|
||||
public void testDvProtectionOrder_bug47363b() {
|
||||
@Test
|
||||
public void dvProtectionOrder_bug47363b() {
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet("Sheet1");
|
||||
sheet.protectSheet("secret");
|
||||
@ -429,7 +469,7 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
} catch (IllegalStateException e) {
|
||||
String expMsg = "Unexpected (org.apache.poi.hssf.record.PasswordRecord) while looking for DV Table insert pos";
|
||||
if (expMsg.equals(e.getMessage())) {
|
||||
throw new AssertionFailedError("Identified bug 47363b");
|
||||
fail("Identified bug 47363b");
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
@ -446,7 +486,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals(4, nRecsWithProtection - nRecsWithoutProtection);
|
||||
}
|
||||
|
||||
public void testZoom() {
|
||||
@Test
|
||||
public void zoom() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sheet = wb.createSheet();
|
||||
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
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* Make sure the excel file loads work
|
||||
*
|
||||
*/
|
||||
public void testPageBreakFiles() {
|
||||
@Test
|
||||
public void pageBreakFiles() {
|
||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls");
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
@ -524,7 +562,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals("column breaks number", 2, sheet.getColumnBreaks().length);
|
||||
}
|
||||
|
||||
public void testDBCSName () {
|
||||
@Test
|
||||
public void dbcsName () {
|
||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("DBCSSheetName.xls");
|
||||
wb.getSheetAt(1);
|
||||
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
|
||||
* of the sheet when it is first opened.
|
||||
*/
|
||||
public void testTopRow() {
|
||||
@Test
|
||||
public void topRow() {
|
||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("SimpleWithPageBreaks.xls");
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
@ -549,10 +589,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals("HSSFSheet.getLeftCol()", leftcol, sheet.getLeftCol());
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void testAddEmptyRow() {
|
||||
@Test
|
||||
public void addEmptyRow() {
|
||||
//try to add 5 empty rows to a new sheet
|
||||
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||
HSSFSheet sheet = workbook.createSheet();
|
||||
@ -572,7 +610,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void testAutoSizeColumn() {
|
||||
@Test
|
||||
public void autoSizeColumn() {
|
||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("43902.xls");
|
||||
String sheetName = "my sheet";
|
||||
HSSFSheet sheet = wb.getSheet(sheetName);
|
||||
@ -614,7 +653,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertTrue(sheet3.getColumnWidth(0) <= maxWithRow1And2);
|
||||
}
|
||||
|
||||
public void testAutoSizeDate() throws Exception {
|
||||
@Test
|
||||
public void autoSizeDate() throws Exception {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet s = wb.createSheet("Sheet1");
|
||||
HSSFRow r = s.createRow(0);
|
||||
@ -654,7 +694,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
/**
|
||||
* Setting ForceFormulaRecalculation on sheets
|
||||
*/
|
||||
public void testForceRecalculation() throws Exception {
|
||||
@Test
|
||||
public void forceRecalculation() throws Exception {
|
||||
HSSFWorkbook workbook = HSSFTestDataSamples.openSampleWorkbook("UncalcedRecord.xls");
|
||||
|
||||
HSSFSheet sheet = workbook.getSheetAt(0);
|
||||
@ -721,7 +762,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertTrue(wb3.getSheetAt(3).getForceFormulaRecalculation());
|
||||
}
|
||||
|
||||
public void testColumnWidthA() {
|
||||
@Test
|
||||
public void columnWidthA() {
|
||||
//check we can correctly read column widths from a reference workbook
|
||||
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" );
|
||||
HSSFSheet sheet = wb.getSheetAt( 7 );
|
||||
// shall not be NPE
|
||||
@ -807,16 +850,17 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
* Excel, ooo, and google docs are OK with this.
|
||||
* Now POI is too.
|
||||
*/
|
||||
public void testMissingRowRecords_bug41187() {
|
||||
@Test
|
||||
public void missingRowRecords_bug41187() {
|
||||
HSSFWorkbook wb = HSSFTestDataSamples.openSampleWorkbook("ex41187-19267.xls");
|
||||
|
||||
HSSFSheet sheet = wb.getSheetAt(0);
|
||||
HSSFRow row = sheet.getRow(0);
|
||||
if(row == null) {
|
||||
throw new AssertionFailedError("Identified bug 41187 a");
|
||||
fail("Identified bug 41187 a");
|
||||
}
|
||||
if (row.getHeight() == 0) {
|
||||
throw new AssertionFailedError("Identified bug 41187 b");
|
||||
fail("Identified bug 41187 b");
|
||||
}
|
||||
assertEquals("Hi Excel!", row.getCell(0).getRichStringCellValue().getString());
|
||||
// check row height for 'default' flag
|
||||
@ -831,7 +875,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
*
|
||||
* See bug #45720.
|
||||
*/
|
||||
public void testCloneSheetWithDrawings() {
|
||||
@Test
|
||||
public void cloneSheetWithDrawings() {
|
||||
HSSFWorkbook wb1 = HSSFTestDataSamples.openSampleWorkbook("45720.xls");
|
||||
|
||||
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
|
||||
* 31 chars.
|
||||
*/
|
||||
public void testLongSheetNames() {
|
||||
@Test
|
||||
public void longSheetNames() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
final String SAME_PREFIX = "A123456789B123456789C123456789"; // 30 chars
|
||||
|
||||
wb.createSheet(SAME_PREFIX + "Dxxxx");
|
||||
try {
|
||||
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) {
|
||||
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
|
||||
*/
|
||||
public void testReadColumnStyles() {
|
||||
@Test
|
||||
public void readColumnStyles() {
|
||||
HSSFWorkbook wbNone = HSSFTestDataSamples.openSampleWorkbook("ColumnStyleNone.xls");
|
||||
HSSFWorkbook wbSimple = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dp.xls");
|
||||
HSSFWorkbook wbComplex = HSSFTestDataSamples.openSampleWorkbook("ColumnStyle1dpColoured.xls");
|
||||
@ -921,7 +968,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
/**
|
||||
* Tests the arabic setting
|
||||
*/
|
||||
public void testArabic() {
|
||||
@Test
|
||||
public void arabic() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet s = wb.createSheet();
|
||||
|
||||
@ -930,7 +978,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertTrue(s.isRightToLeft());
|
||||
}
|
||||
|
||||
public void testAutoFilter(){
|
||||
@Test
|
||||
public void autoFilter(){
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sh = wb.createSheet();
|
||||
InternalWorkbook iwb = wb.getWorkbook();
|
||||
@ -979,14 +1028,16 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertTrue(subRecords.get(2) instanceof LbsDataSubRecord );
|
||||
}
|
||||
|
||||
public void testGetSetColumnHiddenShort() {
|
||||
@Test
|
||||
public void getSetColumnHiddenShort() {
|
||||
Workbook workbook = new HSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet("Sheet 1");
|
||||
sheet.setColumnHidden((short)2, true);
|
||||
assertTrue(sheet.isColumnHidden((short)2));
|
||||
}
|
||||
|
||||
public void testColumnWidthShort() {
|
||||
@Test
|
||||
public void columnWidthShort() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
@ -1045,20 +1096,19 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertEquals(40000, sheet.getColumnWidth((short)10));
|
||||
}
|
||||
|
||||
public void testShowInPane() {
|
||||
@Test
|
||||
public void showInPane() {
|
||||
Workbook wb = new HSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
sheet.showInPane(2, 3);
|
||||
|
||||
try {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Maximum row number is 65535");
|
||||
sheet.showInPane(Integer.MAX_VALUE, 3);
|
||||
fail("Should catch exception here");
|
||||
} catch (IllegalArgumentException e) {
|
||||
assertEquals("Maximum row number is 65535", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testDrawingRecords() {
|
||||
@Test
|
||||
public void drawingRecords() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
HSSFSheet sheet = wb.createSheet();
|
||||
|
||||
@ -1068,7 +1118,8 @@ public final class TestHSSFSheet extends BaseTestSheet {
|
||||
assertNull(sheet.getDrawingEscherAggregate());
|
||||
}
|
||||
|
||||
public void testBug55723b() {
|
||||
@Test
|
||||
public void bug55723b() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -17,21 +17,32 @@
|
||||
|
||||
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.util.PaneInformation;
|
||||
import org.apache.poi.ss.ITestDataProvider;
|
||||
import org.apache.poi.ss.SpreadsheetVersion;
|
||||
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
|
||||
* {@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;
|
||||
|
||||
@ -39,7 +50,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
_testDataProvider = testDataProvider;
|
||||
}
|
||||
|
||||
public void testCreateRow() {
|
||||
@Test
|
||||
public void createRow() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = workbook.createSheet();
|
||||
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();
|
||||
Sheet sheet1 = workbook.createSheet();
|
||||
assertEquals(0, sheet1.getPhysicalNumberOfRows());
|
||||
@ -112,15 +125,14 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
|
||||
Row row3 = sheet1.createRow(3);
|
||||
Sheet sheet2 = workbook.createSheet();
|
||||
try {
|
||||
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Specified row does not belong to this sheet");
|
||||
sheet2.removeRow(row3);
|
||||
fail("Expected exception");
|
||||
} catch (IllegalArgumentException e){
|
||||
assertEquals("Specified row does not belong to this sheet", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testCloneSheet() {
|
||||
@Test
|
||||
public void cloneSheet() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
CreationHelper factory = workbook.getCreationHelper();
|
||||
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
|
||||
* BUG 37416
|
||||
*/
|
||||
public void testCloneSheetMultipleTimes() {
|
||||
@Test
|
||||
public void cloneSheetMultipleTimes() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
CreationHelper factory = workbook.getCreationHelper();
|
||||
Sheet sheet = workbook.createSheet("Test Clone");
|
||||
@ -179,7 +192,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
/**
|
||||
* Setting landscape and portrait stuff on new sheets
|
||||
*/
|
||||
public void testPrintSetupLandscapeNew() {
|
||||
@Test
|
||||
public void printSetupLandscapeNew() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
Sheet sheetL = workbook.createSheet("LandscapeS");
|
||||
Sheet sheetP = workbook.createSheet("LandscapeP");
|
||||
@ -216,7 +230,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
* then an IllegalArgumentException should be thrown
|
||||
*
|
||||
*/
|
||||
public void testAddMerged() {
|
||||
@Test
|
||||
public void addMerged() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
assertEquals(0, sheet.getNumMergedRegions());
|
||||
@ -231,7 +246,7 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
sheet.addMergedRegion(region);
|
||||
fail("Expected exception");
|
||||
} catch (IllegalArgumentException e){
|
||||
// TODO assertEquals("Minimum row number is 0.", e.getMessage());
|
||||
// TODO: assertEquals("Minimum row number is 0.", e.getMessage());
|
||||
}
|
||||
try {
|
||||
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
|
||||
*
|
||||
*/
|
||||
public void testRemoveMerged() {
|
||||
@Test
|
||||
public void removeMerged() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
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());
|
||||
}
|
||||
|
||||
public void testShiftMerged() {
|
||||
@Test
|
||||
public void shiftMerged() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
CreationHelper factory = wb.getCreationHelper();
|
||||
Sheet sheet = wb.createSheet();
|
||||
@ -313,7 +330,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
* Tests the display of gridlines, formulas, and rowcolheadings.
|
||||
* @author Shawn Laubach (slaubach at apache dot org)
|
||||
*/
|
||||
public void testDisplayOptions() {
|
||||
@Test
|
||||
public void displayOptions() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
@ -336,7 +354,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertEquals(sheet.isDisplayZeros(), false);
|
||||
}
|
||||
|
||||
public void testColumnWidth() {
|
||||
@Test
|
||||
public void columnWidth() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
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();
|
||||
Sheet sheet = workbook.createSheet();
|
||||
sheet.setDefaultRowHeightInPoints(15);
|
||||
@ -424,7 +444,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
}
|
||||
|
||||
/** cell with formula becomes null on cloning a sheet*/
|
||||
public void test35084() {
|
||||
@Test
|
||||
public void bug35084() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet s = wb.createSheet("Sheet1");
|
||||
Row r = s.createRow(0);
|
||||
@ -438,7 +459,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
}
|
||||
|
||||
/** test that new default column styles get applied */
|
||||
public void testDefaultColumnStyle() {
|
||||
@Test
|
||||
public void defaultColumnStyle() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
CellStyle style = wb.createCellStyle();
|
||||
Sheet sheet = wb.createSheet();
|
||||
@ -453,7 +475,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertEquals("style should match", style.getIndex(), style2.getIndex());
|
||||
}
|
||||
|
||||
public void testOutlineProperties() {
|
||||
@Test
|
||||
public void outlineProperties() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
|
||||
Sheet sheet = wb.createSheet();
|
||||
@ -483,7 +506,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
/**
|
||||
* Test basic display properties
|
||||
*/
|
||||
public void testSheetProperties() {
|
||||
@Test
|
||||
public void sheetProperties() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
@ -565,15 +589,13 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertEquals(11.5, sheet.getMargin(Sheet.HeaderMargin), 0.0);
|
||||
|
||||
// incorrect margin constant
|
||||
try {
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
thrown.expectMessage("Unknown margin constant: 65");
|
||||
sheet.setMargin((short) 65, 15);
|
||||
fail("Expected exception");
|
||||
} catch (IllegalArgumentException e){
|
||||
assertEquals("Unknown margin constant: 65", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void testRowBreaks() {
|
||||
@Test
|
||||
public void rowBreaks() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = workbook.createSheet();
|
||||
//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));
|
||||
}
|
||||
|
||||
public void testColumnBreaks() {
|
||||
@Test
|
||||
public void columnBreaks() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = workbook.createSheet();
|
||||
assertNotNull(sheet.getColumnBreaks());
|
||||
@ -628,7 +651,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertFalse(sheet.isColumnBroken(12));
|
||||
}
|
||||
|
||||
public void testGetFirstLastRowNum() {
|
||||
@Test
|
||||
public void getFirstLastRowNum() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = workbook.createSheet("Sheet 1");
|
||||
sheet.createRow(9);
|
||||
@ -638,7 +662,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertEquals(9, sheet.getLastRowNum());
|
||||
}
|
||||
|
||||
public void testGetFooter() {
|
||||
@Test
|
||||
public void getFooter() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = workbook.createSheet("Sheet 1");
|
||||
assertNotNull(sheet.getFooter());
|
||||
@ -646,15 +671,16 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertEquals("test center footer", sheet.getFooter().getCenter());
|
||||
}
|
||||
|
||||
public void testGetSetColumnHidden() {
|
||||
@Test
|
||||
public void getSetColumnHidden() {
|
||||
Workbook workbook = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = workbook.createSheet("Sheet 1");
|
||||
sheet.setColumnHidden(2, true);
|
||||
assertTrue(sheet.isColumnHidden(2));
|
||||
}
|
||||
|
||||
public void testProtectSheet() {
|
||||
|
||||
@Test
|
||||
public void protectSheet() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
assertFalse(sheet.getProtect());
|
||||
@ -665,7 +691,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testCreateFreezePane() {
|
||||
@Test
|
||||
public void createFreezePane() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
// create a workbook
|
||||
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(
|
||||
"RepeatingRowsCols."
|
||||
+ _testDataProvider.getStandardFileNameExtension());
|
||||
@ -727,7 +755,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
}
|
||||
|
||||
|
||||
public void testSetRepeatingRowsAndColumnsBug47294(){
|
||||
@Test
|
||||
public void setRepeatingRowsAndColumnsBug47294(){
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet1 = wb.createSheet();
|
||||
sheet1.setRepeatingRows(CellRangeAddress.valueOf("1:4"));
|
||||
@ -739,7 +768,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertEquals("1:4", sheet2.getRepeatingRows().formatAsString());
|
||||
}
|
||||
|
||||
public void testSetRepeatingRowsAndColumns() {
|
||||
@Test
|
||||
public void setRepeatingRowsAndColumns() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet1 = wb.createSheet("Sheet1");
|
||||
Sheet sheet2 = wb.createSheet("Sheet2");
|
||||
@ -788,7 +818,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public void testBaseZoom() {
|
||||
@Test
|
||||
public void baseZoom() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
@ -796,14 +827,15 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
sheet.setZoom(3,4);
|
||||
}
|
||||
|
||||
public void testBaseShowInPane() {
|
||||
@Test
|
||||
public void baseShowInPane() {
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
sheet.showInPane(2, 3);
|
||||
}
|
||||
|
||||
|
||||
public void testBug55723(){
|
||||
@Test
|
||||
public void bug55723(){
|
||||
Workbook wb = _testDataProvider.createWorkbook();
|
||||
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...
|
||||
}
|
||||
|
||||
public void testBug55723_Rows() {
|
||||
@Test
|
||||
public void bug55723_Rows() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
@ -827,8 +860,8 @@ public abstract class BaseTestSheet extends TestCase {
|
||||
assertNotNull(filter);
|
||||
}
|
||||
|
||||
|
||||
public void testBug55723d_RowsOver65k() {
|
||||
@Test
|
||||
public void bug55723d_RowsOver65k() {
|
||||
HSSFWorkbook wb = new HSSFWorkbook();
|
||||
Sheet sheet = wb.createSheet();
|
||||
|
||||
|
BIN
test-data/spreadsheet/51585.xlsx
Normal file
BIN
test-data/spreadsheet/51585.xlsx
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user