diff options
author | Yegor Kozlov <yegor@apache.org> | 2008-11-07 16:57:23 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2008-11-07 16:57:23 +0000 |
commit | f1438095498ea70e80195365bf168dd14e80cecd (patch) | |
tree | 291c4ae921745f2e2ef55c077bb9db0266a77399 /src/ooxml/java/org/apache/poi | |
parent | d61df950d94a49ca25176709f84a0acf7845b44e (diff) | |
download | poi-f1438095498ea70e80195365bf168dd14e80cecd.tar.gz poi-f1438095498ea70e80195365bf168dd14e80cecd.zip |
javadocs cleanup
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@712196 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java/org/apache/poi')
11 files changed, 472 insertions, 478 deletions
diff --git a/src/ooxml/java/org/apache/poi/util/PackageHelper.java b/src/ooxml/java/org/apache/poi/util/PackageHelper.java index 4471a6046f..258e5b8d1e 100755 --- a/src/ooxml/java/org/apache/poi/util/PackageHelper.java +++ b/src/ooxml/java/org/apache/poi/util/PackageHelper.java @@ -84,9 +84,7 @@ public class PackageHelper { }
/**
- *
- * @return
- * @throws IOException
+ * Creates an empty file in the default temporary-file directory,
*/
public static File createTempFile() throws IOException {
File file = File.createTempFile("poi-ooxml-", ".tmp");
diff --git a/src/ooxml/java/org/apache/poi/xssf/model/XSSFChildContainingModel.java b/src/ooxml/java/org/apache/poi/xssf/model/XSSFChildContainingModel.java index fd37e79fde..d16cf9a1bd 100644 --- a/src/ooxml/java/org/apache/poi/xssf/model/XSSFChildContainingModel.java +++ b/src/ooxml/java/org/apache/poi/xssf/model/XSSFChildContainingModel.java @@ -36,7 +36,7 @@ public interface XSSFChildContainingModel extends XSSFModel { * appropriate model or usermodel thing can be * created for it. * @param childPart The PackagePart of the child - * @param childId the ID of the relationship the child comes from + * @param childRelId the ID of the relationship the child comes from */ public void generateChild(PackagePart childPart, String childRelId); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java index f738b87749..edbae83765 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java @@ -86,8 +86,8 @@ public final class XSSFCell implements Cell { /** * Construct a XSSFCell. * - * @param row the xml bean containing information about the cell. * @param row the parent row. + * @param cell the xml bean containing information about the cell. */ protected XSSFCell(XSSFRow row, CTCell cell) { this.cell = cell; diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java index 74baa5f2e6..8a6ca929c7 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCellStyle.java @@ -120,13 +120,13 @@ public class XSSFCellStyle implements CellStyle { * Get the type of horizontal alignment for the cell * * @return short - the type of alignment - * @see #ALIGN_GENERAL - * @see #ALIGN_LEFT - * @see #ALIGN_CENTER - * @see #ALIGN_RIGHT - * @see #ALIGN_FILL - * @see #ALIGN_JUSTIFY - * @see #ALIGN_CENTER_SELECTION + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_GENERAL + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_LEFT + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_RIGHT + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_FILL + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION */ public short getAlignment() { return (short)(getAlignmentEnum().ordinal()); @@ -136,6 +136,7 @@ public class XSSFCellStyle implements CellStyle { * Get the type of horizontal alignment for the cell * * @return HorizontalAlignment - the type of alignment + * @see org.apache.poi.ss.usermodel.HorizontalAlignment */ public HorizontalAlignment getAlignmentEnum() { CTCellAlignment align = cellXf.getAlignment(); @@ -150,20 +151,20 @@ public class XSSFCellStyle implements CellStyle { * Get the type of border to use for the bottom border of the cell * * @return short - border type - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public short getBorderBottom() { if(!cellXf.getApplyBorder()) return BORDER_NONE; @@ -188,21 +189,21 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of border to use for the left border of the cell * - * @return short - border type, default value is {@link #BORDER_NONE} - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @return short - border type, default value is {@link org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE} + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public short getBorderLeft() { if(!cellXf.getApplyBorder()) return BORDER_NONE; @@ -216,7 +217,7 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of border to use for the left border of the cell * - * @return border type, default value is {@link BorderStyle.NONE} + * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} */ public BorderStyle getBorderLeftEnum() { int style = getBorderLeft(); @@ -226,21 +227,21 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of border to use for the right border of the cell * - * @return short - border type, default value is {@link #BORDER_NONE} - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @return short - border type, default value is {@link org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE} + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public short getBorderRight() { if(!cellXf.getApplyBorder()) return BORDER_NONE; @@ -254,7 +255,7 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of border to use for the right border of the cell * - * @return border type, default value is {@link BorderStyle.NONE} + * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} */ public BorderStyle getBorderRightEnum() { int style = getBorderRight(); @@ -264,21 +265,21 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of border to use for the top border of the cell * - * @return short - border type, default value is {@link #BORDER_NONE} - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @return short - border type, default value is {@link org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE} + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle #BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public short getBorderTop() { if(!cellXf.getApplyBorder()) return BORDER_NONE; @@ -292,7 +293,7 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of border to use for the top border of the cell * - * @return border type, default value is {@link BorderStyle.NONE} + * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} */ public BorderStyle getBorderTopEnum() { int style = getBorderTop(); @@ -303,8 +304,8 @@ public class XSSFCellStyle implements CellStyle { * Get the color to use for the bottom border * <br/> * Color is optional. When missing, IndexedColors.AUTOMATIC is implied. - * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors.AUTOMATIC} - * @see IndexedColors + * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC} + * @see org.apache.poi.ss.usermodel.IndexedColors */ public short getBottomBorderColor() { XSSFColor clr = getBottomBorderXSSFColor(); @@ -350,8 +351,8 @@ public class XSSFCellStyle implements CellStyle { * Note - many cells are actually filled with a foreground * fill, not a background fill - see {@link #getFillForegroundColor()} * </p> - * @return fill color, default value is {@link IndexedColors.AUTOMATIC} - * @see IndexedColors + * @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC} + * @see org.apache.poi.ss.usermodel.IndexedColors */ public short getFillBackgroundColor() { XSSFColor clr = getFillBackgroundXSSFColor(); @@ -383,7 +384,7 @@ public class XSSFCellStyle implements CellStyle { * background color ({@link #getFillBackgroundColor()}) * </p> * @see IndexedColors - * @return fill color, default value is {@link IndexedColors.AUTOMATIC} + * @return fill color, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#AUTOMATIC} */ public short getFillForegroundColor() { XSSFColor clr = getFillForegroundXSSFColor(); @@ -406,25 +407,25 @@ public class XSSFCellStyle implements CellStyle { /** * Get the fill pattern - * @return fill pattern, default value is {@link #NO_FILL} - * - * @see #NO_FILL - * @see #SOLID_FOREGROUND - * @see #FINE_DOTS - * @see #ALT_BARS - * @see #SPARSE_DOTS - * @see #THICK_HORZ_BANDS - * @see #THICK_VERT_BANDS - * @see #THICK_BACKWARD_DIAG - * @see #THICK_FORWARD_DIAG - * @see #BIG_SPOTS - * @see #BRICKS - * @see #THIN_HORZ_BANDS - * @see #THIN_VERT_BANDS - * @see #THIN_BACKWARD_DIAG - * @see #THIN_FORWARD_DIAG - * @see #SQUARES - * @see #DIAMONDS + * @return fill pattern, default value is {@link org.apache.poi.ss.usermodel.CellStyle#NO_FILL} + * + * @see org.apache.poi.ss.usermodel.CellStyle#NO_FILL + * @see org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND + * @see org.apache.poi.ss.usermodel.CellStyle#FINE_DOTS + * @see org.apache.poi.ss.usermodel.CellStyle#ALT_BARS + * @see org.apache.poi.ss.usermodel.CellStyle#SPARSE_DOTS + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_HORZ_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_VERT_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_BACKWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_FORWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#BIG_SPOTS + * @see org.apache.poi.ss.usermodel.CellStyle#BRICKS + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_HORZ_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_VERT_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_BACKWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_FORWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#SQUARES + * @see org.apache.poi.ss.usermodel.CellStyle#DIAMONDS */ public short getFillPattern() { if(!cellXf.getApplyFill()) return 0; @@ -440,7 +441,7 @@ public class XSSFCellStyle implements CellStyle { /** * Get the fill pattern * - * @return the fill pattern, default value is {@link FillPatternType.NO_FILL} + * @return the fill pattern, default value is {@link org.apache.poi.ss.usermodel.FillPatternType#NO_FILL} */ public FillPatternType getFillPatternEnum() { int style = getFillPattern(); @@ -499,8 +500,8 @@ public class XSSFCellStyle implements CellStyle { /** * Get the color to use for the left border * - * @return the index of the color definition, default value is {@link IndexedColors.BLACK} - * @see IndexedColors + * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK} + * @see org.apache.poi.ss.usermodel.IndexedColors */ public short getLeftBorderColor() { XSSFColor clr = getLeftBorderXSSFColor(); @@ -511,7 +512,7 @@ public class XSSFCellStyle implements CellStyle { * Get the color to use for the left border * * @return the index of the color definition or <code>null</code> if not set - * @see IndexedColors + * @see org.apache.poi.ss.usermodel.IndexedColors */ public XSSFColor getLeftBorderXSSFColor() { if(!cellXf.getApplyBorder()) return null; @@ -534,8 +535,8 @@ public class XSSFCellStyle implements CellStyle { /** * Get the color to use for the right border * - * @return the index of the color definition, default value is {@link IndexedColors.BLACK} - * @see IndexedColors + * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK} + * @see org.apache.poi.ss.usermodel.IndexedColors */ public short getRightBorderColor() { XSSFColor clr = getRightBorderXSSFColor(); @@ -577,8 +578,8 @@ public class XSSFCellStyle implements CellStyle { /** * Get the color to use for the top border * - * @return the index of the color definition, default value is {@link IndexedColors.BLACK} - * @see IndexedColors + * @return the index of the color definition, default value is {@link org.apache.poi.ss.usermodel.IndexedColors#BLACK} + * @see org.apache.poi.ss.usermodel.IndexedColors */ public short getTopBorderColor() { XSSFColor clr = getTopBorderXSSFColor(); @@ -602,11 +603,11 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of vertical alignment for the cell * - * @return align the type of alignment, default value is {@link #VERTICAL_BOTTOM} - * @see #VERTICAL_TOP - * @see #VERTICAL_CENTER - * @see #VERTICAL_BOTTOM - * @see #VERTICAL_JUSTIFY + * @return align the type of alignment, default value is {@link org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM} + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_TOP + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_CENTER + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY */ public short getVerticalAlignment() { return (short) (getVerticalAlignmentEnum().ordinal()); @@ -615,8 +616,8 @@ public class XSSFCellStyle implements CellStyle { /** * Get the type of vertical alignment for the cell * - * @return the type of alignment, default value is {@link VerticalAlignment.BOTTOM} - * @see VerticalAlignment + * @return the type of alignment, default value is {@link org.apache.poi.ss.usermodel.VerticalAlignment#BOTTOM} + * @see org.apache.poi.ss.usermodel.VerticalAlignment */ public VerticalAlignment getVerticalAlignmentEnum() { CTCellAlignment align = cellXf.getAlignment(); @@ -641,13 +642,13 @@ public class XSSFCellStyle implements CellStyle { * Set the type of horizontal alignment for the cell * * @param align - the type of alignment - * @see #ALIGN_GENERAL - * @see #ALIGN_LEFT - * @see #ALIGN_CENTER - * @see #ALIGN_RIGHT - * @see #ALIGN_FILL - * @see #ALIGN_JUSTIFY - * @see #ALIGN_CENTER_SELECTION + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_GENERAL + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_LEFT + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_RIGHT + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_FILL + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_JUSTIFY + * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION */ public void setAlignment(short align) { getCellAlignment().setHorizontal(HorizontalAlignment.values()[align]); @@ -667,20 +668,20 @@ public class XSSFCellStyle implements CellStyle { * Set the type of border to use for the bottom border of the cell * * @param border the type of border to use - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public void setBorderBottom(short border) { CTBorder ct = getCTBorder(); @@ -698,7 +699,7 @@ public class XSSFCellStyle implements CellStyle { * Set the type of border to use for the bottom border of the cell * * @param border - type of border to use - * @see BorderStyle + * @see org.apache.poi.ss.usermodel.BorderStyle */ public void setBorderBottom(BorderStyle border) { setBorderBottom((short)border.ordinal()); @@ -707,20 +708,20 @@ public class XSSFCellStyle implements CellStyle { /** * Set the type of border to use for the left border of the cell * @param border the type of border to use - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public void setBorderLeft(short border) { CTBorder ct = getCTBorder(); @@ -747,20 +748,20 @@ public class XSSFCellStyle implements CellStyle { * Set the type of border to use for the right border of the cell * * @param border the type of border to use - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public void setBorderRight(short border) { CTBorder ct = getCTBorder(); @@ -787,20 +788,20 @@ public class XSSFCellStyle implements CellStyle { * Set the type of border to use for the top border of the cell * * @param border the type of border to use - * @see #BORDER_NONE - * @see #BORDER_THIN - * @see #BORDER_MEDIUM - * @see #BORDER_DASHED - * @see #BORDER_DOTTED - * @see #BORDER_THICK - * @see #BORDER_DOUBLE - * @see #BORDER_HAIR - * @see #BORDER_MEDIUM_DASHED - * @see #BORDER_DASH_DOT - * @see #BORDER_MEDIUM_DASH_DOT - * @see #BORDER_DASH_DOT_DOT - * @see #BORDER_MEDIUM_DASH_DOT_DOT - * @see #BORDER_SLANTED_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_NONE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THIN + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOTTED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_THICK + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DOUBLE + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_HAIR + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASHED + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_MEDIUM_DASH_DOT_DOT + * @see org.apache.poi.ss.usermodel.CellStyle#BORDER_SLANTED_DASH_DOT */ public void setBorderTop(short border) { CTBorder ct = getCTBorder(); @@ -826,7 +827,7 @@ public class XSSFCellStyle implements CellStyle { /** * Set the color to use for the bottom border * @param color the index of the color definition - * @see IndexedColors + * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setBottomBorderColor(short color) { XSSFColor clr = new XSSFColor(); @@ -928,7 +929,7 @@ public class XSSFCellStyle implements CellStyle { * for the color to be shown in the cell. * * @param bg - the color to use - * @see IndexedColors + * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setFillBackgroundColor(short bg) { XSSFColor clr = new XSSFColor(); @@ -965,7 +966,7 @@ public class XSSFCellStyle implements CellStyle { * <br/> * <i>Note: Ensure Foreground color is set prior to background color.</i> * @param fg the color to use - * @see IndexedColors + * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setFillForegroundColor(short fg) { XSSFColor clr = new XSSFColor(); @@ -1010,26 +1011,26 @@ public class XSSFCellStyle implements CellStyle { * For solid cell fills (no pattern), foregorund color is used. * For cell fills with patterns specified, then the cell fill color is specified by the background color. * - * @see #NO_FILL - * @see #SOLID_FOREGROUND - * @see #FINE_DOTS - * @see #ALT_BARS - * @see #SPARSE_DOTS - * @see #THICK_HORZ_BANDS - * @see #THICK_VERT_BANDS - * @see #THICK_BACKWARD_DIAG - * @see #THICK_FORWARD_DIAG - * @see #BIG_SPOTS - * @see #BRICKS - * @see #THIN_HORZ_BANDS - * @see #THIN_VERT_BANDS - * @see #THIN_BACKWARD_DIAG - * @see #THIN_FORWARD_DIAG - * @see #SQUARES - * @see #DIAMONDS + * @see org.apache.poi.ss.usermodel.CellStyle#NO_FILL + * @see org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND + * @see org.apache.poi.ss.usermodel.CellStyle#FINE_DOTS + * @see org.apache.poi.ss.usermodel.CellStyle#ALT_BARS + * @see org.apache.poi.ss.usermodel.CellStyle#SPARSE_DOTS + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_HORZ_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_VERT_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_BACKWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#THICK_FORWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#BIG_SPOTS + * @see org.apache.poi.ss.usermodel.CellStyle#BRICKS + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_HORZ_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_VERT_BANDS + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_BACKWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#THIN_FORWARD_DIAG + * @see org.apache.poi.ss.usermodel.CellStyle#SQUARES + * @see org.apache.poi.ss.usermodel.CellStyle#DIAMONDS * @see #setFillBackgroundColor(short) * @see #setFillForegroundColor(short) - * @param fp fill pattern (set to {@link #SOLID_FOREGROUND} to fill w/foreground color) + * @param fp fill pattern (set to {@link org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND} to fill w/foreground color) */ public void setFillPattern(short fp) { CTFill ct = getCTFill(); @@ -1050,7 +1051,7 @@ public class XSSFCellStyle implements CellStyle { * @param ptrn the fill pattern to use * @see #setFillBackgroundColor(short) * @see #setFillForegroundColor(short) - * @see FillPatternType + * @see org.apache.poi.ss.usermodel.FillPatternType */ public void setFillPattern(FillPatternType ptrn) { setFillPattern((short)ptrn.ordinal()); @@ -1095,7 +1096,7 @@ public class XSSFCellStyle implements CellStyle { * Set the color to use for the left border as a indexed color value * * @param color the index of the color definition - * @see IndexedColors + * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setLeftBorderColor(short color) { XSSFColor clr = new XSSFColor(); @@ -1135,7 +1136,7 @@ public class XSSFCellStyle implements CellStyle { * Set the color to use for the right border * * @param color the index of the color definition - * @see IndexedColors + * @see org.apache.poi.ss.usermodel.IndexedColors */ public void setRightBorderColor(short color) { XSSFColor clr = new XSSFColor(); @@ -1216,11 +1217,11 @@ public class XSSFCellStyle implements CellStyle { * Set the type of vertical alignment for the cell * * @param align - align the type of alignment - * @see #VERTICAL_TOP - * @see #VERTICAL_CENTER - * @see #VERTICAL_BOTTOM - * @see #VERTICAL_JUSTIFY - * @see VerticalAlignment + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_TOP + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_CENTER + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_BOTTOM + * @see org.apache.poi.ss.usermodel.CellStyle#VERTICAL_JUSTIFY + * @see org.apache.poi.ss.usermodel.VerticalAlignment */ public void setVerticalAlignment(short align) { getCellAlignment().setVertical(VerticalAlignment.values()[align]); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java index d24b264515..c4af9bdafd 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFont.java @@ -38,7 +38,7 @@ public class XSSFFont implements Font { public static final short DEFAULT_FONT_SIZE = 11; /** * Default font color is black - * @see IndexedColors.BLACK + * @see org.apache.poi.ss.usermodel.IndexedColors#BLACK */ public static final short DEFAULT_FONT_COLOR = IndexedColors.BLACK.getIndex(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java index 19f75aab4a..cd20997c87 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFFormulaEvaluator.java @@ -1,246 +1,244 @@ -/* ====================================================================
- 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;
-
-import java.util.Iterator;
-
-import org.apache.poi.hssf.record.formula.eval.BoolEval;
-import org.apache.poi.hssf.record.formula.eval.ErrorEval;
-import org.apache.poi.hssf.record.formula.eval.NumberEval;
-import org.apache.poi.hssf.record.formula.eval.StringEval;
-import org.apache.poi.hssf.record.formula.eval.ValueEval;
-import org.apache.poi.hssf.usermodel.HSSFCell;
-import org.apache.poi.ss.formula.WorkbookEvaluator;
-import org.apache.poi.ss.usermodel.Cell;
-import org.apache.poi.ss.usermodel.CellValue;
-import org.apache.poi.ss.usermodel.FormulaEvaluator;
-import org.apache.poi.ss.usermodel.Row;
-import org.apache.poi.ss.usermodel.Sheet;
-
-/**
- * Evaluates formula cells.<p/>
- *
- * For performance reasons, this class keeps a cache of all previously calculated intermediate
- * cell values. Be sure to call {@link #clearCache()} if any workbook cells are changed between
- * calls to evaluate~ methods on this class.
- *
- * @author Amol S. Deshmukh < amolweb at ya hoo dot com >
- * @author Josh Micich
- */
-public class XSSFFormulaEvaluator implements FormulaEvaluator {
-
- private WorkbookEvaluator _bookEvaluator;
-
- public XSSFFormulaEvaluator(XSSFWorkbook workbook) {
- _bookEvaluator = new WorkbookEvaluator(XSSFEvaluationWorkbook.create(workbook));
- }
-
- /**
- * Should be called whenever there are major changes (e.g. moving sheets) to input cells
- * in the evaluated workbook.
- * Failure to call this method after changing cell values will cause incorrect behaviour
- * of the evaluate~ methods of this class
- */
- public void clearAllCachedResultValues() {
- _bookEvaluator.clearAllCachedResultValues();
- }
- public void notifySetFormula(Cell cell) {
- _bookEvaluator.notifyUpdateCell(new XSSFEvaluationCell((XSSFCell)cell));
- }
- public void notifyDeleteCell(Cell cell) {
- _bookEvaluator.notifyDeleteCell(new XSSFEvaluationCell((XSSFCell)cell));
- }
-
- /**
- * If cell contains a formula, the formula is evaluated and returned,
- * else the CellValue simply copies the appropriate cell value from
- * the cell and also its cell type. This method should be preferred over
- * evaluateInCell() when the call should not modify the contents of the
- * original cell.
- * @param cell
- */
- public CellValue evaluate(Cell cell) {
- if (cell == null) {
- return null;
- }
-
- switch (cell.getCellType()) {
- case XSSFCell.CELL_TYPE_BOOLEAN:
- return CellValue.valueOf(cell.getBooleanCellValue());
- case XSSFCell.CELL_TYPE_ERROR:
- return CellValue.getError(cell.getErrorCellValue());
- case XSSFCell.CELL_TYPE_FORMULA:
- return evaluateFormulaCellValue(cell);
- case XSSFCell.CELL_TYPE_NUMERIC:
- return new CellValue(cell.getNumericCellValue());
- case XSSFCell.CELL_TYPE_STRING:
- return new CellValue(cell.getRichStringCellValue().getString());
- }
- throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")");
- }
-
-
- /**
- * If cell contains formula, it evaluates the formula,
- * and saves the result of the formula. The cell
- * remains as a formula cell.
- * Else if cell does not contain formula, this method leaves
- * the cell unchanged.
- * Note that the type of the formula result is returned,
- * so you know what kind of value is also stored with
- * the formula.
- * <pre>
- * int evaluatedCellType = evaluator.evaluateFormulaCell(cell);
- * </pre>
- * Be aware that your cell will hold both the formula,
- * and the result. If you want the cell replaced with
- * the result of the formula, use {@link #evaluateInCell(HSSFCell)}
- * @param cell The cell to evaluate
- * @return The type of the formula result (the cell's type remains as HSSFCell.CELL_TYPE_FORMULA however)
- */
- public int evaluateFormulaCell(Cell cell) {
- if (cell == null || cell.getCellType() != XSSFCell.CELL_TYPE_FORMULA) {
- return -1;
- }
- CellValue cv = evaluateFormulaCellValue(cell);
- // cell remains a formula cell, but the cached value is changed
- setCellValue(cell, cv);
- return cv.getCellType();
- }
-
- /**
- * If cell contains formula, it evaluates the formula, and
- * puts the formula result back into the cell, in place
- * of the old formula.
- * Else if cell does not contain formula, this method leaves
- * the cell unchanged.
- * Note that the same instance of HSSFCell is returned to
- * allow chained calls like:
- * <pre>
- * int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType();
- * </pre>
- * Be aware that your cell value will be changed to hold the
- * result of the formula. If you simply want the formula
- * value computed for you, use {@link #evaluateFormulaCell(HSSFCell)}
- * @param cell
- */
- public XSSFCell evaluateInCell(Cell cell) {
- if (cell == null) {
- return null;
- }
- XSSFCell result = (XSSFCell) cell;
- if (cell.getCellType() == XSSFCell.CELL_TYPE_FORMULA) {
- CellValue cv = evaluateFormulaCellValue(cell);
- setCellType(cell, cv); // cell will no longer be a formula cell
- setCellValue(cell, cv);
- }
- return result;
- }
- private static void setCellType(Cell cell, CellValue cv) {
- int cellType = cv.getCellType();
- switch (cellType) {
- case XSSFCell.CELL_TYPE_BOOLEAN:
- case XSSFCell.CELL_TYPE_ERROR:
- case XSSFCell.CELL_TYPE_NUMERIC:
- case XSSFCell.CELL_TYPE_STRING:
- cell.setCellType(cellType);
- return;
- case XSSFCell.CELL_TYPE_BLANK:
- // never happens - blanks eventually get translated to zero
- case XSSFCell.CELL_TYPE_FORMULA:
- // this will never happen, we have already evaluated the formula
- }
- throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
- }
-
- private static void setCellValue(Cell cell, CellValue cv) {
- int cellType = cv.getCellType();
- switch (cellType) {
- case XSSFCell.CELL_TYPE_BOOLEAN:
- cell.setCellValue(cv.getBooleanValue());
- break;
- case XSSFCell.CELL_TYPE_ERROR:
- cell.setCellErrorValue(cv.getErrorValue());
- break;
- case XSSFCell.CELL_TYPE_NUMERIC:
- cell.setCellValue(cv.getNumberValue());
- break;
- case XSSFCell.CELL_TYPE_STRING:
- cell.setCellValue(new XSSFRichTextString(cv.getStringValue()));
- break;
- case XSSFCell.CELL_TYPE_BLANK:
- // never happens - blanks eventually get translated to zero
- case XSSFCell.CELL_TYPE_FORMULA:
- // this will never happen, we have already evaluated the formula
- default:
- throw new IllegalStateException("Unexpected cell value type (" + cellType + ")");
- }
- }
-
- /**
- * Loops over all cells in all sheets of the supplied
- * workbook.
- * For cells that contain formulas, their formulas are
- * evaluated, and the results are saved. These cells
- * remain as formula cells.
- * For cells that do not contain formulas, no changes
- * are made.
- * This is a helpful wrapper around looping over all
- * cells, and calling evaluateFormulaCell on each one.
- */
- public static void evaluateAllFormulaCells(XSSFWorkbook wb) {
- XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb);
- for(int i=0; i<wb.getNumberOfSheets(); i++) {
- Sheet sheet = wb.getSheetAt(i);
-
- for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) {
- Row r = rit.next();
-
- for (Iterator cit = r.cellIterator(); cit.hasNext();) {
- XSSFCell c = (XSSFCell) cit.next();
- if (c.getCellType() == XSSFCell.CELL_TYPE_FORMULA)
- evaluator.evaluateFormulaCell(c);
- }
- }
- }
- }
-
- /**
- * Returns a CellValue wrapper around the supplied ValueEval instance.
- * @param eval
- */
- private CellValue evaluateFormulaCellValue(Cell cell) {
- ValueEval eval = _bookEvaluator.evaluate(new XSSFEvaluationCell((XSSFCell) cell));
- if (eval instanceof NumberEval) {
- NumberEval ne = (NumberEval) eval;
- return new CellValue(ne.getNumberValue());
- }
- if (eval instanceof BoolEval) {
- BoolEval be = (BoolEval) eval;
- return CellValue.valueOf(be.getBooleanValue());
- }
- if (eval instanceof StringEval) {
- StringEval ne = (StringEval) eval;
- return new CellValue(ne.getStringValue());
- }
- if (eval instanceof ErrorEval) {
- return CellValue.getError(((ErrorEval)eval).getErrorCode());
- }
- throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
- }
-}
+/* ==================================================================== + 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; + +import java.util.Iterator; + +import org.apache.poi.hssf.record.formula.eval.BoolEval; +import org.apache.poi.hssf.record.formula.eval.ErrorEval; +import org.apache.poi.hssf.record.formula.eval.NumberEval; +import org.apache.poi.hssf.record.formula.eval.StringEval; +import org.apache.poi.hssf.record.formula.eval.ValueEval; +import org.apache.poi.ss.formula.WorkbookEvaluator; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellValue; +import org.apache.poi.ss.usermodel.FormulaEvaluator; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; + +/** + * Evaluates formula cells.<p/> + * + * For performance reasons, this class keeps a cache of all previously calculated intermediate + * cell values. Be sure to call {@link #clearAllCachedResultValues()} if any workbook cells are changed between + * calls to evaluate~ methods on this class. + * + * @author Amol S. Deshmukh < amolweb at ya hoo dot com > + * @author Josh Micich + */ +public class XSSFFormulaEvaluator implements FormulaEvaluator { + + private WorkbookEvaluator _bookEvaluator; + + public XSSFFormulaEvaluator(XSSFWorkbook workbook) { + _bookEvaluator = new WorkbookEvaluator(XSSFEvaluationWorkbook.create(workbook)); + } + + /** + * Should be called whenever there are major changes (e.g. moving sheets) to input cells + * in the evaluated workbook. + * Failure to call this method after changing cell values will cause incorrect behaviour + * of the evaluate~ methods of this class + */ + public void clearAllCachedResultValues() { + _bookEvaluator.clearAllCachedResultValues(); + } + public void notifySetFormula(Cell cell) { + _bookEvaluator.notifyUpdateCell(new XSSFEvaluationCell((XSSFCell)cell)); + } + public void notifyDeleteCell(Cell cell) { + _bookEvaluator.notifyDeleteCell(new XSSFEvaluationCell((XSSFCell)cell)); + } + + /** + * If cell contains a formula, the formula is evaluated and returned, + * else the CellValue simply copies the appropriate cell value from + * the cell and also its cell type. This method should be preferred over + * evaluateInCell() when the call should not modify the contents of the + * original cell. + * @param cell + */ + public CellValue evaluate(Cell cell) { + if (cell == null) { + return null; + } + + switch (cell.getCellType()) { + case XSSFCell.CELL_TYPE_BOOLEAN: + return CellValue.valueOf(cell.getBooleanCellValue()); + case XSSFCell.CELL_TYPE_ERROR: + return CellValue.getError(cell.getErrorCellValue()); + case XSSFCell.CELL_TYPE_FORMULA: + return evaluateFormulaCellValue(cell); + case XSSFCell.CELL_TYPE_NUMERIC: + return new CellValue(cell.getNumericCellValue()); + case XSSFCell.CELL_TYPE_STRING: + return new CellValue(cell.getRichStringCellValue().getString()); + } + throw new IllegalStateException("Bad cell type (" + cell.getCellType() + ")"); + } + + + /** + * If cell contains formula, it evaluates the formula, + * and saves the result of the formula. The cell + * remains as a formula cell. + * Else if cell does not contain formula, this method leaves + * the cell unchanged. + * Note that the type of the formula result is returned, + * so you know what kind of value is also stored with + * the formula. + * <pre> + * int evaluatedCellType = evaluator.evaluateFormulaCell(cell); + * </pre> + * Be aware that your cell will hold both the formula, + * and the result. If you want the cell replaced with + * the result of the formula, use {@link #evaluate(org.apache.poi.ss.usermodel.Cell)} } + * @param cell The cell to evaluate + * @return The type of the formula result (the cell's type remains as HSSFCell.CELL_TYPE_FORMULA however) + */ + public int evaluateFormulaCell(Cell cell) { + if (cell == null || cell.getCellType() != XSSFCell.CELL_TYPE_FORMULA) { + return -1; + } + CellValue cv = evaluateFormulaCellValue(cell); + // cell remains a formula cell, but the cached value is changed + setCellValue(cell, cv); + return cv.getCellType(); + } + + /** + * If cell contains formula, it evaluates the formula, and + * puts the formula result back into the cell, in place + * of the old formula. + * Else if cell does not contain formula, this method leaves + * the cell unchanged. + * Note that the same instance of HSSFCell is returned to + * allow chained calls like: + * <pre> + * int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType(); + * </pre> + * Be aware that your cell value will be changed to hold the + * result of the formula. If you simply want the formula + * value computed for you, use {@link #evaluateFormulaCell(org.apache.poi.ss.usermodel.Cell)} } + * @param cell + */ + public XSSFCell evaluateInCell(Cell cell) { + if (cell == null) { + return null; + } + XSSFCell result = (XSSFCell) cell; + if (cell.getCellType() == XSSFCell.CELL_TYPE_FORMULA) { + CellValue cv = evaluateFormulaCellValue(cell); + setCellType(cell, cv); // cell will no longer be a formula cell + setCellValue(cell, cv); + } + return result; + } + private static void setCellType(Cell cell, CellValue cv) { + int cellType = cv.getCellType(); + switch (cellType) { + case XSSFCell.CELL_TYPE_BOOLEAN: + case XSSFCell.CELL_TYPE_ERROR: + case XSSFCell.CELL_TYPE_NUMERIC: + case XSSFCell.CELL_TYPE_STRING: + cell.setCellType(cellType); + return; + case XSSFCell.CELL_TYPE_BLANK: + // never happens - blanks eventually get translated to zero + case XSSFCell.CELL_TYPE_FORMULA: + // this will never happen, we have already evaluated the formula + } + throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); + } + + private static void setCellValue(Cell cell, CellValue cv) { + int cellType = cv.getCellType(); + switch (cellType) { + case XSSFCell.CELL_TYPE_BOOLEAN: + cell.setCellValue(cv.getBooleanValue()); + break; + case XSSFCell.CELL_TYPE_ERROR: + cell.setCellErrorValue(cv.getErrorValue()); + break; + case XSSFCell.CELL_TYPE_NUMERIC: + cell.setCellValue(cv.getNumberValue()); + break; + case XSSFCell.CELL_TYPE_STRING: + cell.setCellValue(new XSSFRichTextString(cv.getStringValue())); + break; + case XSSFCell.CELL_TYPE_BLANK: + // never happens - blanks eventually get translated to zero + case XSSFCell.CELL_TYPE_FORMULA: + // this will never happen, we have already evaluated the formula + default: + throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); + } + } + + /** + * Loops over all cells in all sheets of the supplied + * workbook. + * For cells that contain formulas, their formulas are + * evaluated, and the results are saved. These cells + * remain as formula cells. + * For cells that do not contain formulas, no changes + * are made. + * This is a helpful wrapper around looping over all + * cells, and calling evaluateFormulaCell on each one. + */ + public static void evaluateAllFormulaCells(XSSFWorkbook wb) { + XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(wb); + for(int i=0; i<wb.getNumberOfSheets(); i++) { + Sheet sheet = wb.getSheetAt(i); + + for (Iterator<Row> rit = sheet.rowIterator(); rit.hasNext();) { + Row r = rit.next(); + + for (Iterator cit = r.cellIterator(); cit.hasNext();) { + XSSFCell c = (XSSFCell) cit.next(); + if (c.getCellType() == XSSFCell.CELL_TYPE_FORMULA) + evaluator.evaluateFormulaCell(c); + } + } + } + } + + /** + * Returns a CellValue wrapper around the supplied ValueEval instance. + */ + private CellValue evaluateFormulaCellValue(Cell cell) { + ValueEval eval = _bookEvaluator.evaluate(new XSSFEvaluationCell((XSSFCell) cell)); + if (eval instanceof NumberEval) { + NumberEval ne = (NumberEval) eval; + return new CellValue(ne.getNumberValue()); + } + if (eval instanceof BoolEval) { + BoolEval be = (BoolEval) eval; + return CellValue.valueOf(be.getBooleanValue()); + } + if (eval instanceof StringEval) { + StringEval ne = (StringEval) eval; + return new CellValue(ne.getStringValue()); + } + if (eval instanceof ErrorEval) { + return CellValue.getError(((ErrorEval)eval).getErrorCode()); + } + throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")"); + } +} diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java index 2e1394b442..f776aafe37 100755 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPicture.java @@ -223,7 +223,8 @@ public class XSSFPicture extends XSSFShape { * Return the dimension of this image
*
* @param part the package part holding raw picture data
- * @param type type of the picture: {@link Workbook#PICTURE_TYPE_JPEG, Workbook#PICTURE_TYPE_PNG or Workbook#PICTURE_TYPE_DIB)
+ * @param type type of the picture: {@link Workbook#PICTURE_TYPE_JPEG},
+ * {@link Workbook#PICTURE_TYPE_PNG} or {@link Workbook#PICTURE_TYPE_DIB}
*
* @return image dimension in pixels
*/
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java index 851c85af5d..736eea053c 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFPictureData.java @@ -101,12 +101,12 @@ public class XSSFPictureData extends POIXMLDocumentPart implements PictureData { * Return an integer constant that specifies type of this picture * * @return an integer constant that specifies type of this picture - * @see Workbook#PICTURE_TYPE_EMF - * @see Workbook#PICTURE_TYPE_WMF - * @see Workbook#PICTURE_TYPE_PICT - * @see Workbook#PICTURE_TYPE_JPEG - * @see Workbook#PICTURE_TYPE_PNG - * @see Workbook#PICTURE_TYPE_DIB + * @see org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_EMF + * @see org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_WMF + * @see org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_PICT + * @see org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_JPEG + * @see org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_PNG + * @see org.apache.poi.ss.usermodel.Workbook#PICTURE_TYPE_DIB */ public int getPictureType(){ String contentType = getPackagePart().getContentType(); diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java index 792e14ca8f..539e014d97 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java @@ -163,7 +163,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> { /** * Returns the cell at the given (0 based) index, - * with the {@link MissingCellPolicy} from the parent Workbook. + * with the {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy} from the parent Workbook. * * @return the cell at the given (0 based) index */ @@ -172,7 +172,7 @@ public class XSSFRow implements Row, Comparable<XSSFRow> { } /** - * Returns the cell at the given (0 based) index, with the specified {@link MissingCellPolicy} + * Returns the cell at the given (0 based) index, with the specified {@link org.apache.poi.ss.usermodel.Row.MissingCellPolicy} * * @return the cell at the given (0 based) index * @throws IllegalArgumentException if cellnum < 0 or the specified MissingCellPolicy is invalid diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index de59bb3fa0..5a42033634 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -254,12 +254,12 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . - * @see #PICTURE_TYPE_EMF - * @see #PICTURE_TYPE_WMF - * @see #PICTURE_TYPE_PICT - * @see #PICTURE_TYPE_JPEG - * @see #PICTURE_TYPE_PNG - * @see #PICTURE_TYPE_DIB + * @see Workbook#PICTURE_TYPE_EMF + * @see Workbook#PICTURE_TYPE_WMF + * @see Workbook#PICTURE_TYPE_PICT + * @see Workbook#PICTURE_TYPE_JPEG + * @see Workbook#PICTURE_TYPE_PNG + * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ public int addPicture(byte[] pictureData, int format) { @@ -283,12 +283,12 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X * @param format The format of the picture. * * @return the index to this picture (0 based), the added picture can be obtained from {@link #getAllPictures()} . - * @see #PICTURE_TYPE_EMF - * @see #PICTURE_TYPE_WMF - * @see #PICTURE_TYPE_PICT - * @see #PICTURE_TYPE_JPEG - * @see #PICTURE_TYPE_PNG - * @see #PICTURE_TYPE_DIB + * @see Workbook#PICTURE_TYPE_EMF + * @see Workbook#PICTURE_TYPE_WMF + * @see Workbook#PICTURE_TYPE_PICT + * @see Workbook#PICTURE_TYPE_JPEG + * @see Workbook#PICTURE_TYPE_PNG + * @see Workbook#PICTURE_TYPE_DIB * @see #getAllPictures() */ public int addPicture(InputStream is, int format) throws IOException { diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java index dd708d79b3..32d9dc62aa 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/extensions/XSSFHeaderFooter.java @@ -111,10 +111,6 @@ public abstract class XSSFHeaderFooter implements HeaderFooter { return this.headerFooter; } - /** - * - * @return - */ public String getValue() { String value = getText(); if(value == null) |