Fix Javadocs

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1888939 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andreas Beeker 2021-04-18 23:15:45 +00:00
parent 27e0842bcc
commit 32c2de2325
25 changed files with 276 additions and 327 deletions

View File

@ -85,10 +85,12 @@ public class DeferredSXSSFWorkbook extends SXSSFWorkbook {
return sxSheet;
}
@Override
public DeferredSXSSFSheet createSheet() {
return (DeferredSXSSFSheet) super.createSheet();
}
@Override
public DeferredSXSSFSheet createSheet(String sheetname) {
return (DeferredSXSSFSheet) super.createSheet(sheetname);
}

View File

@ -427,11 +427,12 @@ public abstract class PAPAbstractType {
/**
* Border line style.
*
* @return One of
* @return One of <ul>
* <li>{@link #BRCL_SINGLE}
* <li>{@link #BRCL_THICK}
* <li>{@link #BRCL_DOUBLE}
* <li>{@link #BRCL_SHADOW}
* </ul>
*/
@Internal
public byte getBrcl()
@ -442,12 +443,12 @@ public abstract class PAPAbstractType {
/**
* Border line style.
*
* @param field_6_brcl
* One of
* @param field_6_brcl One of <ul>
* <li>{@link #BRCL_SINGLE}
* <li>{@link #BRCL_THICK}
* <li>{@link #BRCL_DOUBLE}
* <li>{@link #BRCL_SHADOW}
* </ul>
*/
@Internal
public void setBrcl( byte field_6_brcl )
@ -458,12 +459,13 @@ public abstract class PAPAbstractType {
/**
* Rectangle border codes.
*
* @return One of
* @return One of <ul>
* <li>{@link #BRCP_NONE}
* <li>{@link #BRCP_BORDER_ABOVE}
* <li>{@link #BRCP_BORDER_BELOW}
* <li>{@link #BRCP_BOX_AROUND}
* <li>{@link #BRCP_BAR_TO_LEFT_OF_PARAGRAPH}
* </ul>
*/
@Internal
public byte getBrcp()
@ -474,13 +476,13 @@ public abstract class PAPAbstractType {
/**
* Rectangle border codes.
*
* @param field_7_brcp
* One of
* @param field_7_brcp One of <ul>
* <li>{@link #BRCP_NONE}
* <li>{@link #BRCP_BORDER_ABOVE}
* <li>{@link #BRCP_BORDER_BELOW}
* <li>{@link #BRCP_BOX_AROUND}
* <li>{@link #BRCP_BAR_TO_LEFT_OF_PARAGRAPH}
* </ul>
*/
@Internal
public void setBrcp( byte field_7_brcp )
@ -870,9 +872,10 @@ public abstract class PAPAbstractType {
/**
* Minimum height is exact or auto.
*
* @return One of
* @return One of <ul>
* <li>{@link #FMINHEIGHT_EXACT}
* <li>{@link #FMINHEIGHT_AT_LEAST}
* </ul>
*/
@Internal
public boolean getFMinHeight()
@ -883,10 +886,10 @@ public abstract class PAPAbstractType {
/**
* Minimum height is exact or auto.
*
* @param field_27_fMinHeight
* One of
* @param field_27_fMinHeight One of <ul>
* <li>{@link #FMINHEIGHT_EXACT}
* <li>{@link #FMINHEIGHT_AT_LEAST}
* </ul>
*/
@Internal
public void setFMinHeight( boolean field_27_fMinHeight )
@ -1095,12 +1098,13 @@ public abstract class PAPAbstractType {
/**
* Get the wAlignFont field for the PAP record.
*
* @return One of
* @return One of <ul>
* <li>{@link #WALIGNFONT_HANGING}
* <li>{@link #WALIGNFONT_CENTERED}
* <li>{@link #WALIGNFONT_ROMAN}
* <li>{@link #WALIGNFONT_VARIABLE}
* <li>{@link #WALIGNFONT_AUTO}
* </ul>
*/
@Internal
public int getWAlignFont()
@ -1111,13 +1115,13 @@ public abstract class PAPAbstractType {
/**
* Set the wAlignFont field for the PAP record.
*
* @param field_39_wAlignFont
* One of
* @param field_39_wAlignFont One of <ul>
* <li>{@link #WALIGNFONT_HANGING}
* <li>{@link #WALIGNFONT_CENTERED}
* <li>{@link #WALIGNFONT_ROMAN}
* <li>{@link #WALIGNFONT_VARIABLE}
* <li>{@link #WALIGNFONT_AUTO}
* </ul>
*/
@Internal
public void setWAlignFont( int field_39_wAlignFont )

View File

@ -202,140 +202,80 @@ public abstract class SEPAbstractType {
public String toString()
{
StringBuilder builder = new StringBuilder();
builder.append("[SEP]\n");
builder.append(" .bkc = ");
builder.append(" (").append(getBkc()).append(" )\n");
builder.append(" .fTitlePage = ");
builder.append(" (").append(getFTitlePage()).append(" )\n");
builder.append(" .fAutoPgn = ");
builder.append(" (").append(getFAutoPgn()).append(" )\n");
builder.append(" .nfcPgn = ");
builder.append(" (").append(getNfcPgn()).append(" )\n");
builder.append(" .fUnlocked = ");
builder.append(" (").append(getFUnlocked()).append(" )\n");
builder.append(" .cnsPgn = ");
builder.append(" (").append(getCnsPgn()).append(" )\n");
builder.append(" .fPgnRestart = ");
builder.append(" (").append(getFPgnRestart()).append(" )\n");
builder.append(" .fEndNote = ");
builder.append(" (").append(getFEndNote()).append(" )\n");
builder.append(" .lnc = ");
builder.append(" (").append(getLnc()).append(" )\n");
builder.append(" .grpfIhdt = ");
builder.append(" (").append(getGrpfIhdt()).append(" )\n");
builder.append(" .nLnnMod = ");
builder.append(" (").append(getNLnnMod()).append(" )\n");
builder.append(" .dxaLnn = ");
builder.append(" (").append(getDxaLnn()).append(" )\n");
builder.append(" .dxaPgn = ");
builder.append(" (").append(getDxaPgn()).append(" )\n");
builder.append(" .dyaPgn = ");
builder.append(" (").append(getDyaPgn()).append(" )\n");
builder.append(" .fLBetween = ");
builder.append(" (").append(getFLBetween()).append(" )\n");
builder.append(" .vjc = ");
builder.append(" (").append(getVjc()).append(" )\n");
builder.append(" .dmBinFirst = ");
builder.append(" (").append(getDmBinFirst()).append(" )\n");
builder.append(" .dmBinOther = ");
builder.append(" (").append(getDmBinOther()).append(" )\n");
builder.append(" .dmPaperReq = ");
builder.append(" (").append(getDmPaperReq()).append(" )\n");
builder.append(" .brcTop = ");
builder.append(" (").append(getBrcTop()).append(" )\n");
builder.append(" .brcLeft = ");
builder.append(" (").append(getBrcLeft()).append(" )\n");
builder.append(" .brcBottom = ");
builder.append(" (").append(getBrcBottom()).append(" )\n");
builder.append(" .brcRight = ");
builder.append(" (").append(getBrcRight()).append(" )\n");
builder.append(" .fPropMark = ");
builder.append(" (").append(getFPropMark()).append(" )\n");
builder.append(" .ibstPropRMark = ");
builder.append(" (").append(getIbstPropRMark()).append(" )\n");
builder.append(" .dttmPropRMark = ");
builder.append(" (").append(getDttmPropRMark()).append(" )\n");
builder.append(" .dxtCharSpace = ");
builder.append(" (").append(getDxtCharSpace()).append(" )\n");
builder.append(" .dyaLinePitch = ");
builder.append(" (").append(getDyaLinePitch()).append(" )\n");
builder.append(" .clm = ");
builder.append(" (").append(getClm()).append(" )\n");
builder.append(" .unused2 = ");
builder.append(" (").append(getUnused2()).append(" )\n");
builder.append(" .dmOrientPage = ");
builder.append(" (").append(getDmOrientPage()).append(" )\n");
builder.append(" .iHeadingPgn = ");
builder.append(" (").append(getIHeadingPgn()).append(" )\n");
builder.append(" .pgnStart = ");
builder.append(" (").append(getPgnStart()).append(" )\n");
builder.append(" .lnnMin = ");
builder.append(" (").append(getLnnMin()).append(" )\n");
builder.append(" .wTextFlow = ");
builder.append(" (").append(getWTextFlow()).append(" )\n");
builder.append(" .unused3 = ");
builder.append(" (").append(getUnused3()).append(" )\n");
builder.append(" .pgbProp = ");
builder.append(" (").append(getPgbProp()).append(" )\n");
builder.append(" .unused4 = ");
builder.append(" (").append(getUnused4()).append(" )\n");
builder.append(" .xaPage = ");
builder.append(" (").append(getXaPage()).append(" )\n");
builder.append(" .yaPage = ");
builder.append(" (").append(getYaPage()).append(" )\n");
builder.append(" .xaPageNUp = ");
builder.append(" (").append(getXaPageNUp()).append(" )\n");
builder.append(" .yaPageNUp = ");
builder.append(" (").append(getYaPageNUp()).append(" )\n");
builder.append(" .dxaLeft = ");
builder.append(" (").append(getDxaLeft()).append(" )\n");
builder.append(" .dxaRight = ");
builder.append(" (").append(getDxaRight()).append(" )\n");
builder.append(" .dyaTop = ");
builder.append(" (").append(getDyaTop()).append(" )\n");
builder.append(" .dyaBottom = ");
builder.append(" (").append(getDyaBottom()).append(" )\n");
builder.append(" .dzaGutter = ");
builder.append(" (").append(getDzaGutter()).append(" )\n");
builder.append(" .dyaHdrTop = ");
builder.append(" (").append(getDyaHdrTop()).append(" )\n");
builder.append(" .dyaHdrBottom = ");
builder.append(" (").append(getDyaHdrBottom()).append(" )\n");
builder.append(" .ccolM1 = ");
builder.append(" (").append(getCcolM1()).append(" )\n");
builder.append(" .fEvenlySpaced = ");
builder.append(" (").append(getFEvenlySpaced()).append(" )\n");
builder.append(" .unused5 = ");
builder.append(" (").append(getUnused5()).append(" )\n");
builder.append(" .dxaColumns = ");
builder.append(" (").append(getDxaColumns()).append(" )\n");
builder.append(" .rgdxaColumn = ");
builder.append(" (").append(Arrays.toString(getRgdxaColumn())).append(" )\n");
builder.append(" .dxaColumnWidth = ");
builder.append(" (").append(getDxaColumnWidth()).append(" )\n");
builder.append(" .dmOrientFirst = ");
builder.append(" (").append(getDmOrientFirst()).append(" )\n");
builder.append(" .fLayout = ");
builder.append(" (").append(getFLayout()).append(" )\n");
builder.append(" .unused6 = ");
builder.append(" (").append(getUnused6()).append(" )\n");
builder.append(" .olstAnm = ");
builder.append(" (").append(Arrays.toString(getOlstAnm())).append(" )\n");
builder.append("[/SEP]\n");
return builder.toString();
return "[SEP]\n" +
" .bkc = (" + getBkc() + " )\n" +
" .fTitlePage = (" + getFTitlePage() + " )\n" +
" .fAutoPgn = (" + getFAutoPgn() + " )\n" +
" .nfcPgn = (" + getNfcPgn() + " )\n" +
" .fUnlocked = (" + getFUnlocked() + " )\n" +
" .cnsPgn = (" + getCnsPgn() + " )\n" +
" .fPgnRestart = (" + getFPgnRestart() + " )\n" +
" .fEndNote = (" + getFEndNote() + " )\n" +
" .lnc = (" + getLnc() + " )\n" +
" .grpfIhdt = (" + getGrpfIhdt() + " )\n" +
" .nLnnMod = (" + getNLnnMod() + " )\n" +
" .dxaLnn = (" + getDxaLnn() + " )\n" +
" .dxaPgn = (" + getDxaPgn() + " )\n" +
" .dyaPgn = (" + getDyaPgn() + " )\n" +
" .fLBetween = (" + getFLBetween() + " )\n" +
" .vjc = (" + getVjc() + " )\n" +
" .dmBinFirst = (" + getDmBinFirst() + " )\n" +
" .dmBinOther = (" + getDmBinOther() + " )\n" +
" .dmPaperReq = (" + getDmPaperReq() + " )\n" +
" .brcTop = (" + getBrcTop() + " )\n" +
" .brcLeft = (" + getBrcLeft() + " )\n" +
" .brcBottom = (" + getBrcBottom() + " )\n" +
" .brcRight = (" + getBrcRight() + " )\n" +
" .fPropMark = (" + getFPropMark() + " )\n" +
" .ibstPropRMark = (" + getIbstPropRMark() + " )\n" +
" .dttmPropRMark = (" + getDttmPropRMark() + " )\n" +
" .dxtCharSpace = (" + getDxtCharSpace() + " )\n" +
" .dyaLinePitch = (" + getDyaLinePitch() + " )\n" +
" .clm = (" + getClm() + " )\n" +
" .unused2 = (" + getUnused2() + " )\n" +
" .dmOrientPage = (" + getDmOrientPage() + " )\n" +
" .iHeadingPgn = (" + getIHeadingPgn() + " )\n" +
" .pgnStart = (" + getPgnStart() + " )\n" +
" .lnnMin = (" + getLnnMin() + " )\n" +
" .wTextFlow = (" + getWTextFlow() + " )\n" +
" .unused3 = (" + getUnused3() + " )\n" +
" .pgbProp = (" + getPgbProp() + " )\n" +
" .unused4 = (" + getUnused4() + " )\n" +
" .xaPage = (" + getXaPage() + " )\n" +
" .yaPage = (" + getYaPage() + " )\n" +
" .xaPageNUp = (" + getXaPageNUp() + " )\n" +
" .yaPageNUp = (" + getYaPageNUp() + " )\n" +
" .dxaLeft = (" + getDxaLeft() + " )\n" +
" .dxaRight = (" + getDxaRight() + " )\n" +
" .dyaTop = (" + getDyaTop() + " )\n" +
" .dyaBottom = (" + getDyaBottom() + " )\n" +
" .dzaGutter = (" + getDzaGutter() + " )\n" +
" .dyaHdrTop = (" + getDyaHdrTop() + " )\n" +
" .dyaHdrBottom = (" + getDyaHdrBottom() + " )\n" +
" .ccolM1 = (" + getCcolM1() + " )\n" +
" .fEvenlySpaced = (" + getFEvenlySpaced() + " )\n" +
" .unused5 = (" + getUnused5() + " )\n" +
" .dxaColumns = (" + getDxaColumns() + " )\n" +
" .rgdxaColumn = (" + Arrays.toString(getRgdxaColumn()) + " )\n" +
" .dxaColumnWidth = (" + getDxaColumnWidth() + " )\n" +
" .dmOrientFirst = (" + getDmOrientFirst() + " )\n" +
" .fLayout = (" + getFLayout() + " )\n" +
" .unused6 = (" + getUnused6() + " )\n" +
" .olstAnm = (" + Arrays.toString(getOlstAnm()) + " )\n" +
"[/SEP]\n";
}
/**
* Break code.
*
* @return One of
* @return One of <ul>
* <li>{@link #BKC_NO_BREAK}
* <li>{@link #BKC_NEW_COLUMN}
* <li>{@link #BKC_NEW_PAGE}
* <li>{@link #BKC_EVEN_PAGE}
* <li>{@link #BKC_ODD_PAGE}
* </ul>
*/
public byte getBkc()
{
@ -345,13 +285,13 @@ public abstract class SEPAbstractType {
/**
* Break code.
*
* @param field_1_bkc
* One of
* @param field_1_bkc One of <ul>
* <li>{@link #BKC_NO_BREAK}
* <li>{@link #BKC_NEW_COLUMN}
* <li>{@link #BKC_NEW_PAGE}
* <li>{@link #BKC_EVEN_PAGE}
* <li>{@link #BKC_ODD_PAGE}
* </ul>
*/
public void setBkc(byte field_1_bkc)
{
@ -393,12 +333,13 @@ public abstract class SEPAbstractType {
/**
* Page number format code.
*
* @return One of
* @return One of <ul>
* <li>{@link #NFCPGN_ARABIC}
* <li>{@link #NFCPGN_ROMAN_UPPER_CASE}
* <li>{@link #NFCPGN_ROMAN_LOWER_CASE}
* <li>{@link #NFCPGN_LETTER_UPPER_CASE}
* <li>{@link #NFCPGN_LETTER_LOWER_CASE}
* </ul>
*/
public byte getNfcPgn()
{
@ -408,13 +349,13 @@ public abstract class SEPAbstractType {
/**
* Page number format code.
*
* @param field_4_nfcPgn
* One of
* @param field_4_nfcPgn One of <ul>
* <li>{@link #NFCPGN_ARABIC}
* <li>{@link #NFCPGN_ROMAN_UPPER_CASE}
* <li>{@link #NFCPGN_ROMAN_LOWER_CASE}
* <li>{@link #NFCPGN_LETTER_UPPER_CASE}
* <li>{@link #NFCPGN_LETTER_LOWER_CASE}
* </ul>
*/
public void setNfcPgn(byte field_4_nfcPgn)
{
@ -840,9 +781,10 @@ public abstract class SEPAbstractType {
/**
* Get the dmOrientPage field for the SEP record.
*
* @return One of
* @return One of <ul>
* <li>{@link #DMORIENTPAGE_LANDSCAPE}
* <li>{@link #DMORIENTPAGE_PORTRAIT}
* </ul>
*/
public boolean getDmOrientPage()
{
@ -852,10 +794,10 @@ public abstract class SEPAbstractType {
/**
* Set the dmOrientPage field for the SEP record.
*
* @param field_31_dmOrientPage
* One of
* @param field_31_dmOrientPage One of <ul>
* <li>{@link #DMORIENTPAGE_LANDSCAPE}
* <li>{@link #DMORIENTPAGE_PORTRAIT}
* </ul>
*/
public void setDmOrientPage(boolean field_31_dmOrientPage)
{

View File

@ -56,7 +56,7 @@ public final class ExtractorFactory {
/**
* Some OPCPackages are packed in side an OLE2 container.
* If encrypted, the {@link DirectoryNode} is called {@link Decryptor#DEFAULT_POIFS_ENTRY "EncryptedPackage"},
* otherwise the node is called "Packge"
* otherwise the node is called "Package"
*/
public static final String OOXML_PACKAGE = "Package";

View File

@ -40,26 +40,24 @@ import org.apache.poi.util.LocaleUtil;
* prefix or suffix.
* </p>
* <p>
* For example the Excel pattern <code>"$#,##0.00 "USD"_);($#,##0.00 "USD")"
* </code> will be correctly formatted as "$1,000.00 USD" or "($1,000.00 USD)".
* However the pattern <code>"00-00-00"</code> is incorrectly formatted by
* For example the Excel pattern {@code "$#,##0.00 "USD"_);($#,##0.00 "USD")"
* } will be correctly formatted as "$1,000.00 USD" or "($1,000.00 USD)".
* However the pattern {@code "00-00-00"} is incorrectly formatted by
* DecimalFormat as "000000--". For Excel formats that are not compatible with
* DecimalFormat, you can provide your own custom {@link Format} implementation
* via <code>HSSFDataFormatter.addFormat(String,Format)</code>. The following
* via {@code HSSFDataFormatter.addFormat(String,Format)}. The following
* custom formats are already provided by this class:
* </p>
* <pre>
* <ul><li>SSN "000-00-0000"</li>
* <li>Phone Number "(###) ###-####"</li>
* <li>Zip plus 4 "00000-0000"</li>
* </ul>
* </pre>
* <p>
* If the Excel format pattern cannot be parsed successfully, then a default
* format will be used. The default number format will mimic the Excel General
* format: "#" for whole numbers and "#.##########" for decimal numbers. You
* can override the default format pattern with <code>
* HSSFDataFormatter.setDefaultNumberFormat(Format)</code>. <b>Note:</b> the
* can override the default format pattern with {@code
* HSSFDataFormatter.setDefaultNumberFormat(Format)}. <b>Note:</b> the
* default format will only be used when a Format cannot be created from the
* cell's data format string.
*/

View File

@ -868,7 +868,6 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
* Note that Excel allows sheet names up to 31 chars in length but other applications
* (such as OpenOffice) allow more. Some versions of Excel crash with names longer than 31 chars,
* others - truncate such names to 31 character.
* </p>
* <p>
* POI's SpreadsheetAPI silently truncates the input argument to 31 characters.
* Example:
@ -878,7 +877,6 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
* assert 31 == sheet.getSheetName().length();
* assert "My very long sheet name which i" == sheet.getSheetName();
* }</pre>
* </p>
* <p>
* Except the 31-character constraint, Excel applies some other rules:
* <p>
@ -895,7 +893,6 @@ public final class HSSFWorkbook extends POIDocument implements Workbook {
* <li> closing square bracket (]) </li>
* </ul>
* The string MUST NOT begin or end with the single quote (') character.
* </p>
*
* @param sheetname sheetname to set for the sheet.
* @return Sheet representing the new sheet.

View File

@ -83,16 +83,16 @@ import org.apache.poi.util.Internal;
/**
* This class parses a formula string into a List of tokens in RPN order.
* Inspired by
* Lets Build a Compiler, by Jack Crenshaw
* Inspired by "Lets Build a Compiler" by Jack Crenshaw
* BNF for the formula expression is :
* <pre>{@code
* <expression> ::= <term> [<addop> <term>]*
* <term> ::= <factor> [ <mulop> <factor> ]*
* <factor> ::= <number> | (<expression>) | <cellRef> | <function>
* <function> ::= <functionName> ([expression [, expression]*])
* }</pre>
* <p>
* For POI internal use only
* <p>
*/
@Internal
public final class FormulaParser {
@ -158,7 +158,7 @@ public final class FormulaParser {
* @param workbook the parent workbook
* @param formulaType the type of the formula
* @param sheetIndex the 0-based index of the sheet this formula belongs to.
* The sheet index is required to resolve sheet-level names. <code>-1</code> means that
* The sheet index is required to resolve sheet-level names. {@code -1} means that
* the scope of the name will be ignored and the parser will match names only by name
* @param rowIndex - the related cell's row index in 0-based form (-1 if the formula is not cell related)
* used to handle structured references that have the "#This Row" quantifier.
@ -183,7 +183,7 @@ public final class FormulaParser {
* @param workbook the parent workbook
* @param formulaType the type of the formula
* @param sheetIndex the 0-based index of the sheet this formula belongs to.
* The sheet index is required to resolve sheet-level names. <code>-1</code> means that
* The sheet index is required to resolve sheet-level names. {@code -1} means that
* the scope of the name will be ignored and the parser will match names only by name
*
* @return array of parsed tokens
@ -210,10 +210,10 @@ public final class FormulaParser {
}
return (Area3DPxg) arr[0];
}
/** Read New Character From Input Stream */
private void GetChar() {
// The intersection operator is a space. We track whether the run of
// The intersection operator is a space. We track whether the run of
// whitespace preceding "look" counts as an intersection operator.
if (IsWhite(look)) {
if (look == ' ') {
@ -223,7 +223,7 @@ public final class FormulaParser {
else {
_inIntersection = false;
}
// Check to see if we've walked off the end of the string.
if (_pointer > _formulaLength) {
throw new RuntimeException("Parsed past the end of the formula, pos: " + _pointer +
@ -382,9 +382,6 @@ public final class FormulaParser {
}
return false;
}
if (token instanceof OperandPtg) {
return false;
}
return false;
}
@ -401,7 +398,7 @@ public final class FormulaParser {
}
/**
* @return <code>false</code> if sub-expression represented the specified ParseNode definitely
* @return {@code false} if sub-expression represented the specified ParseNode definitely
* cannot appear on either side of the range (':') operator
*/
private static boolean isValidRangeOperand(ParseNode a) {
@ -432,12 +429,8 @@ public final class FormulaParser {
}
// one special case of ScalarConstantPtg
if (tkn == ErrPtg.REF_INVALID) {
return true;
}
// All other ControlPtgs and ScalarConstantPtgs cannot be used with ':'
return false;
return tkn == ErrPtg.REF_INVALID;
}
/**
@ -470,7 +463,7 @@ public final class FormulaParser {
SkipWhite();
int savePointer = _pointer;
SheetIdentifier sheetIden = parseSheetName();
if (sheetIden == null) {
resetPointer(savePointer);
} else {
@ -482,7 +475,7 @@ public final class FormulaParser {
if (part1 == null) {
if (sheetIden != null) {
if(look == '#'){ // error ref like MySheet!#REF!
return new ParseNode(ErrPtg.valueOf(parseErrorLiteral()));
return new ParseNode(ErrPtg.valueOf(parseErrorLiteral()));
} else {
// Is it a named range?
String name = parseAsName();
@ -587,13 +580,13 @@ public final class FormulaParser {
}
private static final String specHeaders = "Headers";
private static final String specAll = "All";
private static final String specData = "Data";
private static final String specTotals = "Totals";
private static final String specThisRow = "This Row";
/**
* Parses a structured reference, returns it as area reference.
* Examples:
@ -617,11 +610,10 @@ public final class FormulaParser {
* Table1[[#This Row], [col1]]
* Table1[ [col1]:[col2] ]
* </pre>
* @param tableName
* @return Area Reference for the given table
*/
private ParseNode parseStructuredReference(String tableName) {
if ( ! (_ssVersion.equals(SpreadsheetVersion.EXCEL2007)) ) {
throw new FormulaParseException("Structured references work only on XSSF (Excel 2007+)!");
}
@ -630,17 +622,17 @@ public final class FormulaParser {
throw new FormulaParseException("Illegal table name: '" + tableName + "'");
}
String sheetName = tbl.getSheetName();
int startCol = tbl.getStartColIndex();
int endCol = tbl.getEndColIndex();
int startRow = tbl.getStartRowIndex();
int endRow = tbl.getEndRowIndex();
// Do NOT return before done reading all the structured reference tokens from the input stream.
// Throwing exceptions is okay.
int savePtr0 = _pointer;
GetChar();
boolean isTotalsSpec = false;
boolean isThisRowSpec = false;
boolean isDataSpec = false;
@ -707,7 +699,7 @@ public final class FormulaParser {
}
}
}
if(nColQuantifiers == 0 && nSpecQuantifiers == 0){
resetPointer(savePtr0);
savePtr0 = _pointer;
@ -757,15 +749,15 @@ public final class FormulaParser {
return new ParseNode(ErrPtg.VALUE_INVALID);
} else {
throw new FormulaParseException(
"Formula contained [#This Row] or [@] structured reference but this row < 0. " +
"Formula contained [#This Row] or [@] structured reference but this row < 0. " +
"Row index must be specified for row-referencing structured references.");
}
}
int actualStartRow = startRow;
int actualEndRow = endRow;
int actualStartCol = startCol;
int actualEndCol = endCol;
int actualEndCol = endCol;
if (nSpecQuantifiers > 0) {
//Selecting rows
if (nSpecQuantifiers == 1 && isAllSpec) {
@ -787,14 +779,14 @@ public final class FormulaParser {
actualStartRow = actualEndRow;
} else if ((nSpecQuantifiers == 1 && isThisRowSpec) || isThisRow) {
actualStartRow = _rowIndex; //The rowNum is 0 based
actualEndRow = _rowIndex;
actualEndRow = _rowIndex;
} else {
throw new FormulaParseException("The formula "+ _formulaString + " is illegal");
}
} else {
if (isThisRow) { // there is a @
actualStartRow = _rowIndex; //The rowNum is 0 based
actualEndRow = _rowIndex;
actualEndRow = _rowIndex;
} else { // Really no special quantifiers
actualStartRow++;
if (tbl.getTotalsRowCount() > 0) actualEndRow--;
@ -810,11 +802,11 @@ public final class FormulaParser {
int startIdx = tbl.findColumnIndex(startColumnName);
int endIdx = tbl.findColumnIndex(endColumnName);
if (startIdx == -1 || endIdx == -1) {
throw new FormulaParseException("One of the columns "+ startColumnName +", "+ endColumnName +" doesn't exist in table "+ tbl.getName());
}
throw new FormulaParseException("One of the columns "+ startColumnName +", "+ endColumnName +" doesn't exist in table "+ tbl.getName());
}
actualStartCol = startCol+ startIdx;
actualEndCol = startCol + endIdx;
} else if (nColQuantifiers == 1 && !isThisRow) {
if (startColumnName == null) {
throw new IllegalStateException("Fatal error");
@ -832,7 +824,7 @@ public final class FormulaParser {
Ptg ptg = _book.get3DReferencePtg(new AreaReference(topLeft, bottomRight, _ssVersion), sheetIden);
return new ParseNode(ptg);
}
/**
* Tries to parse the next as column - can contain whitespace
* Caller should save pointer.
@ -855,7 +847,7 @@ public final class FormulaParser {
}
Match(']');
return name.toString();
}
}
/**
* Tries to parse the next as special quantifier
* Caller should save pointer.
@ -899,7 +891,7 @@ public final class FormulaParser {
if (look == '"') {
return new ParseNode(new StringPtg(parseStringLiteral()));
}
// from now on we can only be dealing with non-quoted identifiers
// which will either be named ranges or functions
String name = parseAsName();
@ -929,7 +921,7 @@ public final class FormulaParser {
throw new FormulaParseException("Specified name '"
+ name + "' is not a range as expected.");
}
private String parseAsName() {
StringBuilder sb = new StringBuilder();
@ -948,7 +940,7 @@ public final class FormulaParser {
/**
* @param ch unicode codepoint
* @return <code>true</code> if the specified character may be used in a defined name
* @return {@code true} if the specified character may be used in a defined name
*/
private static boolean isValidDefinedNameChar(int ch) {
if (Character.isLetterOrDigit(ch)) {
@ -969,12 +961,11 @@ public final class FormulaParser {
// includes special non-name control characters like ! $ : , ( ) [ ] and space
return false;
}
/**
*
* @param sheetIden may be <code>null</code>
* @param part1
* @param part2 may be <code>null</code>
* @param sheetIden may be {@code null}
* @param part2 may be {@code null}
*/
private ParseNode createAreaRefParseNode(SheetIdentifier sheetIden, SimpleRangePart part1,
SimpleRangePart part2) throws FormulaParseException {
@ -1015,14 +1006,14 @@ public final class FormulaParser {
/**
* Matches a zero or one letter-runs followed by zero or one digit-runs.
* Either or both runs man optionally be prefixed with a single '$'.
* (copied+modified from {@link CellReference#CELL_REF_PATTERN})
* (copied+modified from CellReference.CELL_REF_PATTERN)
*/
private static final Pattern CELL_REF_PATTERN = Pattern.compile("(\\$?[A-Za-z]+)?(\\$?[0-9]+)?");
/**
* Parses out a potential LHS or RHS of a ':' intended to produce a plain AreaRef. Normally these are
* proper cell references but they could also be row or column refs like "$AC" or "10"
* @return <code>null</code> (and leaves {@link #_pointer} unchanged if a proper range part does not parse out
* @return {@code null} (and leaves {@link #_pointer} unchanged if a proper range part does not parse out
*/
private SimpleRangePart parseSimpleRangePart() {
int ptr = _pointer-1; // TODO avoid StringIndexOutOfBounds
@ -1132,9 +1123,9 @@ public final class FormulaParser {
}
/**
* @return <code>true</code> if the two range parts can be combined in an
* @return {@code true} if the two range parts can be combined in an
* {@link AreaPtg} ( Note - the explicit range operator (:) may still be valid
* when this method returns <code>false</code> )
* when this method returns {@code false} )
*/
public boolean isCompatibleForArea(SimpleRangePart part2) {
return _type == part2._type;
@ -1145,7 +1136,7 @@ public final class FormulaParser {
return getClass().getName() + " [" + _rep + "]";
}
}
private String getBookName() {
StringBuilder sb = new StringBuilder();
GetChar();
@ -1158,8 +1149,8 @@ public final class FormulaParser {
}
/**
* Note - caller should reset {@link #_pointer} upon <code>null</code> result
* @return The sheet name as an identifier <code>null</code> if '!' is not found in the right place
* Note - caller should reset {@link #_pointer} upon {@code null} result
* @return The sheet name as an identifier {@code null} if '!' is not found in the right place
*/
private SheetIdentifier parseSheetName() {
String bookName;
@ -1171,10 +1162,10 @@ public final class FormulaParser {
if (look == '\'') {
Match('\'');
if (look == '[')
bookName = getBookName();
StringBuilder sb = new StringBuilder();
boolean done = look == '\'';
while(!done) {
@ -1228,9 +1219,9 @@ public final class FormulaParser {
}
return null;
}
/**
* If we have something that looks like [book]Sheet1: or
* If we have something that looks like [book]Sheet1: or
* Sheet1, see if it's actually a range eg Sheet1:Sheet2!
*/
private SheetIdentifier parseSheetRange(String bookname, NameIdentifier sheet1Name) {
@ -1264,7 +1255,7 @@ public final class FormulaParser {
}
/**
* @return <code>true</code> if the specified name is a valid cell reference
* @return {@code true} if the specified name is a valid cell reference
*/
private boolean isValidCellReference(String str) {
//check range bounds against grid max
@ -1297,7 +1288,7 @@ public final class FormulaParser {
* Note - Excel function names are 'case aware but not case sensitive'. This method may end
* up creating a defined name record in the workbook if the specified name is not an internal
* Excel function, and has not been encountered before.
*
*
* Side effect: creates workbook name if name is not recognized (name is probably a UDF)
*
* @param name case preserved function name (as it was entered/appeared in the formula).
@ -1319,7 +1310,7 @@ public final class FormulaParser {
throw new FormulaParseException("Attempt to use name '" + name
+ "' as a function, but defined name in workbook does not refer to a function");
}
// calls to user-defined functions within the workbook
// get a Name token which points to a defined name record
nameToken = hName.createPtg();
@ -1354,7 +1345,7 @@ public final class FormulaParser {
return getFunction(name, nameToken, args);
}
/**
* Adds a name (named range or user defined function) to underlying workbook's names table
*/
@ -1369,7 +1360,7 @@ public final class FormulaParser {
* Generates the variable function ptg for the formula.
* <p>
* For IF Formulas, additional PTGs are added to the tokens
* @param name a {@link NamePtg} or {@link NameXPtg} or <code>null</code>
* @param name a {@link NamePtg} or {@link NameXPtg} or {@code null}
* @return Ptg a null is returned if we're in an IF formula, it needs extreme manipulation and is handled in this function
*/
private ParseNode getFunction(String name, Ptg namePtg, ParseNode[] args) {
@ -1678,7 +1669,7 @@ public final class FormulaParser {
if (!isPositive) {
value = -value;
}
return Double.valueOf(value);
return value;
}
private Ptg parseNumber() {
@ -1930,7 +1921,7 @@ public final class FormulaParser {
return result;
}
}
private ParseNode comparisonExpression() {
ParseNode result = concatExpression();
while (true) {

View File

@ -40,7 +40,8 @@ import org.apache.poi.ss.util.DateParser;
*
* The <b>basis</b> optionally specifies the behaviour of YEARFRAC as follows:
*
* <table border="0" cellpadding="1" cellspacing="0" summary="basis parameter description">
* <table>
* <caption>basis parameter description</caption>
* <tr><th>Value</th><th>Days per Month</th><th>Days per Year</th></tr>
* <tr align='center'><td>0 (default)</td><td>30</td><td>360</td></tr>
* <tr align='center'><td>1</td><td>actual</td><td>actual</td></tr>
@ -58,6 +59,7 @@ final class YearFrac implements FreeRefFunction {
// enforce singleton
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
int srcCellRow = ec.getRowIndex();
int srcCellCol = ec.getColumnIndex();
@ -90,7 +92,7 @@ final class YearFrac implements FreeRefFunction {
String strVal = ((StringEval) ve).getStringValue();
Double dVal = OperandResolver.parseDouble(strVal);
if (dVal != null) {
return dVal.doubleValue();
return dVal;
}
LocalDate date = DateParser.parseLocalDate(strVal);
return DateUtil.getExcelDate(date, false);

View File

@ -111,7 +111,8 @@ public final class OperandResolver {
* area depending on the coordinates of the calling cell. Here is an example demonstrating
* both selection from a single row area and a single column area in the same formula.
*
* <table border="1" cellpadding="1" cellspacing="1" summary="sample spreadsheet">
* <table>
* <caption>sample spreadsheet</caption>
* <tr><th>&nbsp;</th><th>&nbsp;A&nbsp;</th><th>&nbsp;B&nbsp;</th><th>&nbsp;C&nbsp;</th><th>&nbsp;D&nbsp;</th></tr>
* <tr><th>1</th><td>15</td><td>20</td><td>25</td><td>&nbsp;</td></tr>
* <tr><th>2</th><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td><td>200</td></tr>
@ -122,7 +123,8 @@ public final class OperandResolver {
* If the formula "=1000+A1:B1+D2:D3" is put into the 9 cells from A2 to C4, the spreadsheet
* will look like this:
*
* <table border="1" cellpadding="1" cellspacing="1" summary="sample spreadsheet">
* <table>
* <caption>sample spreadsheet</caption>
* <tr><th>&nbsp;</th><th>&nbsp;A&nbsp;</th><th>&nbsp;B&nbsp;</th><th>&nbsp;C&nbsp;</th><th>&nbsp;D&nbsp;</th></tr>
* <tr><th>1</th><td>15</td><td>20</td><td>25</td><td>&nbsp;</td></tr>
* <tr><th>2</th><td>1215</td><td>1220</td><td>#VALUE!</td><td>200</td></tr>

View File

@ -25,13 +25,15 @@ import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate;
* Implementation for the function COUNTBLANK
* <p>
* Syntax: COUNTBLANK ( range )
* <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><th>range&nbsp;&nbsp;&nbsp;</th><td>is the range of cells to count blanks</td></tr>
* </table>
* </p>
*/
public final class Countblank extends Fixed1ArgFunction {
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0) {
double result;
@ -45,14 +47,11 @@ public final class Countblank extends Fixed1ArgFunction {
return new NumberEval(result);
}
private static final I_MatchPredicate predicate = new I_MatchPredicate() {
public boolean matches(ValueEval valueEval) {
// Note - only BlankEval counts
return valueEval == BlankEval.instance ||
// see https://support.office.com/en-us/article/COUNTBLANK-function-6a92d772-675c-4bee-b346-24af6bd3ac22
// "Cells with formulas that return "" (empty text) are also counted."
(valueEval instanceof StringEval && ((StringEval)valueEval).getStringValue().isEmpty());
}
private static final I_MatchPredicate predicate = valueEval -> {
// Note - only BlankEval counts
return valueEval == BlankEval.instance ||
// see https://support.office.com/en-us/article/COUNTBLANK-function-6a92d772-675c-4bee-b346-24af6bd3ac22
// "Cells with formulas that return "" (empty text) are also counted."
(valueEval instanceof StringEval && ((StringEval)valueEval).getStringValue().isEmpty());
};
}

View File

@ -36,11 +36,11 @@ import org.apache.poi.ss.usermodel.FormulaError;
* Implementation for the function COUNTIF
* <p>
* Syntax: COUNTIF ( range, criteria )
* <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><th>range&nbsp;&nbsp;&nbsp;</th><td>is the range of cells to be counted based on the criteria</td></tr>
* <tr><th>criteria</th><td>is used to determine which cells to count</td></tr>
* </table>
* </p>
*/
public final class Countif extends Fixed2ArgFunction {
@ -138,10 +138,7 @@ public final class Countif extends Fixed2ArgFunction {
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder(64);
sb.append(getClass().getName());
sb.append(" [").append(_representation).append("]");
return sb.toString();
return getClass().getName() + " [" + _representation + "]";
}
public String getRepresentation() {
return _representation;
@ -208,7 +205,7 @@ public final class Countif extends Fixed2ArgFunction {
// x is text that is not a number
return false;
}
return _value == val.doubleValue();
return _value == val;
} else if((x instanceof NumberEval)) {
NumberEval ne = (NumberEval) x;
testValue = ne.getNumberValue();
@ -304,7 +301,7 @@ public final class Countif extends Fixed2ArgFunction {
}
return false;
}
public int getValue() {
return _value;
}
@ -377,7 +374,7 @@ public final class Countif extends Fixed2ArgFunction {
}
/**
* Translates Excel countif wildcard strings into java regex strings
* @return <code>null</code> if the specified value contains no special wildcard characters.
* @return {@code null} if the specified value contains no special wildcard characters.
*/
public static Pattern getWildCardPattern(String value) {
int len = value.length();
@ -458,7 +455,7 @@ public final class Countif extends Fixed2ArgFunction {
/**
* Creates a criteria predicate object for the supplied criteria arg
* @return <code>null</code> if the arg evaluates to blank.
* @return {@code null} if the arg evaluates to blank.
*/
/* package */ static I_MatchPredicate createCriteriaPredicate(ValueEval arg, int srcRowIndex, int srcColumnIndex) {
@ -505,12 +502,12 @@ public final class Countif extends Fixed2ArgFunction {
Boolean booleanVal = parseBoolean(value);
if(booleanVal != null) {
return new BooleanMatcher(booleanVal.booleanValue(), operator);
return new BooleanMatcher(booleanVal, operator);
}
Double doubleVal = OperandResolver.parseDouble(value);
if(doubleVal != null) {
return new NumberMatcher(doubleVal.doubleValue(), operator);
return new NumberMatcher(doubleVal, operator);
}
ErrorEval ee = parseError(value);
if (ee != null) {
@ -550,7 +547,7 @@ public final class Countif extends Fixed2ArgFunction {
}
/**
* Boolean literals ('TRUE', 'FALSE') treated similarly but NOT same as numbers.
* @return <code>null</code> to represent blank values
* @return {@code null} to represent blank values
*/
/* package */ static Boolean parseBoolean(String strRep) {
if (strRep.length() < 1) {

View File

@ -31,7 +31,8 @@ import org.apache.poi.ss.usermodel.FormulaError;
* <b>ERROR.TYPE</b>(<b>errorValue</b>)</p>
* <p>
* Returns a number corresponding to the error type of the supplied argument.
* <table border="1" cellpadding="1" cellspacing="1" summary="Return values for ERROR.TYPE()">
* <table>
* <caption>Return values for ERROR.TYPE()</caption>
* <tr><td>errorValue</td><td>Return Value</td></tr>
* <tr><td>#NULL!</td><td>1</td></tr>
* <tr><td>#DIV/0!</td><td>2</td></tr>

View File

@ -33,7 +33,8 @@ import org.apache.poi.ss.formula.TwoDEval;
* Syntax : <p>
* INDEX ( reference, row_num[, column_num [, area_num]])<p>
* INDEX ( array, row_num[, column_num])
* <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><th>reference</th><td>typically an area reference, possibly a union of areas</td></tr>
* <tr><th>array</th><td>a literal array value (currently not supported)</td></tr>
* <tr><th>row_num</th><td>selects the row within the array or area reference</td></tr>
@ -43,6 +44,7 @@ import org.apache.poi.ss.formula.TwoDEval;
*/
public final class Index implements Function2Arg, Function3Arg, Function4Arg, ArrayMode {
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
TwoDEval reference = convertFirstArg(arg0);
@ -67,6 +69,7 @@ public final class Index implements Function2Arg, Function3Arg, Function4Arg, Ar
return e.getErrorEval();
}
}
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
ValueEval arg2) {
TwoDEval reference = convertFirstArg(arg0);
@ -79,6 +82,7 @@ public final class Index implements Function2Arg, Function3Arg, Function4Arg, Ar
return e.getErrorEval();
}
}
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
ValueEval arg2, ValueEval arg3) {
throw new RuntimeException("Incomplete code"
@ -104,6 +108,7 @@ public final class Index implements Function2Arg, Function3Arg, Function4Arg, Ar
}
@Override
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
switch (args.length) {
case 2:

View File

@ -35,7 +35,7 @@ import org.apache.poi.ss.usermodel.Table;
*
* INDIRECT() returns the cell or area reference denoted by the text argument.<p>
*
* <b>Syntax</b>:</br>
* <b>Syntax</b>:<br>
* <b>INDIRECT</b>(<b>ref_text</b>,isA1Style)<p>
*
* <b>ref_text</b> a string representation of the desired reference as it would
@ -51,6 +51,7 @@ public final class Indirect implements FreeRefFunction {
// enforce singleton
}
@Override
public ValueEval evaluate(ValueEval[] args, OperationEvaluationContext ec) {
if (args.length < 1) {
return ErrorEval.VALUE_INVALID;
@ -88,7 +89,7 @@ public final class Indirect implements FreeRefFunction {
}
// numeric quantities follow standard boolean conversion rules
// for strings, only "TRUE" and "FALSE" (case insensitive) are valid
return OperandResolver.coerceValueToBoolean(ve, false).booleanValue();
return OperandResolver.coerceValueToBoolean(ve, false);
}
private static ValueEval evaluateIndirect(final OperationEvaluationContext ec, String text,
@ -116,7 +117,7 @@ public final class Indirect implements FreeRefFunction {
if (Table.isStructuredReference.matcher(refText).matches()) {
// The argument is structured reference
Area3DPxg areaPtg = null;
Area3DPxg areaPtg;
try {
areaPtg = FormulaParser.parseStructuredReference(refText, (FormulaParsingWorkbook) ec.getWorkbook(), ec.getRowIndex());
} catch (FormulaParseException e) {
@ -142,7 +143,7 @@ public final class Indirect implements FreeRefFunction {
/**
* @return array of length 2: {workbookName, sheetName,}. Second element will always be
* present. First element may be null if sheetName is unqualified.
* Returns <code>null</code> if text cannot be parsed.
* Returns {@code null} if text cannot be parsed.
*/
private static String[] parseWorkbookAndSheetName(CharSequence text) {
int lastIx = text.length() - 1;
@ -212,7 +213,7 @@ public final class Indirect implements FreeRefFunction {
}
/**
* @return <code>null</code> if there is a syntax error in any escape sequence
* @return {@code null} if there is a syntax error in any escape sequence
* (the typical syntax error is a single quote character not followed by another).
*/
private static String unescapeString(CharSequence text) {
@ -246,9 +247,6 @@ public final class Indirect implements FreeRefFunction {
if (Character.isWhitespace(text.charAt(0))) {
return true;
}
if (Character.isWhitespace(text.charAt(lastIx))) {
return true;
}
return false;
return Character.isWhitespace(text.charAt(lastIx));
}
}

View File

@ -367,7 +367,8 @@ final class LookupUtils {
* Processes the third argument to VLOOKUP, or HLOOKUP (<b>col_index_num</b>
* or <b>row_index_num</b> respectively).<br>
* Sample behaviour:
* <table border="0" cellpadding="1" cellspacing="2" summary="Sample behaviour">
* <table>
* <caption>Sample behaviour</caption>
* <tr><th>Input&nbsp;&nbsp;&nbsp;Return</th><th>Value&nbsp;&nbsp;</th><th>Thrown Error</th></tr>
* <tr><td>5</td><td>4</td><td>&nbsp;</td></tr>
* <tr><td>2.9</td><td>2</td><td>&nbsp;</td></tr>

View File

@ -19,58 +19,57 @@ package org.apache.poi.ss.formula.functions;
import static org.apache.poi.ss.formula.functions.AggregateFunction.subtotalInstance;
import org.apache.poi.ss.formula.LazyRefEval;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NotImplementedException;
import org.apache.poi.ss.formula.eval.NotImplementedFunctionException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.apache.poi.ss.formula.LazyRefEval;
import org.apache.poi.ss.formula.eval.ErrorEval;
import org.apache.poi.ss.formula.eval.EvaluationException;
import org.apache.poi.ss.formula.eval.NotImplementedFunctionException;
import org.apache.poi.ss.formula.eval.OperandResolver;
import org.apache.poi.ss.formula.eval.ValueEval;
/**
* Implementation for the Excel function SUBTOTAL<p>
*
* <b>Syntax :</b> <br>
* SUBTOTAL ( <b>functionCode</b>, <b>ref1</b>, ref2 ... ) <br>
* <table border="1" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><td><b>functionCode</b></td><td>(1-11) Selects the underlying aggregate function to be used (see table below)</td></tr>
* <tr><td><b>ref1</b>, ref2 ...</td><td>Arguments to be passed to the underlying aggregate function</td></tr>
* </table><br>
* </p>
*
* <table border="1" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><th>functionCode</th><th>Aggregate Function</th></tr>
* <tr align='center'><td>1</td><td>AVERAGE</td></tr>
* <tr align='center'><td>2</td><td>COUNT</td></tr>
* <tr align='center'><td>3</td><td>COUNTA</td></tr>
* <tr align='center'><td>4</td><td>MAX</td></tr>
* <tr align='center'><td>5</td><td>MIN</td></tr>
* <tr align='center'><td>6</td><td>PRODUCT</td></tr>
* <tr align='center'><td>7</td><td>STDEV</td></tr>
* <tr align='center'><td>8</td><td>STDEVP *</td></tr>
* <tr align='center'><td>9</td><td>SUM</td></tr>
* <tr align='center'><td>10</td><td>VAR *</td></tr>
* <tr align='center'><td>11</td><td>VARP *</td></tr>
* <tr align='center'><td>101</td><td>AVERAGE</td></tr>
* <tr align='center'><td>102</td><td>COUNT</td></tr>
* <tr align='center'><td>103</td><td>COUNTA</td></tr>
* <tr align='center'><td>104</td><td>MAX</td></tr>
* <tr align='center'><td>105</td><td>MIN</td></tr>
* <tr align='center'><td>106</td><td>PRODUCT</td></tr>
* <tr align='center'><td>107</td><td>STDEV</td></tr>
* <tr align='center'><td>108</td><td>STDEVP *</td></tr>
* <tr align='center'><td>109</td><td>SUM</td></tr>
* <tr align='center'><td>110</td><td>VAR *</td></tr>
* <tr align='center'><td>111</td><td>VARP *</td></tr>
* <tr><td>1</td><td>AVERAGE</td></tr>
* <tr><td>2</td><td>COUNT</td></tr>
* <tr><td>3</td><td>COUNTA</td></tr>
* <tr><td>4</td><td>MAX</td></tr>
* <tr><td>5</td><td>MIN</td></tr>
* <tr><td>6</td><td>PRODUCT</td></tr>
* <tr><td>7</td><td>STDEV</td></tr>
* <tr><td>8</td><td>STDEVP *</td></tr>
* <tr><td>9</td><td>SUM</td></tr>
* <tr><td>10</td><td>VAR *</td></tr>
* <tr><td>11</td><td>VARP *</td></tr>
* <tr><td>101</td><td>AVERAGE</td></tr>
* <tr><td>102</td><td>COUNT</td></tr>
* <tr><td>103</td><td>COUNTA</td></tr>
* <tr><td>104</td><td>MAX</td></tr>
* <tr><td>105</td><td>MIN</td></tr>
* <tr><td>106</td><td>PRODUCT</td></tr>
* <tr><td>107</td><td>STDEV</td></tr>
* <tr><td>108</td><td>STDEVP *</td></tr>
* <tr><td>109</td><td>SUM</td></tr>
* <tr><td>110</td><td>VAR *</td></tr>
* <tr><td>111</td><td>VARP *</td></tr>
* </table><br>
* * Not implemented in POI yet. Functions 101-111 are the same as functions 1-11 but with
* the option 'ignore hidden values'.
* <p>
*/
public class Subtotal implements Function {
@ -102,6 +101,7 @@ public class Subtotal implements Function {
throw EvaluationException.invalidValue();
}
@Override
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
int nInnerArgs = args.length-1; // -1: first arg is used to select from a basic aggregate function
if (nInnerArgs < 1) {
@ -109,7 +109,7 @@ public class Subtotal implements Function {
}
final Function innerFunc;
int functionCode = 0;
int functionCode;
try {
ValueEval ve = OperandResolver.getSingleValue(args[0], srcRowIndex, srcColumnIndex);
functionCode = OperandResolver.coerceValueToInt(ve);

View File

@ -30,7 +30,8 @@ import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate;
*
* Syntax : <br>
* SUMIF ( <b>range</b>, <b>criteria</b>, sum_range ) <br>
* <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><th>range</th><td>The range over which criteria is applied. Also used for addend values when the third parameter is not present</td></tr>
* <tr><th>criteria</th><td>The value or expression used to filter rows from <b>range</b></td></tr>
* <tr><th>sum_range</th><td>Locates the top-left corner of the corresponding range of addends - values to be added (after being selected by the criteria)</td></tr>
@ -38,6 +39,7 @@ import org.apache.poi.ss.formula.functions.CountUtils.I_MatchPredicate;
*/
public final class Sumif extends Var2or3ArgFunction {
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1) {
AreaEval aeRange;
@ -49,6 +51,7 @@ public final class Sumif extends Var2or3ArgFunction {
return eval(srcRowIndex, srcColumnIndex, arg1, aeRange, aeRange);
}
@Override
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, ValueEval arg0, ValueEval arg1,
ValueEval arg2) {

View File

@ -36,7 +36,8 @@ import org.apache.poi.ss.formula.eval.ValueEval;
*
* Syntax : <br>
* SUMPRODUCT ( array1[, array2[, array3[, ...]]])
* <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><th>array1, ... arrayN&nbsp;&nbsp;</th><td>typically area references,
* possibly cell references or scalar values</td></tr>
* </table><br>
@ -54,6 +55,7 @@ import org.apache.poi.ss.formula.eval.ValueEval;
public final class Sumproduct implements Function {
@Override
public ValueEval evaluate(ValueEval[] args, int srcCellRow, int srcCellCol) {
int maxN = args.length;
@ -87,8 +89,8 @@ public final class Sumproduct implements Function {
int maxN = evalArgs.length;
double term = 1D;
for(int n=0; n<maxN; n++) {
double val = getScalarValue(evalArgs[n]);
for (ValueEval evalArg : evalArgs) {
double val = getScalarValue(evalArg);
term *= val;
}
return new NumberEval(term);
@ -178,13 +180,12 @@ public final class Sumproduct implements Function {
}
private static boolean areasAllSameSize(TwoDEval[] args, int height, int width) {
for (int i = 0; i < args.length; i++) {
TwoDEval areaEval = args[i];
for (TwoDEval areaEval : args) {
// check that height and width match
if(areaEval.getHeight() != height) {
if (areaEval.getHeight() != height) {
return false;
}
if(areaEval.getWidth() != width) {
if (areaEval.getWidth() != width) {
return false;
}
}
@ -193,12 +194,12 @@ public final class Sumproduct implements Function {
/**
* Determines a <code>double</code> value for the specified <code>ValueEval</code>.
* @param isScalarProduct <code>false</code> for SUMPRODUCTs over area refs.
* @throws EvaluationException if <code>ve</code> represents an error value.
* Determines a {@code double} value for the specified {@code ValueEval}.
* @param isScalarProduct {@code false} for SUMPRODUCTs over area refs.
* @throws EvaluationException if {@code ve} represents an error value.
* <p>
* Note - string values and empty cells are interpreted differently depending on
* <code>isScalarProduct</code>. For scalar products, if any term is blank or a string, the
* {@code isScalarProduct}. For scalar products, if any term is blank or a string, the
* error (#VALUE!) is raised. For area (sum)products, if any term is blank or a string, the
* result is zero.
*/

View File

@ -47,7 +47,8 @@ import org.apache.poi.ss.formula.eval.ValueEval;
*
* Syntax:<br>
* TREND(known_y's, known_x's, new_x's, constant)
* <table border="0" cellpadding="1" cellspacing="0" summary="Parameter descriptions">
* <table>
* <caption>Parameter descriptions</caption>
* <tr><th>known_y's, known_x's, new_x's</th><td>typically area references, possibly cell references or scalar values</td></tr>
* <tr><th>constant</th><td><b>TRUE</b> or <b>FALSE</b>:
* determines whether the regression line should include an intercept term</td></tr>
@ -56,7 +57,6 @@ import org.apache.poi.ss.formula.eval.ValueEval;
* of the same size as <b>known_y's</b>.<br>
* If <b>new_x's</b> is not given, it is assumed to be the same as <b>known_x's</b><br>
* If <b>constant</b> is omitted, it is assumed to be <b>TRUE</b>
* </p>
*/
public final class Trend implements Function {
@ -72,6 +72,7 @@ public final class Trend implements Function {
}
}
@Override
public ValueEval evaluate(ValueEval[] args, int srcRowIndex, int srcColumnIndex) {
if (args.length < 1 || args.length > 4) {
return ErrorEval.VALUE_INVALID;

View File

@ -164,12 +164,11 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
* POI's SpreadsheetAPI silently truncates the input argument to 31 characters.
* Example:
*
* <pre><code>
* <pre>{@code
* Sheet sheet = workbook.createSheet("My very long sheet name which is longer than 31 chars"); // will be truncated
* assert 31 == sheet.getSheetName().length();
* assert "My very long sheet name which i" == sheet.getSheetName();
* </code></pre>
* </p>
* }</pre>
*
* Except the 31-character constraint, Excel applies some other rules:
* <p>
@ -186,7 +185,6 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
* <li> closing square bracket (]) </li>
* </ul>
* The string MUST NOT begin or end with the single quote (') character.
* </p>
*
* <p>
* See {@link org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)}
@ -237,7 +235,7 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
* Get sheet with the given name
*
* @param name of the sheet
* @return Sheet with the name provided or <code>null</code> if it does not exist
* @return Sheet with the name provided or {@code null} if it does not exist
*/
Sheet getSheet(String name);
@ -258,7 +256,7 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
/**
* Finds a font that matches the one with the supplied attributes
*
* @return the font with the matched attributes or <code>null</code>
* @return the font with the matched attributes or {@code null}
*/
Font findFont(boolean bold, short color, short fontHeight, String name, boolean italic, boolean strikeout, short typeOffset, byte underline);
@ -337,7 +335,7 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
/**
* @param name the name of the defined name
* @return the defined name with the specified name. <code>null</code> if not found.
* @return the defined name with the specified name. {@code null} if not found.
*/
Name getName(String name);
@ -479,12 +477,12 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
CreationHelper getCreationHelper();
/**
* @return <code>false</code> if this workbook is not visible in the GUI
* @return {@code false} if this workbook is not visible in the GUI
*/
boolean isHidden();
/**
* @param hiddenFlag pass <code>false</code> to make the workbook visible in the GUI
* @param hiddenFlag pass {@code false} to make the workbook visible in the GUI
*/
void setHidden(boolean hiddenFlag);
@ -495,7 +493,7 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
* ({@link #isSheetVeryHidden(int)})
* </p>
* @param sheetIx Number
* @return <code>true</code> if sheet is hidden
* @return {@code true} if sheet is hidden
* @see #getSheetVisibility(int)
*/
boolean isSheetHidden(int sheetIx);
@ -507,7 +505,7 @@ public interface Workbook extends Closeable, Iterable<Sheet> {
* ({@link #isSheetHidden(int)})
* </p>
* @param sheetIx sheet index to check
* @return <code>true</code> if sheet is very hidden
* @return {@code true} if sheet is very hidden
* @see #getSheetVisibility(int)
*/
boolean isSheetVeryHidden(int sheetIx);

View File

@ -383,7 +383,8 @@ public class AreaReference {
* Returns a text representation of this area reference.
* <p>
* Example return values:
* <table border="0" cellpadding="1" cellspacing="0" summary="Example return values">
* <table>
* <caption>Example return values</caption>
* <tr><th align='left'>Result</th><th align='left'>Comment</th></tr>
* <tr><td>A1:A1</td><td>Single cell area reference without sheet</td></tr>
* <tr><td>A1:$C$1</td><td>Multi-cell area reference without sheet</td></tr>

View File

@ -290,13 +290,14 @@ public class CellReference implements GenericRecord {
* reference is valid (in range) becomes important.
* <p>
* Note - that the maximum sheet size varies across Excel versions:
* <blockquote><table border="0" cellpadding="1" cellspacing="0"
* summary="Notable cases.">
* <table>
* <caption>Notable cases.</caption>
* <tr><th>Version&nbsp;&nbsp;</th><th>File Format&nbsp;&nbsp;</th>
* <th>Last Column&nbsp;&nbsp;</th><th>Last Row</th></tr>
* <tr><td>97-2003</td><td>BIFF8</td><td>"IV" (2^8)</td><td>65536 (2^14)</td></tr>
* <tr><td>2007</td><td>BIFF12</td><td>"XFD" (2^14)</td><td>1048576 (2^20)</td></tr>
* </table></blockquote>
* </table>
*
* POI currently targets BIFF8 (Excel 97-2003), so the following behaviour can be observed for
* this method:
* <blockquote><table border="0" cellpadding="1" cellspacing="0"
@ -482,7 +483,8 @@ public class CellReference implements GenericRecord {
* Returns a text representation of this cell reference.
* <p>
* Example return values:
* <table border="0" cellpadding="1" cellspacing="0" summary="Example return values">
* <table>
* <caption>Example return values</caption>
* <tr><th align='left'>Result</th><th align='left'>Comment</th></tr>
* <tr><td>A1</td><td>Cell reference without sheet</td></tr>
* <tr><td>Sheet1!A1</td><td>Standard sheet name</td></tr>

View File

@ -31,7 +31,8 @@ package org.apache.poi.ss.util;
* </ul>
* IEEE 64-bit Double Rendering Comparison
*
* <table border="1" cellpadding="2" cellspacing="0" summary="IEEE 64-bit Double Rendering Comparison">
* <table>
* <caption>IEEE 64-bit Double Rendering Comparison</caption>
* <tr><th>Raw bits</th><th>Java</th><th>Excel</th></tr>
*
* <tr><td>0x0000000000000000L</td><td>0.0</td><td>0</td></tr>

View File

@ -24,7 +24,8 @@ public interface CellWalkContext {
* from top left cell and ends at bottom right cell. Here is a
* brief example (number in cell is it's ordinal number):
*
* <table border="1">
* <table>
* <caption>ordinal number example</caption>
* <tbody>
* <tr><td>1</td><td>2</td></tr>
* <tr><td>3</td><td>4</td></tr>

View File

@ -38,11 +38,11 @@ import java.lang.annotation.Documented;
* removed in the n+2 release, a later version should be specified by this
* annotation. The annotation version number should not include beta</p>
*
* <p>For example, a feature with a <code>&#64;deprecated POI 3.15 beta 3</code>
* <p>For example, a feature with a {@code @deprecated POI 3.15 beta 3}
* is deprecated in POI 3.15 and 3.16 and becomes eligible for deletion during
* the POI 3.17 release series, and may be deleted immediately after POI 3.16 is
* released. This would be annotated <code>&#64;Removal(version="3.17")</p>.
*
* released. This would be annotated {@code @Removal(version="3.17")}</p>.
*
* @since POI-3.15 beta 3
*/
@Documented
@ -50,12 +50,14 @@ import java.lang.annotation.Documented;
public @interface Removal {
/**
* The POI version when this feature may be removed.
*
*
* To ensure that the version number can be compared to the current version
* and a unit test can generate a warning if a removal-eligible feature has
* not been removed yet, the version number should adhere to the following format:
* <pre>{@code
* Format: "(?<major>\d+)\.(?<minor>\d+)"
* Example: "3.15"
* }</pre>
*/
String version() default "";
// TODO: Verify that the version syntax is valid by parsing with a version-aware parser like