if (wb instanceof HSSFWorkbook)
helper = new HSSFHtmlHelper((HSSFWorkbook) wb);
else if (wb instanceof XSSFWorkbook)
- helper = new XSSFHtmlHelper((XSSFWorkbook) wb);
+ helper = new XSSFHtmlHelper();
else
throw new IllegalArgumentException(
"unknown workbook type: " + wb.getClass().getSimpleName());
package org.apache.poi.ss.examples.html;
import java.util.Formatter;
-import java.util.Map;
-import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFColor;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
* Implementation of {@link HtmlHelper} for XSSF files.
* @author Ken Arnold, Industrious Media LLC
*/
public class XSSFHtmlHelper implements HtmlHelper {
- private final XSSFWorkbook wb;
-
- private static final Map<Integer,HSSFColor> colors = HSSFColor.getIndexHash();
-
- public XSSFHtmlHelper(XSSFWorkbook wb) {
- this.wb = wb;
- }
-
public void colorStyles(CellStyle style, Formatter out) {
XSSFCellStyle cs = (XSSFCellStyle) style;
styleColor(out, "background-color", cs.getFillForegroundXSSFColor());
}
private void styleColor(Formatter out, String attr, XSSFColor color) {
- if (color == null || color.isAuto())
+ if (color == null || color.isAuto()) {
return;
+ }
- byte[] rgb = color.getRgb();
+ byte[] rgb = color.getRGB();
if (rgb == null) {
return;
}
// support it will ignore the rgba specification and stick with the
// solid color, which is declared first
out.format(" %s: #%02x%02x%02x;%n", attr, rgb[0], rgb[1], rgb[2]);
- byte[] argb = color.getARgb();
+ byte[] argb = color.getARGB();
if (argb == null) {
return;
}
\r
package org.apache.poi.hssf.usermodel;\r
\r
-import java.awt.*;\r
+import java.awt.BasicStroke;\r
+import java.awt.Color;\r
+import java.awt.Composite;\r
+import java.awt.Font;\r
+import java.awt.FontMetrics;\r
+import java.awt.Graphics;\r
+import java.awt.Graphics2D;\r
+import java.awt.GraphicsConfiguration;\r
+import java.awt.Image;\r
+import java.awt.Paint;\r
+import java.awt.Polygon;\r
+import java.awt.Rectangle;\r
+import java.awt.RenderingHints;\r
+import java.awt.Shape;\r
+import java.awt.Stroke;\r
import java.awt.font.FontRenderContext;\r
import java.awt.font.GlyphVector;\r
import java.awt.geom.AffineTransform;\r
import java.awt.image.ImageObserver;\r
import java.awt.image.RenderedImage;\r
import java.awt.image.renderable.RenderableImage;\r
+import java.io.PrintStream;\r
import java.text.AttributedCharacterIterator;\r
import java.util.Arrays;\r
import java.util.Map;\r
\r
-public class DummyGraphics2d\r
- extends Graphics2D\r
-{\r
+public class DummyGraphics2d extends Graphics2D {\r
private BufferedImage bufimg;\r
- private Graphics2D g2D;\r
+ private final Graphics2D g2D;\r
+ private final PrintStream log;\r
\r
- public DummyGraphics2d()\r
- {\r
+ public DummyGraphics2d() {\r
+ this(System.out);\r
+ }\r
+ \r
+ public DummyGraphics2d(PrintStream log) {\r
bufimg = new BufferedImage(1000, 1000, 2);\r
g2D = (Graphics2D)bufimg.getGraphics();\r
+ this.log = log;\r
+ }\r
+ \r
+ public DummyGraphics2d(PrintStream log, Graphics2D g2D) {\r
+ this.g2D = g2D;\r
+ this.log = log;\r
}\r
\r
- public void addRenderingHints(Map<?,?> hints)\r
- {\r
- System.out.println( "addRenderingHinds(Map):" );\r
- System.out.println( " hints = " + hints );\r
+ public void addRenderingHints(Map<?,?> hints) {\r
+ String l =\r
+ "addRenderingHinds(Map):" +\r
+ "\n hints = " + hints;\r
+ log.println( l );\r
g2D.addRenderingHints( hints );\r
}\r
\r
- public void clip(Shape s)\r
- {\r
- System.out.println( "clip(Shape):" );\r
- System.out.println( " s = " + s );\r
+ public void clip(Shape s) {\r
+ String l =\r
+ "clip(Shape):" +\r
+ "\n s = " + s;\r
+ log.println( l );\r
g2D.clip( s );\r
}\r
\r
- public void draw(Shape s)\r
- {\r
- System.out.println( "draw(Shape):" );\r
- System.out.println( "s = " + s );\r
+ public void draw(Shape s) {\r
+ String l =\r
+ "draw(Shape):" + \r
+ "\n s = " + s;\r
+ log.println( l );\r
g2D.draw( s );\r
}\r
\r
- public void drawGlyphVector(GlyphVector g, float x, float y)\r
- {\r
- System.out.println( "drawGlyphVector(GlyphVector, float, float):" );\r
- System.out.println( "g = " + g );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void drawGlyphVector(GlyphVector g, float x, float y) {\r
+ String l =\r
+ "drawGlyphVector(GlyphVector, float, float):" +\r
+ "\n g = " + g +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawGlyphVector( g, x, y );\r
}\r
\r
- public void drawImage(BufferedImage img,\r
- BufferedImageOp op,\r
- int x,\r
- int y)\r
- {\r
- System.out.println( "drawImage(BufferedImage, BufferedImageOp, x, y):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "op = " + op );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) {\r
+ String l =\r
+ "drawImage(BufferedImage, BufferedImageOp, x, y):" +\r
+ "\n img = " + img +\r
+ "\n op = " + op +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawImage( img, op, x, y );\r
}\r
\r
- public boolean drawImage(Image img,\r
- AffineTransform xform,\r
- ImageObserver obs)\r
- {\r
- System.out.println( "drawImage(Image,AfflineTransform,ImageObserver):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "xform = " + xform );\r
- System.out.println( "obs = " + obs );\r
+ public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) {\r
+ String l =\r
+ "drawImage(Image,AfflineTransform,ImageObserver):" +\r
+ "\n img = " + img +\r
+ "\n xform = " + xform +\r
+ "\n obs = " + obs;\r
+ log.println( l );\r
return g2D.drawImage( img, xform, obs );\r
}\r
\r
- public void drawRenderableImage(RenderableImage img,\r
- AffineTransform xform)\r
- {\r
- System.out.println( "drawRenderableImage(RenderableImage, AfflineTransform):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "xform = " + xform );\r
+ public void drawRenderableImage(RenderableImage img, AffineTransform xform) {\r
+ String l =\r
+ "drawRenderableImage(RenderableImage, AfflineTransform):" +\r
+ "\n img = " + img +\r
+ "\n xform = " + xform;\r
+ log.println( l );\r
g2D.drawRenderableImage( img, xform );\r
}\r
\r
- public void drawRenderedImage(RenderedImage img,\r
- AffineTransform xform)\r
- {\r
- System.out.println( "drawRenderedImage(RenderedImage, AffineTransform):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "xform = " + xform );\r
+ public void drawRenderedImage(RenderedImage img, AffineTransform xform) {\r
+ String l =\r
+ "drawRenderedImage(RenderedImage, AffineTransform):" +\r
+ "\n img = " + img +\r
+ "\n xform = " + xform;\r
+ log.println( l );\r
g2D.drawRenderedImage( img, xform );\r
}\r
\r
- public void drawString(AttributedCharacterIterator iterator,\r
- float x, float y)\r
- {\r
- System.out.println( "drawString(AttributedCharacterIterator):" );\r
- System.out.println( "iterator = " + iterator );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void drawString(AttributedCharacterIterator iterator, float x, float y) {\r
+ String l =\r
+ "drawString(AttributedCharacterIterator):" +\r
+ "\n iterator = " + iterator +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawString( iterator, x, y );\r
}\r
\r
-// public void drawString(AttributedCharacterIterator iterator,\r
-// int x, int y)\r
-// {\r
-// g2D.drawString( iterator, x, y );\r
-// }\r
-\r
- public void drawString(String s, float x, float y)\r
- {\r
- System.out.println( "drawString(s,x,y):" );\r
- System.out.println( "s = " + s );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void drawString(String s, float x, float y) {\r
+ String l =\r
+ "drawString(s,x,y):" +\r
+ "\n s = " + s +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawString( s, x, y );\r
}\r
\r
-// public void drawString(String str, int x, int y)\r
-// {\r
-// g2D.drawString( str, x, y );\r
-// }\r
-\r
- public void fill(Shape s)\r
- {\r
- System.out.println( "fill(Shape):" );\r
- System.out.println( "s = " + s );\r
+ public void fill(Shape s) {\r
+ String l =\r
+ "fill(Shape):" +\r
+ "\n s = " + s;\r
+ log.println( l );\r
g2D.fill( s );\r
}\r
\r
-// public void fill3DRect(int x, int y, int width, int height,\r
-// boolean raised) {\r
-// g2D.fill3DRect( x, y, width, height, raised );\r
-// }\r
-\r
- public Color getBackground()\r
- {\r
- System.out.println( "getBackground():" );\r
+ public Color getBackground() {\r
+ log.println( "getBackground():" );\r
return g2D.getBackground();\r
}\r
\r
- public Composite getComposite()\r
- {\r
- System.out.println( "getComposite():" );\r
+ public Composite getComposite() {\r
+ log.println( "getComposite():" );\r
return g2D.getComposite();\r
}\r
\r
- public GraphicsConfiguration getDeviceConfiguration()\r
- {\r
- System.out.println( "getDeviceConfiguration():" );\r
+ public GraphicsConfiguration getDeviceConfiguration() {\r
+ log.println( "getDeviceConfiguration():" );\r
return g2D.getDeviceConfiguration();\r
}\r
\r
- public FontRenderContext getFontRenderContext()\r
- {\r
- System.out.println( "getFontRenderContext():" );\r
+ public FontRenderContext getFontRenderContext() {\r
+ log.println( "getFontRenderContext():" );\r
return g2D.getFontRenderContext();\r
}\r
\r
- public Paint getPaint()\r
- {\r
- System.out.println( "getPaint():" );\r
+ public Paint getPaint() {\r
+ log.println( "getPaint():" );\r
return g2D.getPaint();\r
}\r
\r
- public Object getRenderingHint(RenderingHints.Key hintKey)\r
- {\r
- System.out.println( "getRenderingHint(RenderingHints.Key):" );\r
- System.out.println( "hintKey = " + hintKey );\r
+ public Object getRenderingHint(RenderingHints.Key hintKey) {\r
+ String l =\r
+ "getRenderingHint(RenderingHints.Key):" +\r
+ "\n hintKey = " + hintKey;\r
+ log.println( l );\r
return g2D.getRenderingHint( hintKey );\r
}\r
\r
- public RenderingHints getRenderingHints()\r
- {\r
- System.out.println( "getRenderingHints():" );\r
+ public RenderingHints getRenderingHints() {\r
+ log.println( "getRenderingHints():" );\r
return g2D.getRenderingHints();\r
}\r
\r
- public Stroke getStroke()\r
- {\r
- System.out.println( "getStroke():" );\r
+ public Stroke getStroke() {\r
+ log.println( "getStroke():" );\r
return g2D.getStroke();\r
}\r
\r
- public AffineTransform getTransform()\r
- {\r
- System.out.println( "getTransform():" );\r
+ public AffineTransform getTransform() {\r
+ log.println( "getTransform():" );\r
return g2D.getTransform();\r
}\r
\r
- public boolean hit(Rectangle rect,\r
- Shape s,\r
- boolean onStroke)\r
- {\r
- System.out.println( "hit(Rectangle, Shape, onStroke):" );\r
- System.out.println( "rect = " + rect );\r
- System.out.println( "s = " + s );\r
- System.out.println( "onStroke = " + onStroke );\r
+ public boolean hit(Rectangle rect, Shape s, boolean onStroke) {\r
+ String l =\r
+ "hit(Rectangle, Shape, onStroke):" +\r
+ "\n rect = " + rect +\r
+ "\n s = " + s +\r
+ "\n onStroke = " + onStroke;\r
+ log.println( l );\r
return g2D.hit( rect, s, onStroke );\r
}\r
\r
- public void rotate(double theta)\r
- {\r
- System.out.println( "rotate(theta):" );\r
- System.out.println( "theta = " + theta );\r
+ public void rotate(double theta) {\r
+ String l =\r
+ "rotate(theta):" +\r
+ "\n theta = " + theta;\r
+ log.println( l );\r
g2D.rotate( theta );\r
}\r
\r
- public void rotate(double theta, double x, double y)\r
- {\r
- System.out.println( "rotate(double,double,double):" );\r
- System.out.println( "theta = " + theta );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void rotate(double theta, double x, double y) {\r
+ String l =\r
+ "rotate(double,double,double):" +\r
+ "\n theta = " + theta +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.rotate( theta, x, y );\r
}\r
\r
- public void scale(double sx, double sy)\r
- {\r
- System.out.println( "scale(double,double):" );\r
- System.out.println( "sx = " + sx );\r
- System.out.println( "sy" );\r
+ public void scale(double sx, double sy) {\r
+ String l =\r
+ "scale(double,double):" +\r
+ "\n sx = " + sx +\r
+ "\n sy";\r
+ log.println( l );\r
g2D.scale( sx, sy );\r
}\r
\r
- public void setBackground(Color color)\r
- {\r
- System.out.println( "setBackground(Color):" );\r
- System.out.println( "color = " + color );\r
+ public void setBackground(Color color) {\r
+ String l =\r
+ "setBackground(Color):" +\r
+ "\n color = " + color;\r
+ log.println( l );\r
g2D.setBackground( color );\r
}\r
\r
- public void setComposite(Composite comp)\r
- {\r
- System.out.println( "setComposite(Composite):" );\r
- System.out.println( "comp = " + comp );\r
+ public void setComposite(Composite comp) {\r
+ String l =\r
+ "setComposite(Composite):" +\r
+ "\n comp = " + comp;\r
+ log.println( l );\r
g2D.setComposite( comp );\r
}\r
\r
- public void setPaint( Paint paint )\r
- {\r
- System.out.println( "setPaint(Paint):" );\r
- System.out.println( "paint = " + paint );\r
+ public void setPaint( Paint paint ) {\r
+ String l =\r
+ "setPaint(Paint):" +\r
+ "\n paint = " + paint;\r
+ log.println( l );\r
g2D.setPaint( paint );\r
}\r
\r
- public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue)\r
- {\r
- System.out.println( "setRenderingHint(RenderingHints.Key, Object):" );\r
- System.out.println( "hintKey = " + hintKey );\r
- System.out.println( "hintValue = " + hintValue );\r
+ public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) {\r
+ String l =\r
+ "setRenderingHint(RenderingHints.Key, Object):" +\r
+ "\n hintKey = " + hintKey +\r
+ "\n hintValue = " + hintValue;\r
+ log.println( l );\r
g2D.setRenderingHint( hintKey, hintValue );\r
}\r
\r
- public void setRenderingHints(Map<?,?> hints)\r
- {\r
- System.out.println( "setRenderingHints(Map):" );\r
- System.out.println( "hints = " + hints );\r
+ public void setRenderingHints(Map<?,?> hints) {\r
+ String l =\r
+ "setRenderingHints(Map):" +\r
+ "\n hints = " + hints;\r
+ log.println( l );\r
g2D.setRenderingHints( hints );\r
}\r
\r
- public void setStroke(Stroke s)\r
- {\r
- System.out.println( "setStroke(Stoke):" );\r
+ public void setStroke(Stroke s) {\r
+ String l;\r
if (s instanceof BasicStroke) {\r
BasicStroke bs = (BasicStroke)s;\r
- StringBuilder str = new StringBuilder("s = BasicStroke(");\r
- str.append("dash[]: "+Arrays.toString(bs.getDashArray())+", ");\r
- str.append("dashPhase: "+bs.getDashPhase()+", ");\r
- str.append("endCap: "+bs.getEndCap()+", ");\r
- str.append("lineJoin: "+bs.getLineJoin()+", ");\r
- str.append("width: "+bs.getLineWidth()+", ");\r
- str.append("miterLimit: "+bs.getMiterLimit()+")");\r
- System.out.println(str.toString());\r
+ l = "setStroke(Stoke):" +\r
+ "\n s = BasicStroke(" +\r
+ "\n dash[]: "+Arrays.toString(bs.getDashArray()) +\r
+ "\n dashPhase: "+bs.getDashPhase() +\r
+ "\n endCap: "+bs.getEndCap() +\r
+ "\n lineJoin: "+bs.getLineJoin() +\r
+ "\n width: "+bs.getLineWidth() +\r
+ "\n miterLimit: "+bs.getMiterLimit() +\r
+ "\n )";\r
} else {\r
- System.out.println( "s = " + s );\r
+ l = "setStroke(Stoke):" +\r
+ "\n s = " + s;\r
}\r
+ log.println( l );\r
g2D.setStroke( s );\r
}\r
\r
- public void setTransform(AffineTransform Tx)\r
- {\r
- System.out.println( "setTransform():" );\r
- System.out.println( "Tx = " + Tx );\r
+ public void setTransform(AffineTransform Tx) {\r
+ String l =\r
+ "setTransform():" +\r
+ "\n Tx = " + Tx;\r
+ log.println( l );\r
g2D.setTransform( Tx );\r
}\r
\r
- public void shear(double shx, double shy)\r
- {\r
- System.out.println( "shear(shx, dhy):" );\r
- System.out.println( "shx = " + shx );\r
- System.out.println( "shy = " + shy );\r
+ public void shear(double shx, double shy) {\r
+ String l =\r
+ "shear(shx, dhy):" +\r
+ "\n shx = " + shx +\r
+ "\n shy = " + shy;\r
+ log.println( l );\r
g2D.shear( shx, shy );\r
}\r
\r
- public void transform(AffineTransform Tx)\r
- {\r
- System.out.println( "transform(AffineTransform):" );\r
- System.out.println( "Tx = " + Tx );\r
+ public void transform(AffineTransform Tx) {\r
+ String l =\r
+ "transform(AffineTransform):" +\r
+ "\n Tx = " + Tx;\r
+ log.println( l );\r
g2D.transform( Tx );\r
}\r
\r
- public void translate(double tx, double ty)\r
- {\r
- System.out.println( "translate(double, double):" );\r
- System.out.println( "tx = " + tx );\r
- System.out.println( "ty = " + ty );\r
+ public void translate(double tx, double ty) {\r
+ String l =\r
+ "translate(double, double):" +\r
+ "\n tx = " + tx +\r
+ "\n ty = " + ty;\r
+ log.println( l );\r
g2D.translate( tx, ty );\r
}\r
\r
-// public void translate(int x, int y)\r
-// {\r
-// g2D.translate( x, y );\r
-// }\r
-\r
- public void clearRect(int x, int y, int width, int height)\r
- {\r
- System.out.println( "clearRect(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void clearRect(int x, int y, int width, int height) {\r
+ String l =\r
+ "clearRect(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.clearRect( x, y, width, height );\r
}\r
\r
- public void clipRect(int x, int y, int width, int height)\r
- {\r
- System.out.println( "clipRect(int, int, int, int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void clipRect(int x, int y, int width, int height) {\r
+ String l =\r
+ "clipRect(int, int, int, int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "height = " + height;\r
+ log.println( l );\r
g2D.clipRect( x, y, width, height );\r
}\r
\r
- public void copyArea(int x, int y, int width, int height,\r
- int dx, int dy)\r
- {\r
- System.out.println( "copyArea(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void copyArea(int x, int y, int width, int height, int dx, int dy) {\r
+ String l =\r
+ "copyArea(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.copyArea( x, y, width, height, dx, dy );\r
}\r
\r
- public Graphics create()\r
- {\r
- System.out.println( "create():" );\r
+ public Graphics create() {\r
+ log.println( "create():" );\r
return g2D.create();\r
}\r
\r
public Graphics create(int x, int y, int width, int height) {\r
- System.out.println( "create(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ String l =\r
+ "create(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
return g2D.create( x, y, width, height );\r
}\r
\r
- public void dispose()\r
- {\r
- System.out.println( "dispose():" );\r
+ public void dispose() {\r
+ log.println( "dispose():" );\r
g2D.dispose();\r
}\r
\r
- public void draw3DRect(int x, int y, int width, int height,\r
- boolean raised) {\r
- System.out.println( "draw3DRect(int,int,int,int,boolean):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
- System.out.println( "raised = " + raised );\r
+ public void draw3DRect(int x, int y, int width, int height, boolean raised) {\r
+ String l =\r
+ "draw3DRect(int,int,int,int,boolean):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height +\r
+ "\n raised = " + raised;\r
+ log.println( l );\r
g2D.draw3DRect( x, y, width, height, raised );\r
}\r
\r
- public void drawArc(int x, int y, int width, int height,\r
- int startAngle, int arcAngle)\r
- {\r
- System.out.println( "drawArc(int,int,int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
- System.out.println( "startAngle = " + startAngle );\r
- System.out.println( "arcAngle = " + arcAngle );\r
+ public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) {\r
+ String l =\r
+ "drawArc(int,int,int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height +\r
+ "\n startAngle = " + startAngle +\r
+ "\n arcAngle = " + arcAngle;\r
+ log.println( l );\r
g2D.drawArc( x, y, width, height, startAngle, arcAngle );\r
}\r
\r
public void drawBytes(byte data[], int offset, int length, int x, int y) {\r
- System.out.println( "drawBytes(byte[],int,int,int,int):" );\r
- System.out.println( "data = " + Arrays.toString(data) );\r
- System.out.println( "offset = " + offset );\r
- System.out.println( "length = " + length );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ String l =\r
+ "drawBytes(byte[],int,int,int,int):" +\r
+ "\n data = " + Arrays.toString(data) +\r
+ "\n offset = " + offset +\r
+ "\n length = " + length +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawBytes( data, offset, length, x, y );\r
}\r
\r
public void drawChars(char data[], int offset, int length, int x, int y) {\r
- System.out.println( "drawChars(data,int,int,int,int):" );\r
- System.out.println( "data = " + Arrays.toString(data) );\r
- System.out.println( "offset = " + offset );\r
- System.out.println( "length = " + length );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ String l =\r
+ "drawChars(data,int,int,int,int):" +\r
+ "\n data = " + Arrays.toString(data) +\r
+ "\n offset = " + offset +\r
+ "\n length = " + length +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawChars( data, offset, length, x, y );\r
}\r
\r
- public boolean drawImage(Image img,\r
- int dx1, int dy1, int dx2, int dy2,\r
- int sx1, int sy1, int sx2, int sy2,\r
- ImageObserver observer)\r
- {\r
- System.out.println( "drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "dx1 = " + dx1 );\r
- System.out.println( "dy1 = " + dy1 );\r
- System.out.println( "dx2 = " + dx2 );\r
- System.out.println( "dy2 = " + dy2 );\r
- System.out.println( "sx1 = " + sx1 );\r
- System.out.println( "sy1 = " + sy1 );\r
- System.out.println( "sx2 = " + sx2 );\r
- System.out.println( "sy2 = " + sy2 );\r
- System.out.println( "observer = " + observer );\r
+ public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, ImageObserver observer) {\r
+ String l =\r
+ "drawImage(Image,int,int,int,int,int,int,int,int,ImageObserver):" +\r
+ "\n img = " + img +\r
+ "\n dx1 = " + dx1 +\r
+ "\n dy1 = " + dy1 +\r
+ "\n dx2 = " + dx2 +\r
+ "\n dy2 = " + dy2 +\r
+ "\n sx1 = " + sx1 +\r
+ "\n sy1 = " + sy1 +\r
+ "\n sx2 = " + sx2 +\r
+ "\n sy2 = " + sy2 +\r
+ "\n observer = " + observer;\r
+ log.println( l );\r
return g2D.drawImage( img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer );\r
}\r
\r
- public boolean drawImage(Image img,\r
- int dx1, int dy1, int dx2, int dy2,\r
- int sx1, int sy1, int sx2, int sy2,\r
- Color bgcolor,\r
- ImageObserver observer)\r
- {\r
- System.out.println( "drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "dx1 = " + dx1 );\r
- System.out.println( "dy1 = " + dy1 );\r
- System.out.println( "dx2 = " + dx2 );\r
- System.out.println( "dy2 = " + dy2 );\r
- System.out.println( "sx1 = " + sx1 );\r
- System.out.println( "sy1 = " + sy1 );\r
- System.out.println( "sx2 = " + sx2 );\r
- System.out.println( "sy2 = " + sy2 );\r
- System.out.println( "bgcolor = " + bgcolor );\r
- System.out.println( "observer = " + observer );\r
+ public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, Color bgcolor, ImageObserver observer) {\r
+ String l =\r
+ "drawImage(Image,int,int,int,int,int,int,int,int,Color,ImageObserver):" +\r
+ "\n img = " + img +\r
+ "\n dx1 = " + dx1 +\r
+ "\n dy1 = " + dy1 +\r
+ "\n dx2 = " + dx2 +\r
+ "\n dy2 = " + dy2 +\r
+ "\n sx1 = " + sx1 +\r
+ "\n sy1 = " + sy1 +\r
+ "\n sx2 = " + sx2 +\r
+ "\n sy2 = " + sy2 +\r
+ "\n bgcolor = " + bgcolor +\r
+ "\n observer = " + observer;\r
+ log.println( l );\r
return g2D.drawImage( img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer );\r
}\r
\r
- public boolean drawImage(Image img, int x, int y,\r
- Color bgcolor,\r
- ImageObserver observer)\r
- {\r
- System.out.println( "drawImage(Image,int,int,Color,ImageObserver):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "bgcolor = " + bgcolor );\r
- System.out.println( "observer = " + observer );\r
+ public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) {\r
+ String l =\r
+ "drawImage(Image,int,int,Color,ImageObserver):" +\r
+ "\n img = " + img +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n bgcolor = " + bgcolor +\r
+ "\n observer = " + observer;\r
+ log.println( l );\r
return g2D.drawImage( img, x, y, bgcolor, observer );\r
}\r
\r
- public boolean drawImage(Image img, int x, int y,\r
- ImageObserver observer)\r
- {\r
- System.out.println( "drawImage(Image,int,int,observer):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "observer = " + observer );\r
+ public boolean drawImage(Image img, int x, int y, ImageObserver observer) {\r
+ String l =\r
+ "drawImage(Image,int,int,observer):" +\r
+ "\n img = " + img +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n observer = " + observer;\r
+ log.println( l );\r
return g2D.drawImage( img, x, y, observer );\r
}\r
\r
- public boolean drawImage(Image img, int x, int y,\r
- int width, int height,\r
- Color bgcolor,\r
- ImageObserver observer)\r
- {\r
- System.out.println( "drawImage(Image,int,int,int,int,Color,ImageObserver):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
- System.out.println( "bgcolor = " + bgcolor );\r
- System.out.println( "observer = " + observer );\r
+ public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) {\r
+ String l =\r
+ "drawImage(Image,int,int,int,int,Color,ImageObserver):" +\r
+ "\n img = " + img +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height +\r
+ "\n bgcolor = " + bgcolor +\r
+ "\n observer = " + observer;\r
+ log.println( l );\r
return g2D.drawImage( img, x, y, width, height, bgcolor, observer );\r
}\r
\r
- public boolean drawImage(Image img, int x, int y,\r
- int width, int height,\r
- ImageObserver observer)\r
- {\r
- System.out.println( "drawImage(Image,int,int,width,height,observer):" );\r
- System.out.println( "img = " + img );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
- System.out.println( "observer = " + observer );\r
+ public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {\r
+ String l =\r
+ "drawImage(Image,int,int,width,height,observer):" +\r
+ "\n img = " + img +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height +\r
+ "\n observer = " + observer;\r
+ log.println( l );\r
return g2D.drawImage( img, x, y, width, height, observer );\r
}\r
\r
- public void drawLine(int x1, int y1, int x2, int y2)\r
- {\r
- System.out.println( "drawLine(int,int,int,int):" );\r
- System.out.println( "x1 = " + x1 );\r
- System.out.println( "y1 = " + y1 );\r
- System.out.println( "x2 = " + x2 );\r
- System.out.println( "y2 = " + y2 );\r
+ public void drawLine(int x1, int y1, int x2, int y2) {\r
+ String l =\r
+ "drawLine(int,int,int,int):" +\r
+ "\n x1 = " + x1 +\r
+ "\n y1 = " + y1 +\r
+ "\n x2 = " + x2 +\r
+ "\n y2 = " + y2;\r
+ log.println( l );\r
g2D.drawLine( x1, y1, x2, y2 );\r
}\r
\r
- public void drawOval(int x, int y, int width, int height)\r
- {\r
- System.out.println( "drawOval(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void drawOval(int x, int y, int width, int height) {\r
+ String l =\r
+ "drawOval(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.drawOval( x, y, width, height );\r
}\r
\r
public void drawPolygon(Polygon p) {\r
- System.out.println( "drawPolygon(Polygon):" );\r
- System.out.println( "p = " + p );\r
+ String l =\r
+ "drawPolygon(Polygon):" +\r
+ "\n p = " + p;\r
+ log.println( l );\r
g2D.drawPolygon( p );\r
}\r
\r
- public void drawPolygon(int xPoints[], int yPoints[],\r
- int nPoints)\r
- {\r
- System.out.println( "drawPolygon(int[],int[],int):" );\r
- System.out.println( "xPoints = " + Arrays.toString(xPoints) );\r
- System.out.println( "yPoints = " + Arrays.toString(yPoints) );\r
- System.out.println( "nPoints = " + nPoints );\r
+ public void drawPolygon(int xPoints[], int yPoints[], int nPoints) {\r
+ String l =\r
+ "drawPolygon(int[],int[],int):" +\r
+ "\n xPoints = " + Arrays.toString(xPoints) +\r
+ "\n yPoints = " + Arrays.toString(yPoints) +\r
+ "\n nPoints = " + nPoints;\r
+ log.println( l );\r
g2D.drawPolygon( xPoints, yPoints, nPoints );\r
}\r
\r
- public void drawPolyline(int xPoints[], int yPoints[],\r
- int nPoints)\r
- {\r
- System.out.println( "drawPolyline(int[],int[],int):" );\r
- System.out.println( "xPoints = " + Arrays.toString(xPoints) );\r
- System.out.println( "yPoints = " + Arrays.toString(yPoints) );\r
- System.out.println( "nPoints = " + nPoints );\r
+ public void drawPolyline(int xPoints[], int yPoints[], int nPoints) {\r
+ String l =\r
+ "drawPolyline(int[],int[],int):" +\r
+ "\n xPoints = " + Arrays.toString(xPoints) +\r
+ "\n yPoints = " + Arrays.toString(yPoints) +\r
+ "\n nPoints = " + nPoints;\r
+ log.println( l );\r
g2D.drawPolyline( xPoints, yPoints, nPoints );\r
}\r
\r
public void drawRect(int x, int y, int width, int height) {\r
- System.out.println( "drawRect(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ String l =\r
+ "drawRect(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.drawRect( x, y, width, height );\r
}\r
\r
- public void drawRoundRect(int x, int y, int width, int height,\r
- int arcWidth, int arcHeight)\r
- {\r
- System.out.println( "drawRoundRect(int,int,int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
- System.out.println( "arcWidth = " + arcWidth );\r
- System.out.println( "arcHeight = " + arcHeight );\r
+ public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {\r
+ String l =\r
+ "drawRoundRect(int,int,int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height +\r
+ "\n arcWidth = " + arcWidth +\r
+ "\n arcHeight = " + arcHeight;\r
+ log.println( l );\r
g2D.drawRoundRect( x, y, width, height, arcWidth, arcHeight );\r
}\r
\r
- public void drawString(AttributedCharacterIterator iterator,\r
- int x, int y)\r
- {\r
- System.out.println( "drawString(AttributedCharacterIterator,int,int):" );\r
- System.out.println( "iterator = " + iterator );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void drawString(AttributedCharacterIterator iterator, int x, int y) {\r
+ String l =\r
+ "drawString(AttributedCharacterIterator,int,int):" +\r
+ "\n iterator = " + iterator +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawString( iterator, x, y );\r
}\r
\r
- public void drawString(String str, int x, int y)\r
- {\r
- System.out.println( "drawString(str,int,int):" );\r
- System.out.println( "str = " + str );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void drawString(String str, int x, int y) {\r
+ String l =\r
+ "drawString(str,int,int):" +\r
+ "\n str = " + str +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.drawString( str, x, y );\r
}\r
\r
- public void fill3DRect(int x, int y, int width, int height,\r
- boolean raised) {\r
- System.out.println( "fill3DRect(int,int,int,int,boolean):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
- System.out.println( "raised = " + raised );\r
+ public void fill3DRect(int x, int y, int width, int height, boolean raised) {\r
+ String l =\r
+ "fill3DRect(int,int,int,int,boolean):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height +\r
+ "\n raised = " + raised;\r
+ log.println( l );\r
g2D.fill3DRect( x, y, width, height, raised );\r
}\r
\r
- public void fillArc(int x, int y, int width, int height,\r
- int startAngle, int arcAngle)\r
- {\r
- System.out.println( "fillArc(int,int,int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
- System.out.println( "startAngle = " + startAngle );\r
- System.out.println( "arcAngle = " + arcAngle );\r
+ public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) {\r
+ String l =\r
+ "fillArc(int,int,int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height +\r
+ "\n startAngle = " + startAngle +\r
+ "\n arcAngle = " + arcAngle;\r
+ log.println( l );\r
g2D.fillArc( x, y, width, height, startAngle, arcAngle );\r
}\r
\r
- public void fillOval(int x, int y, int width, int height)\r
- {\r
- System.out.println( "fillOval(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void fillOval(int x, int y, int width, int height) {\r
+ String l =\r
+ "fillOval(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.fillOval( x, y, width, height );\r
}\r
\r
public void fillPolygon(Polygon p) {\r
- System.out.println( "fillPolygon(Polygon):" );\r
- System.out.println( "p = " + p );\r
+ String l =\r
+ "fillPolygon(Polygon):" +\r
+ "\n p = " + p;\r
+ log.println( l );\r
g2D.fillPolygon( p );\r
}\r
\r
- public void fillPolygon(int xPoints[], int yPoints[],\r
- int nPoints)\r
- {\r
- System.out.println( "fillPolygon(int[],int[],int):" );\r
- System.out.println( "xPoints = " + Arrays.toString(xPoints) );\r
- System.out.println( "yPoints = " + Arrays.toString(yPoints) );\r
- System.out.println( "nPoints = " + nPoints );\r
+ public void fillPolygon(int xPoints[], int yPoints[], int nPoints) {\r
+ String l =\r
+ "fillPolygon(int[],int[],int):" +\r
+ "\n xPoints = " + Arrays.toString(xPoints) +\r
+ "\n yPoints = " + Arrays.toString(yPoints) +\r
+ "\n nPoints = " + nPoints;\r
+ log.println( l );\r
g2D.fillPolygon( xPoints, yPoints, nPoints );\r
}\r
\r
- public void fillRect(int x, int y, int width, int height)\r
- {\r
- System.out.println( "fillRect(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void fillRect(int x, int y, int width, int height) {\r
+ String l =\r
+ "fillRect(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.fillRect( x, y, width, height );\r
}\r
\r
- public void fillRoundRect(int x, int y, int width, int height,\r
- int arcWidth, int arcHeight)\r
- {\r
- System.out.println( "fillRoundRect(int,int,int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) {\r
+ String l =\r
+ "fillRoundRect(int,int,int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.fillRoundRect( x, y, width, height, arcWidth, arcHeight );\r
}\r
\r
public void finalize() {\r
- System.out.println( "finalize():" );\r
- g2D.finalize();\r
-\r
+ log.println( "finalize():" );\r
+ g2D.finalize(); // NOSOLAR\r
super.finalize();\r
}\r
\r
- public Shape getClip()\r
- {\r
- System.out.println( "getClip():" );\r
+ public Shape getClip() {\r
+ log.println( "getClip():" );\r
return g2D.getClip();\r
}\r
\r
- public Rectangle getClipBounds()\r
- {\r
- System.out.println( "getClipBounds():" );\r
+ public Rectangle getClipBounds() {\r
+ log.println( "getClipBounds():" );\r
return g2D.getClipBounds();\r
}\r
\r
public Rectangle getClipBounds(Rectangle r) {\r
- System.out.println( "getClipBounds(Rectangle):" );\r
- System.out.println( "r = " + r );\r
+ String l =\r
+ "getClipBounds(Rectangle):" +\r
+ "\n r = " + r;\r
+ log.println( l );\r
return g2D.getClipBounds( r );\r
}\r
\r
- public Color getColor()\r
- {\r
- System.out.println( "getColor():" );\r
+ public Color getColor() {\r
+ log.println( "getColor():" );\r
return g2D.getColor();\r
}\r
\r
- public Font getFont()\r
- {\r
- System.out.println( "getFont():" );\r
+ public Font getFont() {\r
+ log.println( "getFont():" );\r
return g2D.getFont();\r
}\r
\r
public FontMetrics getFontMetrics() {\r
- System.out.println( "getFontMetrics():" );\r
+ log.println( "getFontMetrics():" );\r
return g2D.getFontMetrics();\r
}\r
\r
- public FontMetrics getFontMetrics(Font f)\r
- {\r
- System.out.println( "getFontMetrics():" );\r
+ public FontMetrics getFontMetrics(Font f) {\r
+ log.println( "getFontMetrics():" );\r
return g2D.getFontMetrics( f );\r
}\r
\r
public boolean hitClip(int x, int y, int width, int height) {\r
- System.out.println( "hitClip(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ String l =\r
+ "hitClip(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
return g2D.hitClip( x, y, width, height );\r
}\r
\r
- public void setClip(Shape clip)\r
- {\r
- System.out.println( "setClip(Shape):" );\r
- System.out.println( "clip = " + clip );\r
+ public void setClip(Shape clip) {\r
+ String l =\r
+ "setClip(Shape):" +\r
+ "\n clip = " + clip;\r
+ log.println( l );\r
g2D.setClip( clip );\r
}\r
\r
- public void setClip(int x, int y, int width, int height)\r
- {\r
- System.out.println( "setClip(int,int,int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
- System.out.println( "width = " + width );\r
- System.out.println( "height = " + height );\r
+ public void setClip(int x, int y, int width, int height) {\r
+ String l =\r
+ "setClip(int,int,int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y +\r
+ "\n width = " + width +\r
+ "\n height = " + height;\r
+ log.println( l );\r
g2D.setClip( x, y, width, height );\r
}\r
\r
- public void setColor(Color c)\r
- {\r
- System.out.println( "setColor():" );\r
- System.out.println( "c = " + c );\r
+ public void setColor(Color c) {\r
+ String l =\r
+ "setColor():" +\r
+ "\n c = " + c;\r
+ log.println( l );\r
g2D.setColor( c );\r
}\r
\r
- public void setFont(Font font)\r
- {\r
- System.out.println( "setFont(Font):" );\r
- System.out.println( "font = " + font );\r
+ public void setFont(Font font) {\r
+ String l =\r
+ "setFont(Font):" +\r
+ "\n font = " + font;\r
+ log.println( l );\r
g2D.setFont( font );\r
}\r
\r
- public void setPaintMode()\r
- {\r
- System.out.println( "setPaintMode():" );\r
+ public void setPaintMode() {\r
+ log.println( "setPaintMode():" );\r
g2D.setPaintMode();\r
}\r
\r
- public void setXORMode(Color c1)\r
- {\r
- System.out.println( "setXORMode(Color):" );\r
- System.out.println( "c1 = " + c1 );\r
+ public void setXORMode(Color c1) {\r
+ String l =\r
+ "setXORMode(Color):" +\r
+ "\n c1 = " + c1;\r
+ log.println( l );\r
g2D.setXORMode( c1 );\r
}\r
\r
public String toString() {\r
- System.out.println( "toString():" );\r
+ log.println( "toString():" );\r
return g2D.toString();\r
}\r
\r
- public void translate(int x, int y)\r
- {\r
- System.out.println( "translate(int,int):" );\r
- System.out.println( "x = " + x );\r
- System.out.println( "y = " + y );\r
+ public void translate(int x, int y) {\r
+ String l =\r
+ "translate(int,int):" +\r
+ "\n x = " + x +\r
+ "\n y = " + y;\r
+ log.println( l );\r
g2D.translate( x, y );\r
}\r
}\r
import java.awt.Font;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
+import org.apache.poi.util.POILogFactory;
+import org.apache.poi.util.POILogger;
+
/**
* Allows the user to lookup the font metrics for a particular font without
* actually having the font on the system. The font details are loaded as a
* font. Use a multiplier for other sizes.
*/
final class StaticFontMetrics {
+ private static final POILogger LOGGER = POILogFactory.getLogger(StaticFontMetrics.class);
/** The font metrics property file we're using */
private static Properties fontMetricsProps;
/** Our cache of font details we've already looked up */
- private static Map<String, FontDetails> fontDetailsMap = new HashMap<String, FontDetails>();
+ private static final Map<String, FontDetails> fontDetailsMap = new HashMap<String, FontDetails>();
+ private StaticFontMetrics() {}
+
/**
* Retrieves the fake font details for a given font.
*
* the font to lookup.
* @return the fake font.
*/
- public static FontDetails getFontDetails(Font font) {
+ public static synchronized FontDetails getFontDetails(Font font) {
// If we haven't already identified out font metrics file,
// figure out which one to use and load it
if (fontMetricsProps == null) {
- InputStream metricsIn = null;
- try {
- fontMetricsProps = new Properties();
-
- // Check to see if the font metric file was specified
- // as a system property
- String propFileName = null;
- try {
- propFileName = System.getProperty("font.metrics.filename");
- } catch (SecurityException e) {
- }
-
- if (propFileName != null) {
- File file = new File(propFileName);
- if (!file.exists())
- throw new FileNotFoundException(
- "font_metrics.properties not found at path "
- + file.getAbsolutePath());
- metricsIn = new FileInputStream(file);
- } else {
- // Use the built-in font metrics file off the classpath
- metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
- if (metricsIn == null)
- throw new FileNotFoundException(
- "font_metrics.properties not found in classpath");
- }
- fontMetricsProps.load(metricsIn);
- } catch (IOException e) {
- throw new RuntimeException("Could not load font metrics: " + e.getMessage());
- } finally {
- if (metricsIn != null) {
- try {
- metricsIn.close();
- } catch (IOException ignore) {
- }
- }
- }
+ try {
+ fontMetricsProps = loadMetrics();
+ } catch (IOException e) {
+ throw new RuntimeException("Could not load font metrics", e);
+ }
}
// Grab the base name of the font they've asked about
// Others have different font instances for bold etc
// (eg font.dialog.plain.* vs font.Californian FB Bold.*)
String fontStyle = "";
- if (font.isPlain())
+ if (font.isPlain()) {
fontStyle += "plain";
- if (font.isBold())
+ }
+ if (font.isBold()) {
fontStyle += "bold";
- if (font.isItalic())
+ }
+ if (font.isItalic()) {
fontStyle += "italic";
+ }
// Do we have a definition for this font with just the name?
// If not, check with the font style added
- if (fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName)) == null
- && fontMetricsProps.get(FontDetails.buildFontHeightProperty(fontName + "."
- + fontStyle)) != null) {
+ String fontHeight = FontDetails.buildFontHeightProperty(fontName);
+ String styleHeight = FontDetails.buildFontHeightProperty(fontName + "." + fontStyle);
+
+ if (fontMetricsProps.get(fontHeight) == null
+ && fontMetricsProps.get(styleHeight) != null) {
// Need to add on the style to the font name
fontName += "." + fontStyle;
}
// Get the details on this font
- if (fontDetailsMap.get(fontName) == null) {
- FontDetails fontDetails = FontDetails.create(fontName, fontMetricsProps);
+ FontDetails fontDetails = fontDetailsMap.get(fontName);
+ if (fontDetails == null) {
+ fontDetails = FontDetails.create(fontName, fontMetricsProps);
fontDetailsMap.put(fontName, fontDetails);
- return fontDetails;
}
- return fontDetailsMap.get(fontName);
+ return fontDetails;
+ }
+
+ private static Properties loadMetrics() throws IOException {
+ // Check to see if the font metric file was specified
+ // as a system property
+ File propFile = null;
+ try {
+ String propFileName = System.getProperty("font.metrics.filename");
+ if (propFileName != null) {
+ propFile = new File(propFileName);
+ if (!propFile.exists()) {
+ LOGGER.log(POILogger.WARN, "font_metrics.properties not found at path "+propFile.getAbsolutePath());
+ propFile = null;
+ }
+ }
+ } catch (SecurityException e) {
+ LOGGER.log(POILogger.WARN, "Can't access font.metrics.filename system property", e);
+ }
+
+ InputStream metricsIn = null;
+ try {
+ if (propFile != null) {
+ metricsIn = new FileInputStream(propFile);
+ } else {
+ // Use the built-in font metrics file off the classpath
+ metricsIn = FontDetails.class.getResourceAsStream("/font_metrics.properties");
+ if (metricsIn == null) {
+ String err = "font_metrics.properties not found in classpath";
+ throw new IOException(err);
+ }
+ }
+
+ Properties props = new Properties();
+ props.load(metricsIn);
+ return props;
+ } finally {
+ if (metricsIn != null) {
+ metricsIn.close();
+ }
+ }
}
}
\r
public String format(Number num) {\r
\r
- double doubleValue = num.doubleValue();\r
+ final double doubleValue = num.doubleValue();\r
\r
- boolean isNeg = (doubleValue < 0.0f) ? true : false;\r
- double absDoubleValue = Math.abs(doubleValue);\r
+ final boolean isNeg = (doubleValue < 0.0f) ? true : false;\r
+ final double absDoubleValue = Math.abs(doubleValue);\r
\r
- double wholePart = Math.floor(absDoubleValue);\r
- double decPart = absDoubleValue - wholePart;\r
+ final double wholePart = Math.floor(absDoubleValue);\r
+ final double decPart = absDoubleValue - wholePart;\r
if (wholePart + decPart == 0) {\r
return "0";\r
}\r
\r
- //if the absolute value is smaller than 1 over the exact or maxDenom\r
- //you can stop here and return "0"\r
- if (absDoubleValue < (1/Math.max(exactDenom, maxDenom))){\r
- return "0";\r
- }\r
+ // if the absolute value is smaller than 1 over the exact or maxDenom\r
+ // you can stop here and return "0"\r
+ // reciprocal is result of an int devision ... and so it's nearly always 0\r
+ // double reciprocal = 1/Math.max(exactDenom, maxDenom);\r
+ // if (absDoubleValue < reciprocal) {\r
+ // return "0";\r
+ // }\r
\r
//this is necessary to prevent overflow in the maxDenom calculation\r
- if (wholePart+(int)decPart == wholePart+decPart){\r
+ if (Double.compare(decPart, 0) == 0){\r
\r
StringBuilder sb = new StringBuilder();\r
if (isNeg){\r
sb.append("-");\r
}\r
- sb.append(Integer.toString((int)wholePart));\r
+ sb.append((int)wholePart);\r
return sb.toString();\r
}\r
\r
public InvalidFormatException(String message){
super(message);
}
+
+ public InvalidFormatException(String message, Throwable cause){
+ super(message,cause);
+ }
}
public OpenXML4JException(String msg) {
super(msg);
}
+
+ public OpenXML4JException(String msg, Throwable cause) {
+ super(msg, cause);
+ }
}
import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;
+import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Part marshallers by content type.
*/
- protected Hashtable<ContentType, PartMarshaller> partMarshallers;
+ protected Map<ContentType, PartMarshaller> partMarshallers;
/**
* Default part marshaller.
/**
* Part unmarshallers by content type.
*/
- protected Hashtable<ContentType, PartUnmarshaller> partUnmarshallers;
+ protected Map<ContentType, PartUnmarshaller> partUnmarshallers;
/**
* Core package properties.
throw new OpenXML4JRuntimeException(
"Package.init() : this exception should never happen, " +
"if you read this message please send a mail to the developers team. : " +
- e.getMessage()
+ e.getMessage(),
+ e
);
}
}
*/
public static OPCPackage open(String path, PackageAccess access)
throws InvalidFormatException {
- if (path == null || "".equals(path.trim()))
+ if (path == null || "".equals(path.trim())) {
throw new IllegalArgumentException("'path' must be given");
+ }
File file = new File(path);
- if (file.exists() && file.isDirectory())
+ if (file.exists() && file.isDirectory()) {
throw new IllegalArgumentException("path must not be a directory");
+ }
OPCPackage pack = new ZipPackage(path, access);
if (pack.partList == null && access != PackageAccess.WRITE) {
* @return A newly created PackageBase ready to use.
*/
public static OPCPackage create(File file) {
- if (file == null || (file.exists() && file.isDirectory()))
+ if (file == null || (file.exists() && file.isDirectory())) {
throw new IllegalArgumentException("file");
+ }
if (file.exists()) {
throw new InvalidOperationException(
*/
public void addThumbnail(String path) throws IOException {
// Check parameter
- if ("".equals(path))
+ if ("".equals(path)) {
throw new IllegalArgumentException("path");
+ }
// Get the filename from the path
String filename = path
+ path.substring(path.lastIndexOf(".") + 1));
} catch (InvalidFormatException e2) {
throw new InvalidOperationException(
- "Can't add a thumbnail file named '" + filename + "'");
+ "Can't add a thumbnail file named '" + filename + "'", e2);
}
}
* @see org.apache.poi.openxml4j.opc.PackageAccess
*/
void throwExceptionIfReadOnly() throws InvalidOperationException {
- if (packageAccess == PackageAccess.READ)
+ if (packageAccess == PackageAccess.READ) {
throw new InvalidOperationException(
"Operation not allowed, document open in read only mode!");
+ }
}
/**
* @see org.apache.poi.openxml4j.opc.PackageAccess
*/
void throwExceptionIfWriteOnly() throws InvalidOperationException {
- if (packageAccess == PackageAccess.WRITE)
+ if (packageAccess == PackageAccess.WRITE) {
throw new InvalidOperationException(
"Operation not allowed, document open in write only mode!");
+ }
}
/**
public PackagePart getPart(PackagePartName partName) {
throwExceptionIfWriteOnly();
- if (partName == null)
+ if (partName == null) {
throw new IllegalArgumentException("partName");
+ }
// If the partlist is null, then we parse the package.
if (partList == null) {
public ArrayList<PackagePart> getPartsByContentType(String contentType) {
ArrayList<PackagePart> retArr = new ArrayList<PackagePart>();
for (PackagePart part : partList.values()) {
- if (part.getContentType().equals(contentType))
+ if (part.getContentType().equals(contentType)) {
retArr.add(part);
+ }
}
Collections.sort(retArr);
return retArr;
*/
public ArrayList<PackagePart> getPartsByRelationshipType(
String relationshipType) {
- if (relationshipType == null)
+ if (relationshipType == null) {
throw new IllegalArgumentException("relationshipType");
+ }
ArrayList<PackagePart> retArr = new ArrayList<PackagePart>();
for (PackageRelationship rel : getRelationshipsByType(relationshipType)) {
PackagePart part = getPart(rel);
PackagePart[] parts = this.getPartsImpl();
this.partList = new PackagePartCollection();
for (PackagePart part : parts) {
- if (partList.containsKey(part._partName))
+ if (partList.containsKey(part._partName)) {
throw new InvalidFormatException(
"A part with the name '" +
part._partName +
"' already exist : Packages shall not contain equivalent " +
"part names and package implementers shall neither create " +
"nor recognize packages with equivalent part names. [M1.12]");
+ }
// Check OPC compliance rule M4.1
if (part.getContentType().equals(
+ part._partName);
continue;
} catch (InvalidOperationException invoe) {
- throw new InvalidFormatException(invoe.getMessage());
+ throw new InvalidFormatException(invoe.getMessage(), invoe);
}
} else {
try {
partList.put(part._partName, part);
} catch (InvalidOperationException e) {
- throw new InvalidFormatException(e.getMessage());
+ throw new InvalidFormatException(e.getMessage(), e);
}
}
}
// Note - POI will read files with more than one Core Properties, which
// Office sometimes produces, but is strict on generation
if (contentType.equals(ContentTypes.CORE_PROPERTIES_PART)) {
- if (this.packageProperties != null)
+ if (this.packageProperties != null) {
throw new InvalidOperationException(
"OPC Compliance error [M4.1]: you try to add more than one core properties relationship in the package !");
+ }
}
/* End check OPC compliance */
*/
public void removePart(PackagePartName partName) {
throwExceptionIfReadOnly();
- if (partName == null || !this.containPart(partName))
+ if (partName == null || !this.containPart(partName)) {
throw new IllegalArgumentException("partName");
+ }
// Delete the specified part from the package.
if (this.partList.containsKey(partName)) {
clearRelationships();
} else if (containPart(sourcePartName)) {
PackagePart part = getPart(sourcePartName);
- if (part != null)
+ if (part != null) {
part.clearRelationships();
+ }
}
}
* Name of the part to delete
*/
public void deletePart(PackagePartName partName) {
- if (partName == null)
+ if (partName == null) {
throw new IllegalArgumentException("partName");
+ }
// Remove the part
this.removePart(partName);
* Name of the part to delete
*/
public void deletePartRecursive(PackagePartName partName) {
- if (partName == null || !this.containPart(partName))
+ if (partName == null || !this.containPart(partName)) {
throw new IllegalArgumentException("partName");
+ }
PackagePart partToDelete = this.getPart(partName);
// Remove the part
// Remove the relationships part
PackagePartName relationshipPartName = PackagingURIHelper
.getRelationshipPartName(partName);
- if (relationshipPartName != null && containPart(relationshipPartName))
+ if (relationshipPartName != null && containPart(relationshipPartName)) {
this.removePart(relationshipPartName);
+ }
}
/**
// relationship for a package to be an error. If present, the
// relationship shall target the Core Properties part.
if (relationshipType.equals(PackageRelationshipTypes.CORE_PROPERTIES)
- && this.packageProperties != null)
+ && this.packageProperties != null) {
throw new InvalidOperationException(
"OPC Compliance error [M4.1]: can't add another core properties part ! Use the built-in package method instead.");
+ }
/*
* Check rule M1.25: The Relationships part shall not have relationships
*/
public boolean isRelationshipExists(PackageRelationship rel) {
for (PackageRelationship r : this.getRelationships()) {
- if (r == rel)
+ if (r == rel) {
return true;
+ }
}
return false;
}
* The content type associated with the marshaller to remove.
*/
public void removeMarshaller(String contentType) {
- partMarshallers.remove(contentType);
+ try {
+ partMarshallers.remove(new ContentType(contentType));
+ } catch (InvalidFormatException e) {
+ throw new RuntimeException(e);
+ }
}
/**
* The content type associated with the unmarshaller to remove.
*/
public void removeUnmarshaller(String contentType) {
- partUnmarshallers.remove(contentType);
+ try {
+ partUnmarshallers.remove(new ContentType(contentType));
+ } catch (InvalidFormatException e) {
+ throw new RuntimeException(e);
+ }
}
/* Accesseurs */
* @see #save(OutputStream)
*/
public void save(File targetFile) throws IOException {
- if (targetFile == null)
+ if (targetFile == null) {
throw new IllegalArgumentException("targetFile");
+ }
this.throwExceptionIfReadOnly();
FileOutputStream fos = null;
try {
fos = new FileOutputStream(targetFile);
- } catch (FileNotFoundException e) {
- throw new IOException(e.getLocalizedMessage());
- }
- try {
this.save(fos);
} finally {
- fos.close();
+ if (fos != null) fos.close();
}
}
* A boolean value indicating if the ctColor has a tint or not
*/
public boolean hasTint() {
- if (! ctColor.isSetRgb()) return false;
+ if (! ctColor.isSetRgb()) {
+ return false;
+ }
return ctColor.getRgb().length == 4;
}
/**
* Indexed ctColor value. Only used for backwards compatibility. References a ctColor in indexedColors.
*/
+ @Override
public short getIndex() {
return (short)ctColor.getIndexed();
}
* Standard Red Green Blue ctColor value (RGB).
* If there was an A (Alpha) value, it will be stripped.
*/
+ @Override
public byte[] getRGB() {
byte[] rgb = getRGBOrARGB();
- if(rgb == null) return null;
+ if(rgb == null) {
+ return null;
+ }
if(rgb.length == 4) {
// Need to trim off the alpha
return rgb;
}
}
- /**
- * @deprecated use {@link #getRGB()}
- */
- public byte[] getRgb() {
- return getRGB();
- }
/**
* Standard Alpha Red Green Blue ctColor value (ARGB).
*/
+ @Override
public byte[] getARGB() {
byte[] rgb = getRGBOrARGB();
- if(rgb == null) return null;
+ if(rgb == null) {
+ return null;
+ }
if(rgb.length == 3) {
// Pad with the default Alpha
return rgb;
}
}
- /**
- * @deprecated Use {@link #getARGB()}
- */
- public byte[] getARgb() {
- return getARGB();
- }
+ @Override
protected byte[] getStoredRBG() {
return ctColor.getRgb();
}
- /**
- * Standard Red Green Blue ctColor value (RGB) with applied tint.
- * Alpha values are ignored.
- */
- public byte[] getRgbWithTint() {
- return getRGBWithTint();
- }
-
- /**
- * Standard Alpha Red Green Blue ctColor value (ARGB).
- */
- public void setRgb(byte[] rgb) {
- setRGB(rgb);
- }
/**
* Standard Alpha Red Green Blue ctColor value (ARGB).
*/
+ @Override
public void setRGB(byte[] rgb) {
ctColor.setRgb(rgb);
}
* Index into the <clrScheme> collection, referencing a particular <sysClr> or
* <srgbClr> value expressed in the Theme part.
*/
+ @Override
public int getTheme() {
return (int)ctColor.getTheme();
}
*
* @return the tint value
*/
+ @Override
public double getTint() {
return ctColor.getTint();
}
*
* @param tint the tint value
*/
+ @Override
public void setTint(double tint) {
ctColor.setTint(tint);
}
return (XSSFColor)color;
}
+ @Override
public int hashCode(){
return ctColor.toString().hashCode();
}
+ @Override
public boolean equals(Object o){
- if(o == null || !(o instanceof XSSFColor)) return false;
+ if(!(o instanceof XSSFColor)) {
+ return false;
+ }
XSSFColor cf = (XSSFColor)o;
return ctColor.toString().equals(cf.getCTColor().toString());
import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.openxml4j.exceptions.InvalidOperationException;
+import org.apache.poi.openxml4j.exceptions.OpenXML4JException;
import org.apache.poi.openxml4j.opc.OPCPackage;
import org.apache.poi.openxml4j.opc.PackageAccess;
import org.apache.poi.openxml4j.opc.PackagePart;
import org.apache.poi.ss.formula.eval.NumberEval;
import org.apache.poi.ss.formula.eval.ValueEval;
import org.apache.poi.ss.formula.functions.Function;
-import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
+import org.apache.poi.ss.usermodel.CellValue;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Comment;
+import org.apache.poi.ss.usermodel.CreationHelper;
+import org.apache.poi.ss.usermodel.DataFormat;
+import org.apache.poi.ss.usermodel.DataFormatter;
+import org.apache.poi.ss.usermodel.DateUtil;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Font;
+import org.apache.poi.ss.usermodel.FormulaError;
+import org.apache.poi.ss.usermodel.FormulaEvaluator;
+import org.apache.poi.ss.usermodel.Hyperlink;
+import org.apache.poi.ss.usermodel.IndexedColors;
+import org.apache.poi.ss.usermodel.Name;
+import org.apache.poi.ss.usermodel.PrintSetup;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.SheetConditionalFormatting;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.AreaReference;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.CellReference;
import org.apache.poi.xssf.model.CalculationChain;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
+import org.apache.xmlbeans.XmlException;
import org.junit.Ignore;
import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcCell;
* open resulting file in Excel to check results!
*/
@Test
- public void bug15375_2() throws Exception {
+ public void bug15375_2() throws IOException {
bug15375(1000);
}
* the wrong sheet name
*/
@Test
- public void bug45430() throws Exception {
+ public void bug45430() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("45430.xlsx");
assertFalse(wb.isMacroEnabled());
assertEquals(3, wb.getNumberOfNames());
/**
* We should carry vba macros over after save
+ * @throws InvalidFormatException
*/
@Test
- public void bug45431() throws Exception {
+ public void bug45431() throws IOException, InvalidFormatException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("45431.xlsm");
OPCPackage pkg1 = wb1.getPackage();
assertTrue(wb1.isMacroEnabled());
}
@Test
- public void bug47504() throws Exception {
+ public void bug47504() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("47504.xlsx");
assertEquals(1, wb1.getNumberOfSheets());
XSSFSheet sh = wb1.getSheetAt(0);
* read the file despite the naughtyness
*/
@Test
- public void bug49020() throws Exception {
+ public void bug49020() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("BrNotClosed.xlsx");
wb.close();
}
* ensure that CTPhoneticPr is loaded by the ooxml test suite so that it is included in poi-ooxml-schemas
*/
@Test
- public void bug49325() throws Exception {
+ public void bug49325() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49325.xlsx");
CTWorksheet sh = wb.getSheetAt(0).getCTWorksheet();
assertNotNull(sh.getPhoneticPr());
* should return that sheet index properly
*/
@Test
- public void bug48923() throws Exception {
+ public void bug48923() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48923.xlsx");
assertEquals(4, wb.getNumberOfNames());
* TODO: delete this test case when MROUND and VAR are implemented
*/
@Test
- public void bug48539() throws Exception {
+ public void bug48539() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48539.xlsx");
try {
assertEquals(3, wb.getNumberOfSheets());
* a theme is used
*/
@Test
- public void bug48779() throws Exception {
+ public void bug48779() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
XSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0);
XSSFCellStyle cs = cell.getCellStyle();
* for integers
*/
@Test
- public void bug47490() throws Exception {
+ public void bug47490() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("GeneralFormatTests.xlsx");
Sheet s = wb.getSheetAt(1);
Row r;
* The OPC spec tolerates both of these peculiarities, so does POI
*/
@Test
- public void bug49609() throws Exception {
+ public void bug49609() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("49609.xlsx");
assertEquals("FAM", wb.getSheetName(0));
assertEquals("Cycle", wb.getSheetAt(0).getRow(0).getCell(1).getStringCellValue());
}
@Test
- public void bug49783() throws Exception {
+ public void bug49783() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("49783.xlsx");
Sheet sheet = wb.getSheetAt(0);
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
* with something like "helloworld" !
*/
@Test
- public void bug49941() throws Exception {
+ public void bug49941() throws IOException {
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFSheet s = wb1.createSheet();
XSSFRow r = s.createRow(0);
* Repeatedly writing the same file which has styles
*/
@Test
- public void bug49940() throws Exception {
+ public void bug49940() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
assertEquals(3, wb.getNumberOfSheets());
assertEquals(10, wb.getStylesSource().getNumCellStyles());
* entry.
*/
@Test
- public void bug49966() throws Exception {
+ public void bug49966() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples
.openSampleWorkbook("shared_formulas.xlsx");
XSSFSheet sheet = wb1.getSheetAt(0);
}
@Test
- public void bug49966Row() throws Exception {
+ public void bug49966Row() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples
.openSampleWorkbook("shared_formulas.xlsx");
XSSFSheet sheet = wb.getSheetAt(0);
}
@Test
- public void bug49156() throws Exception {
+ public void bug49156() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("49156.xlsx");
FormulaEvaluator formulaEvaluator = wb.getCreationHelper().createFormulaEvaluator();
* Newlines are valid characters in a formula
*/
@Test
- public void bug50440And51875() throws Exception {
+ public void bug50440And51875() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("NewlineInFormulas.xlsx");
Sheet s = wb.getSheetAt(0);
Cell c = s.getRow(0).getCell(0);
* Moving a cell comment from one cell to another
*/
@Test
- public void bug50795() throws Exception {
+ public void bug50795() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("50795.xlsx");
XSSFSheet sheet = wb1.getSheetAt(0);
XSSFRow row = sheet.getRow(0);
* For those cases, ensure we don't break on reading the colour
*/
@Test
- public void bug50299() throws Exception {
+ public void bug50299() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
// Check all the colours
/**
* Excel .xls style indexed colours in a .xlsx file
*/
- @SuppressWarnings("deprecation")
@Test
- public void bug50786() throws Exception {
+ public void bug50786() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50786-indexed_colours.xlsx");
XSSFSheet s = wb.getSheetAt(0);
XSSFRow r = s.getRow(2);
XSSFCellStyle cs = c.getCellStyle();
assertEquals(42, cs.getFillForegroundColor());
assertEquals(42, cs.getFillForegroundColorColor().getIndexed());
- assertNotNull(cs.getFillForegroundColorColor().getRgb());
+ assertNotNull(cs.getFillForegroundColorColor().getRGB());
assertEquals("FFCCFFCC", cs.getFillForegroundColorColor().getARGBHex());
wb.close();
}
* should still be able to get colours
*/
@Test
- public void bug50846() throws Exception {
+ public void bug50846() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50846-border_colours.xlsx");
XSSFSheet sheet = wb.getSheetAt(0);
* then being set explicitly still should allow the
* fetching of the RGB.
*/
- @SuppressWarnings("deprecation")
@Test
- public void bug50784() throws Exception {
+ public void bug50784() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50784-font_theme_colours.xlsx");
XSSFSheet s = wb.getSheetAt(0);
XSSFRow r = s.getRow(0);
XSSFColor colr = fr.getXSSFColor();
// No theme, has colours
assertEquals(0, colr.getTheme());
- assertNotNull( colr.getRgb() );
+ assertNotNull( colr.getRGB() );
// Column 0 has a font with colours from a theme
XSSFCell ct = r.getCell(0);
// Has a theme, which has the colours on it
assertEquals(9, colt.getTheme());
XSSFColor themeC = wb.getTheme().getThemeColor(colt.getTheme());
- assertNotNull( themeC.getRgb() );
- assertNotNull( colt.getRgb() );
+ assertNotNull( themeC.getRGB() );
+ assertNotNull( colt.getRGB() );
assertEquals( themeC.getARGBHex(), colt.getARGBHex() ); // The same colour
wb.close();
}
* a rich text string
*/
@Test
- public void bug48877() throws Exception {
+ public void bug48877() throws IOException {
String text = "Use \n with word wrap on to create a new line.\n" +
"This line finishes with two trailing spaces. ";
* Adding sheets when one has a table, then re-ordering
*/
@Test
- public void bug50867() throws Exception {
+ public void bug50867() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("50867_with_table.xlsx");
assertEquals(3, wb1.getNumberOfSheets());
*/
@SuppressWarnings("deprecation")
@Test
- public void bug49253() throws Exception {
+ public void bug49253() throws IOException {
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFWorkbook wb2 = new XSSFWorkbook();
* Default Column style
*/
@Test
- public void bug51037() throws Exception {
+ public void bug51037() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet s = wb.createSheet();
* Something with the SharedStringsTable currently breaks...
*/
@Test
- public void bug46662() throws Exception {
+ public void bug46662() throws IOException {
// New file
XSSFWorkbook wb1 = new XSSFWorkbook();
XSSFTestDataSamples.writeOutAndReadBack(wb1).close();
* Colours and styles when the list has gaps in it
*/
@Test
- public void bug51222() throws Exception {
+ public void bug51222() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51222.xlsx");
XSSFSheet s = wb.getSheetAt(0);
}
@Test
- public void bug51470() throws Exception {
+ public void bug51470() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51470.xlsx");
XSSFSheet sh0 = wb.getSheetAt(0);
XSSFSheet sh1 = wb.cloneSheet(0);
* comments (so /xl/comments1.xml is taken)
*/
@Test
- public void bug51850() throws Exception {
+ public void bug51850() throws IOException {
XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("51850.xlsx");
XSSFSheet sh1 = wb1.getSheetAt(0);
XSSFSheet sh2 = wb1.getSheetAt(1);
* Sheet names with a , in them
*/
@Test
- public void bug51963() throws Exception {
+ public void bug51963() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("51963.xlsx");
Sheet sheet = wb.getSheetAt(0);
assertEquals("Abc,1", sheet.getSheetName());
* DISABLED As we can't currently evaluate these
*/
@Ignore
- public void bug48703() throws Exception {
+ public void bug48703() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48703.xlsx");
XSSFSheet sheet = wb.getSheetAt(0);
* Bugzilla 51710: problems reading shared formuals from .xlsx
*/
@Test
- public void bug51710() throws Exception {
+ public void bug51710() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51710.xlsx");
final String[] columns = {"A","B","C","D","E","F","G","H","I","J","K","L","M","N"};
* Bug 53101:
*/
@Test
- public void bug5301() throws Exception {
+ public void bug5301() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53101.xlsx");
FormulaEvaluator evaluator =
wb.getCreationHelper().createFormulaEvaluator();
}
@Test
- public void bug54436() throws Exception {
+ public void bug54436() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("54436.xlsx");
if(!WorkbookEvaluator.getSupportedFunctionNames().contains("GETPIVOTDATA")){
Function func = new Function() {
* error message when called via WorkbookFactory with no password
*/
@Test(expected=EncryptedDocumentException.class)
- public void bug55692_poifs() throws Exception {
+ public void bug55692_poifs() throws IOException {
// Via a POIFSFileSystem
POIFSFileSystem fsP = new POIFSFileSystem(
POIDataSamples.getPOIFSInstance().openResourceAsStream("protect.xlsx"));
}
@Test
- public void bug55692_stream() throws Exception {
+ public void bug55692_stream() throws IOException, InvalidFormatException {
// Directly on a Stream, will go via NPOIFS and spot it's
// actually a .xlsx file encrypted with the default password, and open
Workbook wb = WorkbookFactory.create(
}
@Test
- public void bug55692_npoifs() throws Exception {
+ public void bug55692_npoifs() throws IOException {
// Via a NPOIFSFileSystem, will spot it's actually a .xlsx file
// encrypted with the default password, and open
NPOIFSFileSystem fsNP = new NPOIFSFileSystem(
}
@Test
- public void bug53282() throws Exception {
+ public void bug53282() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53282b.xlsx");
Cell c = wb.getSheetAt(0).getRow(1).getCell(0);
assertEquals("#@_#", c.getStringCellValue());
* due to a lack of Styles Table
*/
@Test
- public void bug56278() throws Exception {
+ public void bug56278() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56278.xlsx");
assertEquals(0, wb.getSheetIndex("Market Rates"));
}
@Test
- public void bug56315() throws Exception {
+ public void bug56315() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56315.xlsx");
Cell c = wb.getSheetAt(0).getRow(1).getCell(0);
CellValue cv = wb.getCreationHelper().createFormulaEvaluator().evaluate(c);
}
@Test
- public void bug56468() throws Exception {
+ public void bug56468() throws IOException, InterruptedException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet();
XSSFRow row = sheet.createRow(0);
* SUMIF was throwing a NPE on some formulas
*/
@Test
- public void testBug56420SumIfNPE() throws Exception {
+ public void testBug56420SumIfNPE() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56420.xlsx");
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
* with DataFormatter
*/
@Test
- public void bug56702() throws Exception {
+ public void bug56702() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("56702.xlsx");
Sheet sheet = wb.getSheetAt(0);
}
FileOutputStream fileOutStream = new FileOutputStream(outFile);
- wb.write(fileOutStream);
- fileOutStream.close();
- //System.out.println("File \""+outFile.getName()+"\" has been saved successfully");
+ try {
+ wb.write(fileOutStream);
+ } finally {
+ fileOutStream.close();
+ }
FileInputStream is = new FileInputStream(outFile);
try {
}
assertNotNull(newWB.getSheet("test"));
} finally {
- newWB.close();
+ if (newWB != null) {
+ newWB.close();
+ }
}
} finally {
is.close();
}
@Test
- public void testBug56688_1() throws Exception {
+ public void testBug56688_1() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_1.xlsx");
checkValue(excel, "-1.0"); /* Not 0.0 because POI sees date "0" minus one month as invalid date, which is -1! */
excel.close();
}
@Test
- public void testBug56688_2() throws Exception {
+ public void testBug56688_2() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_2.xlsx");
checkValue(excel, "#VALUE!");
excel.close();
}
@Test
- public void testBug56688_3() throws Exception {
+ public void testBug56688_3() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_3.xlsx");
checkValue(excel, "#VALUE!");
excel.close();
}
@Test
- public void testBug56688_4() throws Exception {
+ public void testBug56688_4() throws IOException {
XSSFWorkbook excel = XSSFTestDataSamples.openSampleWorkbook("56688_4.xlsx");
Calendar calendar = LocaleUtil.getLocaleCalendar();
* function in another file
*/
@Test
- public void bug56502() throws Exception {
+ public void bug56502() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56502.xlsx");
Sheet sheet = wb.getSheetAt(0);
}
@Test
- public void bug54764() throws Exception {
+ public void bug54764() throws IOException, OpenXML4JException, XmlException {
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("54764.xlsx");
// Check the core properties - will be found but empty, due
* poi-ooxml-schemas jar
*/
@Test
- public void bug57176() throws Exception {
+ public void bug57176() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57176.xlsx");
CTDefinedNames definedNames = wb.getCTWorkbook().getDefinedNames();
List<CTDefinedName> definedNameList = definedNames.getDefinedNameList();
/**
* .xlsb files are not supported, but we should generate a helpful
* error message if given one
+ * @throws InvalidFormatException
+ * @throws
*/
@Test
- public void bug56800_xlsb() throws Exception {
+ public void bug56800_xlsb() throws IOException, InvalidFormatException {
// Can be opened at the OPC level
OPCPackage pkg = XSSFTestDataSamples.openSamplePackage("Simple.xlsb");
}
@Test
- public void test57196_Detail() throws Exception {
+ public void test57196_Detail() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Sheet1");
XSSFRow row = sheet.createRow(0);
}
@Test
- public void test57196_Detail2() throws Exception {
+ public void test57196_Detail2() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sheet = wb.createSheet("Sheet1");
XSSFRow row = sheet.createRow(0);
}
@Test
- public void test57196_WorkbookEvaluator() throws Exception {
+ public void test57196_WorkbookEvaluator() throws IOException {
String previousLogger = System.getProperty("org.apache.poi.util.POILogger");
//System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
//System.setProperty("poi.log.level", "3");
/**
* A .xlsx file with no Shared Strings table should open fine
* in read-only mode
+ * @throws InvalidFormatException
*/
@SuppressWarnings("resource")
@Test
- public void bug57482() throws Exception {
+ public void bug57482() throws IOException, InvalidFormatException {
for (PackageAccess access : new PackageAccess[] {
PackageAccess.READ_WRITE, PackageAccess.READ
}) {
OPCPackage pkg = OPCPackage.open(file, access);
try {
// Try to open it and read the contents
- XSSFWorkbook wb = new XSSFWorkbook(pkg);
- assertNotNull(wb.getSharedStringSource());
- assertEquals(0, wb.getSharedStringSource().getCount());
+ XSSFWorkbook wb1 = new XSSFWorkbook(pkg);
+ assertNotNull(wb1.getSharedStringSource());
+ assertEquals(0, wb1.getSharedStringSource().getCount());
DataFormatter fmt = new DataFormatter();
- XSSFSheet s = wb.getSheetAt(0);
+ XSSFSheet s = wb1.getSheetAt(0);
assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
// Try to write-out and read again, should only work
// in read-write mode, not read-only mode
+ XSSFWorkbook wb2 = null;
try {
- wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
- if (access == PackageAccess.READ)
+ wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
+ if (access == PackageAccess.READ) {
fail("Shouln't be able to write from read-only mode");
+ }
+
+ // Check again
+ s = wb2.getSheetAt(0);
+ assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
+ assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
+ assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
+ assertEquals("Testing", fmt.formatCellValue(s.getRow(0).getCell(3)));
+
} catch (InvalidOperationException e) {
- if (access == PackageAccess.READ) {
- // Expected
- } else {
+ if (access == PackageAccess.READ_WRITE) {
// Shouldn't occur in write-mode
throw e;
}
+ } finally {
+ if (wb2 != null) {
+ wb2.getPackage().revert();
+ }
}
-
- // Check again
- s = wb.getSheetAt(0);
- assertEquals("1", fmt.formatCellValue(s.getRow(0).getCell(0)));
- assertEquals("11", fmt.formatCellValue(s.getRow(0).getCell(1)));
- assertEquals("5", fmt.formatCellValue(s.getRow(4).getCell(0)));
- assertEquals("Testing", fmt.formatCellValue(s.getRow(0).getCell(3)));
+
+ wb1.getPackage().revert();
} finally {
pkg.revert();
}
* "Unknown error type: -60" fetching formula error value
*/
@Test
- public void bug57535() throws Exception {
+ public void bug57535() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57535.xlsx");
FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
evaluator.clearAllCachedResultValues();
*/
@Test
@Ignore("XMLBeans namespace mis-match on ooxml-strict files")
- public void test57699() throws Exception {
+ public void test57699() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("sample.strict.xlsx");
assertEquals(3, wb.getNumberOfSheets());
// TODO Check sheet contents
* Excel treats this as not-bulleted, so now do we
*/
@Test
- public void testBug57826() throws Exception {
+ public void testBug57826() throws IOException {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("57826.xlsx");
assertTrue("no sheets in workbook", workbook.getNumberOfSheets() >= 1);
}
@Test
- public void bug57642() throws Exception {
+ public void bug57642() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet s = wb.createSheet("TestSheet");
XSSFCell c = s.createRow(0).createCell(0);
/**
* .xlsx supports 64000 cell styles, the style indexes after
* 32,767 must not be -32,768, then -32,767, -32,766
+ * @throws InvalidFormatException
*/
@Test
- public void bug57880() throws Exception {
+ public void bug57880() throws IOException, InvalidFormatException {
int numStyles = 33000;
XSSFWorkbook wb = new XSSFWorkbook();
//XSSFSheet s = wb.createSheet("TestSheet");
data.put("4", new Object[] {4, "John", "Adwards"});
data.put("5", new Object[] {2, "Brian", "Schultz"});
- Set<String> keyset = data.keySet();
int rownum = 1;
- for (String key : keyset)
- {
+ for (Map.Entry<String,Object[]> me : data.entrySet()) {
final Row row;
if(createRow) {
row = sheet.createRow(rownum++);
}
assertNotNull(row);
- Object [] objArr = data.get(key);
int cellnum = 0;
- for (Object obj : objArr)
- {
+ for (Object obj : me.getValue()) {
Cell cell = row.getCell(cellnum);
if(cell == null){
cell = row.createCell(cellnum);
assertFalse(calc.getR().equals("A6"));
}
- /*FileOutputStream out = new FileOutputStream(new File("C:\\temp\\56574.xlsx"));
- try {
- wb.write(out);
- } finally {
- out.close();
- }*/
-
Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
Sheet sheetBack = wbBack.getSheet("Func");
assertNotNull(sheetBack);
* Excel 2007 generated Macro-Enabled .xlsm file
*/
@Test
- public void bug57181() throws Exception {
+ public void bug57181() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57181.xlsm");
assertEquals(9, wb.getNumberOfSheets());
wb.close();
}
@Test
- public void bug52111() throws Exception {
+ public void bug52111() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("Intersection-52111-xssf.xlsx");
Sheet s = wb.getSheetAt(0);
assertFormula(wb, s.getRow(2).getCell(0), "(C2:D3 D3:E4)", "4.0");
}
@Test
- public void test48962() throws Exception {
+ public void test48962() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("48962.xlsx");
Sheet sh = wb.getSheetAt(0);
Row row = sh.getRow(1);
}
@Test
- public void test50755_workday_formula_example() throws Exception {
+ public void test50755_workday_formula_example() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("50755_workday_formula_example.xlsx");
Sheet sheet = wb.getSheet("Sheet1");
for(Row aRow : sheet) {
}
@Test
- public void test51626() throws Exception {
+ public void test51626() throws IOException, InvalidFormatException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("51626.xlsx");
assertNotNull(wb);
wb.close();
}
@Test
- public void test55406() throws Exception {
+ public void test55406() throws IOException {
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("55406_Conditional_formatting_sample.xlsx");
Sheet sheet = wb.getSheetAt(0);
Cell cellA1 = sheet.getRow(0).getCell(0);
package org.apache.poi.xssf.usermodel;
-import java.io.IOException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
-import junit.framework.TestCase;
+import java.io.IOException;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.xssf.model.StylesTable;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
import org.apache.poi.xssf.usermodel.extensions.XSSFCellFill;
+import org.junit.Before;
import org.junit.Test;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
-
-public class TestXSSFCellStyle extends TestCase {
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBorder;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCellXfs;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFont;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTStylesheet;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTXf;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STBorderStyle;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STHorizontalAlignment;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.STVerticalAlignment;
+
+public class TestXSSFCellStyle {
private StylesTable stylesTable;
private CTBorder ctBorderA;
private CTFill ctFill;
private XSSFCellStyle cellStyle;
private CTStylesheet ctStylesheet;
- @Override
- protected void setUp() {
+ @Before
+ public void setUp() {
stylesTable = new StylesTable();
ctStylesheet = stylesTable.getCTStylesheet();
assertEquals(STPatternType.INT_DARK_GRAY, stylesTable.getFillAt(1).getCTFill().getPatternFill().getPatternType().intValue());
}
+ @Test
public void testGetSetBorderBottom() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderBottom());
assertFalse(ctBorder.isSetBottom());
}
+ @Test
public void testGetSetBorderRight() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderRight());
assertFalse(ctBorder.isSetRight());
}
- public void testGetSetBorderLeft() {
+ @Test
+ public void testGetSetBorderLeft() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderLeft());
assertFalse(ctBorder.isSetLeft());
}
- public void testGetSetBorderTop() {
+ @Test
+ public void testGetSetBorderTop() {
//default values
assertEquals(CellStyle.BORDER_NONE, cellStyle.getBorderTop());
assertFalse(ctBorder.isSetTop());
}
- public void testGetSetBorderThin() {
+ @Test
+ public void testGetSetBorderThin() {
cellStyle.setBorderTop(CellStyle.BORDER_THIN);
assertEquals(CellStyle.BORDER_THIN, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.THIN, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMedium() {
+ @Test
+ public void testGetSetBorderMedium() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM);
assertEquals(CellStyle.BORDER_MEDIUM, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.MEDIUM, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderThick() {
+ @Test
+ public void testGetSetBorderThick() {
cellStyle.setBorderTop(CellStyle.BORDER_THICK);
assertEquals(CellStyle.BORDER_THICK, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.THICK, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderHair() {
+ @Test
+ public void testGetSetBorderHair() {
cellStyle.setBorderTop(CellStyle.BORDER_HAIR);
assertEquals(CellStyle.BORDER_HAIR, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.HAIR, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDotted() {
+ @Test
+ public void testGetSetBorderDotted() {
cellStyle.setBorderTop(CellStyle.BORDER_DOTTED);
assertEquals(CellStyle.BORDER_DOTTED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.DOTTED, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDashed() {
+ @Test
+ public void testGetSetBorderDashed() {
cellStyle.setBorderTop(CellStyle.BORDER_DASHED);
assertEquals(CellStyle.BORDER_DASHED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.DASHED, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDashDot() {
+ @Test
+ public void testGetSetBorderDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT);
assertEquals(CellStyle.BORDER_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.DASH_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDashDotDot() {
+ @Test
+ public void testGetSetBorderDashDotDot() {
cellStyle.setBorderTop(CellStyle.BORDER_DASH_DOT_DOT);
assertEquals(CellStyle.BORDER_DASH_DOT_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.DASH_DOT_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMediumDashDot() {
+ @Test
+ public void testGetSetBorderMediumDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT);
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.MEDIUM_DASH_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMediumDashDotDot() {
+ @Test
+ public void testGetSetBorderMediumDashDotDot() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT);
assertEquals(CellStyle.BORDER_MEDIUM_DASH_DOT_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.MEDIUM_DASH_DOT_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderMediumDashed() {
+ @Test
+ public void testGetSetBorderMediumDashed() {
cellStyle.setBorderTop(CellStyle.BORDER_MEDIUM_DASHED);
assertEquals(CellStyle.BORDER_MEDIUM_DASHED, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.MEDIUM_DASHED, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderSlantDashDot() {
+ @Test
+ public void testGetSetBorderSlantDashDot() {
cellStyle.setBorderTop(CellStyle.BORDER_SLANTED_DASH_DOT);
assertEquals(CellStyle.BORDER_SLANTED_DASH_DOT, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.SLANT_DASH_DOT, ctBorder.getTop().getStyle());
}
- public void testGetSetBorderDouble() {
+ @Test
+ public void testGetSetBorderDouble() {
cellStyle.setBorderTop(CellStyle.BORDER_DOUBLE);
assertEquals(CellStyle.BORDER_DOUBLE, cellStyle.getBorderTop());
int borderId = (int)cellStyle.getCoreXf().getBorderId();
assertEquals(STBorderStyle.DOUBLE, ctBorder.getTop().getStyle());
}
- public void testGetSetBottomBorderColor() {
+ @Test
+ public void testGetSetBottomBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getBottomBorderColor());
assertNull(cellStyle.getBottomBorderXSSFColor());
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setBottomBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getBottomBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getBottomBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
assertNull(cellStyle.getBottomBorderXSSFColor());
}
- public void testGetSetTopBorderColor() {
+ @Test
+ public void testGetSetTopBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getTopBorderColor());
assertNull(cellStyle.getTopBorderXSSFColor());
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setTopBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getTopBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getTopBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getTopBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
assertNull(cellStyle.getTopBorderXSSFColor());
}
- public void testGetSetLeftBorderColor() {
+ @Test
+ public void testGetSetLeftBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getLeftBorderColor());
assertNull(cellStyle.getLeftBorderXSSFColor());
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setLeftBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getLeftBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getLeftBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
assertNull(cellStyle.getLeftBorderXSSFColor());
}
- public void testGetSetRightBorderColor() {
+ @Test
+ public void testGetSetRightBorderColor() {
//defaults
assertEquals(IndexedColors.BLACK.getIndex(), cellStyle.getRightBorderColor());
assertNull(cellStyle.getRightBorderXSSFColor());
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setRightBorderColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getRightBorderXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getRightBorderXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getRightBorderXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getBorders().size());
assertNull(cellStyle.getRightBorderXSSFColor());
}
- public void testGetSetFillBackgroundColor() {
+ @Test
+ public void testGetSetFillBackgroundColor() {
assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
assertNull(cellStyle.getFillBackgroundXSSFColor());
int fillId = (int)cellStyle.getCoreXf().getFillId();
assertTrue(fillId > 0);
//check changes in the underlying xml bean
- CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
- assertEquals(IndexedColors.RED.getIndex(), ctFill.getPatternFill().getBgColor().getIndexed());
+ CTFill ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+ assertEquals(IndexedColors.RED.getIndex(), ctFill2.getPatternFill().getBgColor().getIndexed());
//setting XSSFColor
num = stylesTable.getFills().size();
clr = new XSSFColor(java.awt.Color.CYAN);
cellStyle.setFillBackgroundColor(clr);
assertEquals(clr.getCTColor().toString(), cellStyle.getFillBackgroundXSSFColor().getCTColor().toString());
- byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRgb();
+ byte[] rgb = cellStyle.getFillBackgroundXSSFColor().getRGB();
assertEquals(java.awt.Color.CYAN, new java.awt.Color(rgb[0] & 0xFF, rgb[1] & 0xFF, rgb[2] & 0xFF));
//another border was added to the styles table
assertEquals(num + 1, stylesTable.getFills().size());
assertEquals(IndexedColors.AUTOMATIC.getIndex(), cellStyle.getFillBackgroundColor());
}
- public void testDefaultStyles() throws IOException {
+ @Test
+ public void testDefaultStyles() throws IOException {
XSSFWorkbook wb1 = new XSSFWorkbook();
assertNull(style1.getFillBackgroundXSSFColor());
assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb1));
+ wb1.close();
//compatibility with HSSF
HSSFWorkbook wb2 = new HSSFWorkbook();
wb2.close();
}
-
- public void testGetFillForegroundColor() {
+ @Test
+ public void testGetFillForegroundColor() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
StylesTable styles = wb.getStylesSource();
assertEquals(1, wb.getNumCellStyles());
}
assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
+ wb.close();
}
- public void testGetFillPattern() {
+ @Test
+ public void testGetFillPattern() {
assertEquals(STPatternType.INT_DARK_GRAY-1, cellStyle.getFillPattern());
int fillId = (int)cellStyle.getCoreXf().getFillId();
assertTrue(fillId > 0);
//check changes in the underlying xml bean
- CTFill ctFill = stylesTable.getFillAt(fillId).getCTFill();
- assertEquals(STPatternType.SOLID, ctFill.getPatternFill().getPatternType());
+ CTFill ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+ assertEquals(STPatternType.SOLID, ctFill2.getPatternFill().getPatternType());
//setting the same fill multiple time does not update the styles table
for (int i = 0; i < 3; i++) {
cellStyle.setFillPattern(CellStyle.NO_FILL);
assertEquals(CellStyle.NO_FILL, cellStyle.getFillPattern());
fillId = (int)cellStyle.getCoreXf().getFillId();
- ctFill = stylesTable.getFillAt(fillId).getCTFill();
- assertFalse(ctFill.getPatternFill().isSetPatternType());
+ ctFill2 = stylesTable.getFillAt(fillId).getCTFill();
+ assertFalse(ctFill2.getPatternFill().isSetPatternType());
}
- public void testGetFont() {
+ @Test
+ public void testGetFont() {
assertNotNull(cellStyle.getFont());
}
- public void testGetSetHidden() {
+ @Test
+ public void testGetSetHidden() {
assertFalse(cellStyle.getHidden());
cellStyle.setHidden(true);
assertTrue(cellStyle.getHidden());
assertFalse(cellStyle.getHidden());
}
- public void testGetSetLocked() {
+ @Test
+ public void testGetSetLocked() {
assertTrue(cellStyle.getLocked());
cellStyle.setLocked(true);
assertTrue(cellStyle.getLocked());
assertFalse(cellStyle.getLocked());
}
- public void testGetSetIndent() {
+ @Test
+ public void testGetSetIndent() {
assertEquals((short)0, cellStyle.getIndention());
cellStyle.setIndention((short)3);
assertEquals((short)3, cellStyle.getIndention());
assertEquals((short)13, cellStyle.getIndention());
}
- public void testGetSetAlignement() {
+ @Test
+ public void testGetSetAlignement() {
assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
assertEquals(HorizontalAlignment.GENERAL, cellStyle.getAlignmentEnum());
assertEquals(STHorizontalAlignment.CENTER, cellStyle.getCellAlignment().getCTCellAlignment().getHorizontal());
}
- public void testGetSetVerticalAlignment() {
+ @Test
+ public void testGetSetVerticalAlignment() {
assertEquals(VerticalAlignment.BOTTOM, cellStyle.getVerticalAlignmentEnum());
assertEquals(XSSFCellStyle.VERTICAL_BOTTOM, cellStyle.getVerticalAlignment());
assertNull(cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
assertEquals(STVerticalAlignment.JUSTIFY, cellStyle.getCellAlignment().getCTCellAlignment().getVertical());
}
- public void testGetSetWrapText() {
+ @Test
+ public void testGetSetWrapText() {
assertFalse(cellStyle.getWrapText());
cellStyle.setWrapText(true);
assertTrue(cellStyle.getWrapText());
/**
* Cloning one XSSFCellStyle onto Another, same XSSFWorkbook
*/
- public void testCloneStyleSameWB() {
+ @Test
+ public void testCloneStyleSameWB() throws IOException {
XSSFWorkbook wb = new XSSFWorkbook();
assertEquals(1, wb.getNumberOfFonts());
assertTrue(18 == clone.getDataFormat());
assertEquals(2, wb.getNumberOfFonts());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb);
+ assertNotNull(wb2);
+ wb2.close();
+
+ wb.close();
}
/**
* Cloning one XSSFCellStyle onto Another, different XSSFWorkbooks
*/
- public void testCloneStyleDiffWB() {
+ @Test
+ public void testCloneStyleDiffWB() throws IOException {
XSSFWorkbook wbOrig = new XSSFWorkbook();
assertEquals(1, wbOrig.getNumberOfFonts());
assertEquals(0, wbOrig.getStylesSource().getNumberFormats().size());
assertEquals(0, wbClone.getStylesSource().getNumberFormats().size());
assertFalse(HSSFCellStyle.ALIGN_RIGHT == clone.getAlignment());
- assertFalse("TestingFont" == clone.getFont().getFontName());
+ assertNotEquals("TestingFont", clone.getFont().getFontName());
clone.cloneStyleFrom(orig);
assertEquals(fmtClone.getFormat("Test##"), reload.getDataFormat());
assertFalse(fmtClone.getFormat("Test##") == fmt.getFormat("Test##"));
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbClone));
+ XSSFWorkbook wbOrig2 = XSSFTestDataSamples.writeOutAndReadBack(wbOrig);
+ assertNotNull(wbOrig2);
+ wbOrig2.close();
+
+ XSSFWorkbook wbClone2 = XSSFTestDataSamples.writeOutAndReadBack(wbClone);
+ assertNotNull(wbClone2);
+ wbClone2.close();
+
+ wbReload.close();
+ wbClone.close();
+ wbOrig.close();
}
/**
* Avoid ArrayIndexOutOfBoundsException when creating cell style
* in a workbook that has an empty xf table.
*/
- public void testBug52348() {
+ @Test
+ public void testBug52348() throws IOException {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
StylesTable st = workbook.getStylesSource();
assertEquals(0, st._getStyleXfsSize());
XSSFCellStyle style = workbook.createCellStyle(); // no exception at this point
assertNull(style.getStyleXf());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+ assertNotNull(wb2);
+ wb2.close();
+ workbook.close();
}
/**
* Avoid ArrayIndexOutOfBoundsException when getting cell style
* in a workbook that has an empty xf table.
*/
- public void testBug55650() {
+ @Test
+ public void testBug55650() throws IOException {
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("52348.xlsx");
StylesTable st = workbook.getStylesSource();
assertEquals(0, st._getStyleXfsSize());
XSSFCellStyle style = workbook.getSheetAt(0).getRow(0).getCell(0).getCellStyle();
assertNull(style.getStyleXf());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(workbook));
+ XSSFWorkbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(workbook);
+ assertNotNull(wb2);
+ wb2.close();
+
+ workbook.close();
}
- public void testShrinkToFit() {
+ @Test
+ public void testShrinkToFit() throws IOException {
// Existing file
- XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("ShrinkToFit.xlsx");
- Sheet s = wb.getSheetAt(0);
+ XSSFWorkbook wb1 = XSSFTestDataSamples.openSampleWorkbook("ShrinkToFit.xlsx");
+ Sheet s = wb1.getSheetAt(0);
Row r = s.getRow(0);
CellStyle cs = r.getCell(0).getCellStyle();
assertEquals(true, cs.getShrinkToFit());
// New file
- XSSFWorkbook wbOrig = new XSSFWorkbook();
- s = wbOrig.createSheet();
+ XSSFWorkbook wb2 = new XSSFWorkbook();
+ s = wb2.createSheet();
r = s.createRow(0);
- cs = wbOrig.createCellStyle();
+ cs = wb2.createCellStyle();
cs.setShrinkToFit(false);
r.createCell(0).setCellStyle(cs);
- cs = wbOrig.createCellStyle();
+ cs = wb2.createCellStyle();
cs.setShrinkToFit(true);
r.createCell(1).setCellStyle(cs);
// Write out, read, and check
- wb = XSSFTestDataSamples.writeOutAndReadBack(wbOrig);
- s = wb.getSheetAt(0);
+ XSSFWorkbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
+ s = wb3.getSheetAt(0);
r = s.getRow(0);
assertEquals(false, r.getCell(0).getCellStyle().getShrinkToFit());
assertEquals(true, r.getCell(1).getCellStyle().getShrinkToFit());
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wb));
- assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(wbOrig));
+ XSSFWorkbook wb4 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
+ assertNotNull(wb4);
+ wb4.close();
+
+ XSSFWorkbook wb5 = XSSFTestDataSamples.writeOutAndReadBack(wb3);
+ assertNotNull(wb5);
+ wb5.close();
+
+ wb3.close();
+ wb2.close();
+ wb1.close();
+
}
@Test
Sheet sheet = wb.createSheet();
Row row = sheet.createRow(0);
- //CreationHelper ch = wb.getCreationHelper();
DataFormat format = wb.createDataFormat();
Cell cell = row.createCell(1);
cell.setCellValue("somevalue");
- CellStyle cellStyle = wb.createCellStyle();
+ CellStyle cellStyle2 = wb.createCellStyle();
- cellStyle.setDataFormat(format.getFormat("###0"));
+ cellStyle2.setDataFormat(format.getFormat("###0"));
- cellStyle.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
- cellStyle.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
- cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
+ cellStyle2.setFillBackgroundColor(IndexedColors.DARK_BLUE.getIndex());
+ cellStyle2.setFillForegroundColor(IndexedColors.DARK_BLUE.getIndex());
+ cellStyle2.setFillPattern(CellStyle.SOLID_FOREGROUND);
- cellStyle.setAlignment(CellStyle.ALIGN_RIGHT);
- cellStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
+ cellStyle2.setAlignment(CellStyle.ALIGN_RIGHT);
+ cellStyle2.setVerticalAlignment(CellStyle.VERTICAL_TOP);
- cell.setCellStyle(cellStyle);
+ cell.setCellStyle(cellStyle2);
- /*OutputStream stream = new FileOutputStream("C:\\temp\\CellColor.xlsx");
- try {
- wb.write(stream);
- } finally {
- stream.close();
- }*/
-
Workbook wbBack = XSSFTestDataSamples.writeOutAndReadBack(wb);
Cell cellBack = wbBack.getSheetAt(0).getRow(0).getCell(1);
assertNotNull(cellBack);
package org.apache.poi.xssf.usermodel;
-import junit.framework.TestCase;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
import org.apache.poi.xssf.XSSFTestDataSamples;
+import org.junit.Test;
-public final class TestXSSFColor extends TestCase {
+public final class TestXSSFColor {
+
+ @Test
public void testIndexedColour() throws Exception {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
// Now check the XSSFColor
// Note - 64 is a special "auto" one with no rgb equiv
assertEquals(64, indexed.getIndexed());
- assertEquals(null, indexed.getRgb());
- assertEquals(null, indexed.getRgbWithTint());
+ assertEquals(null, indexed.getRGB());
+ assertEquals(null, indexed.getRGBWithTint());
assertEquals(null, indexed.getARGBHex());
// Now move to one with indexed rgb values
assertEquals(59, indexed.getIndexed());
assertEquals("FF333300", indexed.getARGBHex());
- assertEquals(3, indexed.getRgb().length);
- assertEquals(0x33, indexed.getRgb()[0]);
- assertEquals(0x33, indexed.getRgb()[1]);
- assertEquals(0x00, indexed.getRgb()[2]);
+ assertEquals(3, indexed.getRGB().length);
+ assertEquals(0x33, indexed.getRGB()[0]);
+ assertEquals(0x33, indexed.getRGB()[1]);
+ assertEquals(0x00, indexed.getRGB()[2]);
- assertEquals(4, indexed.getARgb().length);
- assertEquals(-1, indexed.getARgb()[0]);
- assertEquals(0x33, indexed.getARgb()[1]);
- assertEquals(0x33, indexed.getARgb()[2]);
- assertEquals(0x00, indexed.getARgb()[3]);
+ assertEquals(4, indexed.getARGB().length);
+ assertEquals(-1, indexed.getARGB()[0]);
+ assertEquals(0x33, indexed.getARGB()[1]);
+ assertEquals(0x33, indexed.getARGB()[2]);
+ assertEquals(0x00, indexed.getARGB()[3]);
// You don't get tinted indexed colours, sorry...
- assertEquals(null, indexed.getRgbWithTint());
+ assertEquals(null, indexed.getRGBWithTint());
+
+ wb.close();
}
- public void testRGBColour() throws Exception {
+ @Test
+ public void testRGBColour() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("50299.xlsx");
// Check the CTColor is as expected
assertEquals(-0.34999, rgb3.getTint(), 0.00001);
assertEquals("FFFFFFFF", rgb3.getARGBHex());
- assertEquals(3, rgb3.getRgb().length);
- assertEquals(-1, rgb3.getRgb()[0]);
- assertEquals(-1, rgb3.getRgb()[1]);
- assertEquals(-1, rgb3.getRgb()[2]);
+ assertEquals(3, rgb3.getRGB().length);
+ assertEquals(-1, rgb3.getRGB()[0]);
+ assertEquals(-1, rgb3.getRGB()[1]);
+ assertEquals(-1, rgb3.getRGB()[2]);
- assertEquals(4, rgb3.getARgb().length);
- assertEquals(-1, rgb3.getARgb()[0]);
- assertEquals(-1, rgb3.getARgb()[1]);
- assertEquals(-1, rgb3.getARgb()[2]);
- assertEquals(-1, rgb3.getARgb()[3]);
+ assertEquals(4, rgb3.getARGB().length);
+ assertEquals(-1, rgb3.getARGB()[0]);
+ assertEquals(-1, rgb3.getARGB()[1]);
+ assertEquals(-1, rgb3.getARGB()[2]);
+ assertEquals(-1, rgb3.getARGB()[3]);
// Tint doesn't have the alpha
// tint = -0.34999
// 255 * (1 + tint) = 165 truncated
// or (byte) -91 (which is 165 - 256)
- assertEquals(3, rgb3.getRgbWithTint().length);
- assertEquals(-91, rgb3.getRgbWithTint()[0]);
- assertEquals(-91, rgb3.getRgbWithTint()[1]);
- assertEquals(-91, rgb3.getRgbWithTint()[2]);
+ assertEquals(3, rgb3.getRGBWithTint().length);
+ assertEquals(-91, rgb3.getRGBWithTint()[0]);
+ assertEquals(-91, rgb3.getRGBWithTint()[1]);
+ assertEquals(-91, rgb3.getRGBWithTint()[2]);
// Set the color to black (no theme).
- rgb3.setRgb(new byte[] {0, 0, 0});
+ rgb3.setRGB(new byte[] {0, 0, 0});
assertEquals("FF000000", rgb3.getARGBHex());
assertEquals(0, rgb3.getCTColor().getRgb()[0]);
assertEquals(0, rgb3.getCTColor().getRgb()[1]);
assertEquals(0, rgb3.getCTColor().getRgb()[2]);
// Set another, is fine
- rgb3.setRgb(new byte[] {16,17,18});
+ rgb3.setRGB(new byte[] {16,17,18});
assertEquals("FF101112", rgb3.getARGBHex());
assertEquals(0x10, rgb3.getCTColor().getRgb()[0]);
assertEquals(0x11, rgb3.getCTColor().getRgb()[1]);
assertEquals(0x12, rgb3.getCTColor().getRgb()[2]);
+
+ wb.close();
}
- public void testARGBColour() throws Exception {
+ @Test
+ public void testARGBColour() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("48779.xlsx");
// Check the CTColor is as expected
// Now check the XSSFColor
assertEquals(0, rgb4.getIndexed());
- assertEquals(0.0, rgb4.getTint());
+ assertEquals(0.0, rgb4.getTint(), 0);
assertEquals("FFFF0000", rgb4.getARGBHex());
- assertEquals(3, rgb4.getRgb().length);
- assertEquals(-1, rgb4.getRgb()[0]);
- assertEquals(0, rgb4.getRgb()[1]);
- assertEquals(0, rgb4.getRgb()[2]);
+ assertEquals(3, rgb4.getRGB().length);
+ assertEquals(-1, rgb4.getRGB()[0]);
+ assertEquals(0, rgb4.getRGB()[1]);
+ assertEquals(0, rgb4.getRGB()[2]);
- assertEquals(4, rgb4.getARgb().length);
- assertEquals(-1, rgb4.getARgb()[0]);
- assertEquals(-1, rgb4.getARgb()[1]);
- assertEquals(0, rgb4.getARgb()[2]);
- assertEquals(0, rgb4.getARgb()[3]);
+ assertEquals(4, rgb4.getARGB().length);
+ assertEquals(-1, rgb4.getARGB()[0]);
+ assertEquals(-1, rgb4.getARGB()[1]);
+ assertEquals(0, rgb4.getARGB()[2]);
+ assertEquals(0, rgb4.getARGB()[3]);
// Tint doesn't have the alpha
- assertEquals(3, rgb4.getRgbWithTint().length);
- assertEquals(-1, rgb4.getRgbWithTint()[0]);
- assertEquals(0, rgb4.getRgbWithTint()[1]);
- assertEquals(0, rgb4.getRgbWithTint()[2]);
+ assertEquals(3, rgb4.getRGBWithTint().length);
+ assertEquals(-1, rgb4.getRGBWithTint()[0]);
+ assertEquals(0, rgb4.getRGBWithTint()[1]);
+ assertEquals(0, rgb4.getRGBWithTint()[2]);
// Turn on tinting, and check it behaves
// TODO These values are suspected to be wrong...
rgb4.setTint(0.4);
- assertEquals(0.4, rgb4.getTint());
-
- assertEquals(3, rgb4.getRgbWithTint().length);
- assertEquals(-1, rgb4.getRgbWithTint()[0]);
- assertEquals(102, rgb4.getRgbWithTint()[1]);
- assertEquals(102, rgb4.getRgbWithTint()[2]);
+ assertEquals(0.4, rgb4.getTint(), 0);
+
+ assertEquals(3, rgb4.getRGBWithTint().length);
+ assertEquals(-1, rgb4.getRGBWithTint()[0]);
+ assertEquals(102, rgb4.getRGBWithTint()[1]);
+ assertEquals(102, rgb4.getRGBWithTint()[2]);
+
+ wb.close();
}
}
package org.apache.poi.xssf.usermodel.extensions;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.io.IOException;
+
+import org.apache.poi.ss.usermodel.FillPatternType;
import org.apache.poi.xssf.XSSFTestDataSamples;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFColor;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.junit.Test;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTColor;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTFill;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPatternFill;
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STPatternType;
-import junit.framework.TestCase;
-
-public class TestXSSFCellFill extends TestCase {
+public class TestXSSFCellFill {
+ @Test
public void testGetFillBackgroundColor() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
assertEquals(2, cellFill.getFillBackgroundColor().getIndexed());
}
+ @Test
public void testGetFillForegroundColor() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
assertEquals(8, cellFill.getFillForegroundColor().getIndexed());
}
+ @Test
public void testGetSetPatternType() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
CTPatternFill ctPatternFill = ctFill.addNewPatternFill();
ctPatternFill.setPatternType(STPatternType.SOLID);
- //assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().ordinal());
+ assertEquals(FillPatternType.SOLID_FOREGROUND.ordinal(), cellFill.getPatternType().intValue()-1);
}
+ @Test
public void testGetNotModifies() {
CTFill ctFill = CTFill.Factory.newInstance();
XSSFCellFill cellFill = new XSSFCellFill(ctFill);
assertEquals(8, cellFill.getPatternType().intValue());
}
- public void testColorFromTheme() {
+ @Test
+ public void testColorFromTheme() throws IOException {
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("styles.xlsx");
XSSFCell cellWithThemeColor = wb.getSheetAt(0).getRow(10).getCell(0);
//color RGB will be extracted from theme
XSSFColor foregroundColor = cellWithThemeColor.getCellStyle().getFillForegroundXSSFColor();
- byte[] rgb = foregroundColor.getRgb();
- byte[] rgbWithTint = foregroundColor.getRgbWithTint();
+ byte[] rgb = foregroundColor.getRGB();
+ byte[] rgbWithTint = foregroundColor.getRGBWithTint();
// Dk2
assertEquals(rgb[0],31);
assertEquals(rgb[1],73);
assertEquals(rgbWithTint[0],120);
assertEquals(rgbWithTint[1],-111);
assertEquals(rgbWithTint[2],-80);
+ wb.close();
}
}
ret[i] = doc.getTextTable().getTextPieces().get(i).getStringBuilder().toString();
// Fix the line endings
- ret[i].replaceAll("\r", "\ufffe");
- ret[i].replaceAll("\ufffe","\r\n");
+ ret[i] = ret[i].replaceAll("\r", "\ufffe");
+ ret[i] = ret[i].replaceAll("\ufffe","\r\n");
}
}
package org.apache.poi.hssf.usermodel;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests the capabilities of the EscherGraphics class.
* All tests have two escher groups available to them,
* one anchored at 0,0,1022,255 and another anchored
* at 20,30,500,200
- *
- * @author Glen Stampoultzis (glens at apache.org)
*/
-public final class TestEscherGraphics extends TestCase {
+public final class TestEscherGraphics {
private HSSFWorkbook workbook;
private HSSFPatriarch patriarch;
private HSSFShapeGroup escherGroupA;
- private HSSFShapeGroup escherGroupB;
private EscherGraphics graphics;
- protected void setUp() throws Exception
- {
+ @Before
+ public void setUp() throws IOException {
workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("test");
patriarch = sheet.createDrawingPatriarch();
escherGroupA = patriarch.createGroup(new HSSFClientAnchor(0,0,1022,255,(short)0,0,(short) 0,0));
- escherGroupB = patriarch.createGroup(new HSSFClientAnchor(20,30,500,200,(short)0,0,(short) 0,0));
-// escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor());
- graphics = new EscherGraphics(this.escherGroupA, workbook, Color.black, 1.0f);
- super.setUp();
+ patriarch.createGroup(new HSSFClientAnchor(20,30,500,200,(short)0,0,(short) 0,0));
+ graphics = new EscherGraphics(escherGroupA, workbook, Color.black, 1.0f);
+ }
+
+ @After
+ public void closeResources() throws IOException {
+ workbook.close();
}
+ @Test
public void testGetFont() {
Font f = graphics.getFont();
- if (f.toString().indexOf("dialog") == -1 && f.toString().indexOf("Dialog") == -1)
+ if (f.toString().indexOf("dialog") == -1 && f.toString().indexOf("Dialog") == -1) {
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
+ }
}
+ @Test
public void testGetFontMetrics() {
Font f = graphics.getFont();
- if (f.toString().indexOf("dialog") != -1 || f.toString().indexOf("Dialog") != -1)
+ if (f.toString().indexOf("dialog") != -1 || f.toString().indexOf("Dialog") != -1) {
return;
+ }
FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
assertEquals(7, fontMetrics.charWidth('X'));
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
}
+ @Test
public void testSetFont() {
Font f = new Font("Helvetica", 0, 12);
graphics.setFont(f);
assertEquals(f, graphics.getFont());
}
+ @Test
public void testSetColor() {
graphics.setColor(Color.red);
assertEquals(Color.red, graphics.getColor());
}
+ @Test
public void testFillRect() {
graphics.fillRect( 10, 10, 20, 20 );
HSSFSimpleShape s = (HSSFSimpleShape) escherGroupA.getChildren().get(0);
assertEquals(30, s.getAnchor().getDx2());
}
+ @Test
public void testDrawString() {
graphics.drawString("This is a test", 10, 10);
HSSFTextbox t = (HSSFTextbox) escherGroupA.getChildren().get(0);
assertEquals("This is a test", t.getString().getString());
}
+ @Test
public void testGetDataBackAgain() throws Exception {
HSSFSheet s;
HSSFShapeGroup s1;
assertEquals(200, s2.getAnchor().getDy2());
// Not working just yet
- //assertEquals("I am text box 1", tbox1.getString().getString());
+ assertEquals("I am text box 1", tbox1.getString().getString());
}
}
package org.apache.poi.hssf.usermodel;
-import junit.framework.TestCase;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
-import java.awt.*;
+import java.awt.Color;
+import java.awt.Font;
+import java.awt.FontMetrics;
import java.awt.geom.Line2D;
+import java.io.IOException;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
/**
* Tests the Graphics2d drawing capability.
- *
- * @author Glen Stampoultzis (glens at apache.org)
*/
-public final class TestEscherGraphics2d extends TestCase {
+public final class TestEscherGraphics2d {
+ private HSSFWorkbook workbook;
private HSSFShapeGroup escherGroup;
private EscherGraphics2d graphics;
- @Override
- protected void setUp() {
- HSSFWorkbook workbook = new HSSFWorkbook();
+ @Before
+ public void setUp() {
+ workbook = new HSSFWorkbook();
HSSFSheet sheet = workbook.createSheet("test");
escherGroup = sheet.createDrawingPatriarch().createGroup(new HSSFClientAnchor(0,0,1023,255,(short)0,0,(short) 0,0));
escherGroup = new HSSFShapeGroup(null, new HSSFChildAnchor());
- EscherGraphics g = new EscherGraphics(this.escherGroup, workbook, Color.black, 1.0f);
+ EscherGraphics g = new EscherGraphics(escherGroup, workbook, Color.black, 1.0f);
graphics = new EscherGraphics2d(g);
}
+
+ @After
+ public void closeResources() throws IOException {
+ workbook.close();
+ }
+ @Test
public void testDrawString() {
graphics.drawString("This is a test", 10, 10);
HSSFTextbox t = (HSSFTextbox) escherGroup.getChildren().get(0);
}
}
- public void testFillRect() {
+ @Test
+ public void testFillRect() {
graphics.fillRect( 10, 10, 20, 20 );
HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0);
assertEquals(HSSFSimpleShape.OBJECT_TYPE_RECTANGLE, s.getShapeType());
assertEquals(30, s.getAnchor().getDx2());
}
- public void testGetFontMetrics() {
+ @Test
+ public void testGetFontMetrics() {
FontMetrics fontMetrics = graphics.getFontMetrics(graphics.getFont());
- if (isDialogPresent()) // if dialog is returned we can't run the test properly.
+ if (isDialogPresent()) {
+ // if dialog is returned we can't run the test properly.
return;
+ }
assertEquals(7, fontMetrics.charWidth('X'));
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", fontMetrics.getFont().toString());
}
- public void testSetFont() {
+ @Test
+ public void testSetFont() {
Font f = new Font("Helvetica", 0, 12);
graphics.setFont(f);
assertEquals(f, graphics.getFont());
}
- public void testSetColor() {
+ @Test
+ public void testSetColor() {
graphics.setColor(Color.red);
assertEquals(Color.red, graphics.getColor());
}
- public void testGetFont() {
+ @Test
+ public void testGetFont() {
Font f = graphics.getFont();
- if (isDialogPresent()) // if dialog is returned we can't run the test properly.
+ if (isDialogPresent()) {
+ // if dialog is returned we can't run the test properly.
return;
+ }
assertEquals("java.awt.Font[family=Arial,name=Arial,style=plain,size=10]", f.toString());
}
return fontDebugStr.indexOf("dialog") != -1 || fontDebugStr.indexOf("Dialog") != -1;
}
- public void testDraw() {
+ @Test
+ public void testDraw() {
graphics.draw(new Line2D.Double(10,10,20,20));
HSSFSimpleShape s = (HSSFSimpleShape) escherGroup.getChildren().get(0);
assertTrue(s.getShapeType() == HSSFSimpleShape.OBJECT_TYPE_LINE);
* Also tests bug 15353 (problems with hyperlinks to Google)
*/
@Test
- public final void bug23094() throws Exception {
+ public final void bug23094() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet s = wb1.createSheet();
Row r = s.createRow(0);
* open resulting file in Excel to check results!
* @param num the number of strings to generate
*/
- public final void bug15375(int num) throws Exception {
+ public final void bug15375(int num) throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sheet = wb1.createSheet();
CreationHelper factory = wb1.getCreationHelper();
* Merged regions were being removed from the parent in cloned sheets
*/
@Test
- public void bug22720() throws Exception {
+ public void bug22720() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
wb.createSheet("TEST");
Sheet template = wb.getSheetAt(0);
}
@Test
- public final void bug28031() throws Exception {
+ public final void bug28031() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sheet = wb1.createSheet();
wb1.setSheetName(0, "Sheet1");
* {=SUM(IF(FREQUENCY(IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""),IF(LEN(V4:V220)>0,MATCH(V4:V220,V4:V220,0),""))>0,1))}
*/
@Test
- public final void bug21334() throws Exception {
+ public final void bug21334() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet sh = wb1.createSheet();
Cell cell = sh.createRow(0).createCell(0);
/** another test for the number of unique strings issue
*test opening the resulting file in Excel*/
@Test
- public final void bug22568() throws Exception {
+ public final void bug22568() throws IOException {
int r=2000;int c=3;
Workbook wb1 = _testDataProvider.createWorkbook();
* Bug 42448: Can't parse SUMPRODUCT(A!C7:A!C67, B8:B68) / B69
*/
@Test
- public final void bug42448() throws Exception {
+ public final void bug42448() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Cell cell = wb.createSheet().createRow(0).createCell(0);
cell.setCellFormula("SUMPRODUCT(A!C7:A!C67, B8:B68) / B69");
}
@Test
- public void bug18800() throws Exception {
+ public void bug18800() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
wb1.createSheet("TEST");
Sheet sheet = wb1.cloneSheet(0);
}
@Test
- public void bug43093() throws Exception {
+ public void bug43093() throws IOException {
Workbook xlw = _testDataProvider.createWorkbook();
addNewSheetWithCellsA1toD4(xlw, 1);
}
@Test
- public void bug46729_testMaxFunctionArguments() throws Exception {
+ public void bug46729_testMaxFunctionArguments() throws IOException {
String[] func = {"COUNT", "AVERAGE", "MAX", "MIN", "OR", "SUBTOTAL", "SKEW"};
SpreadsheetVersion ssVersion = _testDataProvider.getSpreadsheetVersion();
}
@Test
- public final void bug50681_testAutoSize() throws Exception {
+ public final void bug50681_testAutoSize() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
BaseTestSheetAutosizeColumn.fixFonts(wb);
Sheet sheet = wb.createSheet("Sheet1");
* CreateFreezePane column/row order check
*/
@Test
- public void bug49381() throws Exception {
+ public void bug49381() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
int colSplit = 1;
int rowSplit = 2;
* open resulting file in excel, and check that there is a link to Google
*/
@Test
- public void bug15353() throws Exception {
+ public void bug15353() throws IOException {
String hyperlinkF = "HYPERLINK(\"http://google.com\",\"Google\")";
Workbook wb1 = _testDataProvider.createWorkbook();
* HLookup and VLookup with optional arguments
*/
@Test
- public void bug51024() throws Exception {
+ public void bug51024() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r1 = s.createRow(0);
}
@Test
- public void stackoverflow23114397() throws Exception {
+ public void stackoverflow23114397() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
DataFormat format = wb.getCreationHelper().createDataFormat();
* =ISNUMBER(SEARCH("AM",A1)) evaluation
*/
@Test
- public void stackoverflow26437323() throws Exception {
+ public void stackoverflow26437323() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r1 = s.createRow(0);
*/
@Ignore("Fix this to evaluate for XSSF, Fix this to work at all for HSSF")
@Test
- public void bug46670() throws Exception {
+ public void bug46670() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
Sheet s = wb1.createSheet();
Row r1 = s.createRow(0);
* that it now is again
*/
@Test
- public void bug48718() throws Exception {
+ public void bug48718() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
int startingFonts = wb instanceof HSSFWorkbook ? 4 : 1;
}
@Test
- public void bug57430() throws Exception {
+ public void bug57430() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
wb.createSheet("Sheet1");
* kind of value from a Formula cell
*/
@Test
- public void bug47815() throws Exception {
+ public void bug47815() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet s = wb.createSheet();
Row r = s.createRow(0);
}
@Test
- public void test58113() throws Exception {
+ public void test58113() throws IOException {
Workbook wb = _testDataProvider.createWorkbook();
Sheet sheet = wb.createSheet( "Test" );
* Mid in it, can give #VALUE in Excel
*/
@Test
- public void bug55747() throws Exception {
+ public void bug55747() throws IOException {
Workbook wb1 = _testDataProvider.createWorkbook();
FormulaEvaluator ev = wb1.getCreationHelper().createFormulaEvaluator();
Sheet s = wb1.createSheet();