You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2010/03/15 07:14:03 UTC
svn commit: r923072 - in /poi/trunk/src/examples/src/org/apache/poi:
hssf/usermodel/examples/AddDimensionedImage.java
ss/examples/AddDimensionedImage.java
Author: yegor
Date: Mon Mar 15 06:14:03 2010
New Revision: 923072
URL: http://svn.apache.org/viewvc?rev=923072&view=rev
Log:
fixed compilation errors in recently added examples
Modified:
poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java
poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
Modified: poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java?rev=923072&r1=923071&r2=923072&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java Mon Mar 15 06:14:03 2010
@@ -198,8 +198,7 @@ public class AddDimensionedImage {
*/
public void addImageToSheet(String cellNumber, HSSFSheet sheet,
String imageFile, double reqImageWidthMM, double reqImageHeightMM,
- int resizeBehaviour) throws FileNotFoundException, IOException,
- IllegalArgumentException {
+ int resizeBehaviour) throws IOException, IllegalArgumentException {
// Convert the String into column and row indices then chain the
// call to the overridden addImageToSheet() method.
CellReference cellRef = new CellReference(cellNumber);
@@ -500,7 +499,6 @@ public class AddDimensionedImage {
double colWidthMM = 0.0D;
double overlapMM = 0.0D;
double coordinatePositionsPerMM = 0.0D;
- int fromNumber = startingColumn;
int toColumn = startingColumn;
int inset = 0;
@@ -558,7 +556,7 @@ public class AddDimensionedImage {
// Next, from the columns width, calculate how many co-ordinate
// positons there are per millimetre
- coordinatePositionsPerMM = ExcelUtil.TOTAL_COLUMN_COORDINATE_POSITIONS /
+ coordinatePositionsPerMM = ConvertImageUnits.TOTAL_COLUMN_COORDINATE_POSITIONS /
colWidthMM;
// From this figure, determine how many co-ordinat positions to
// inset the left hand or bottom edge of the image.
@@ -673,8 +671,7 @@ public class AddDimensionedImage {
* @throws java.io.IOException Thrown if reading the file failed or was
* interrupted.
*/
- private byte[] imageToBytes(String imageFilename)
- throws FileNotFoundException, IOException {
+ private byte[] imageToBytes(String imageFilename) throws IOException {
File imageFile = null;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
@@ -721,18 +718,26 @@ public class AddDimensionedImage {
* @param args the command line arguments
*/
public static void main(String[] args) {
- File file = null;
+ String imageFile = null;
+ String outputFile = null;
FileInputStream fis = null;
FileOutputStream fos = null;
HSSFWorkbook workbook = null;
HSSFSheet sheet = null;
try {
+ if(args.length < 2){
+ System.err.println("Usage: AddDimensionedImage imageFile outputFile");
+ return;
+ }
+ imageFile = args[0];
+ outputFile = args[1];
+
workbook = new HSSFWorkbook();
sheet = workbook.createSheet("Picture Test");
new AddDimensionedImage().addImageToSheet("A1", sheet,
- "C:/temp/1.png", 25, 25,
+ imageFile, 125, 125,
AddDimensionedImage.EXPAND_ROW_AND_COLUMN);
- fos = new FileOutputStream("C:/temp/Newly Auto Adjusted.xls");
+ fos = new FileOutputStream(outputFile);
workbook.write(fos);
}
catch(FileNotFoundException fnfEx) {
Modified: poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java?rev=923072&r1=923071&r2=923072&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/ss/examples/AddDimensionedImage.java Mon Mar 15 06:14:03 2010
@@ -24,7 +24,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
-import org.apache.commons.io.FilenameUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.ClientAnchor;
import org.apache.poi.ss.usermodel.Drawing;
@@ -250,8 +249,7 @@ public class AddDimensionedImage {
*/
public void addImageToSheet(String cellNumber, Sheet sheet, Drawing drawing,
URL imageFile, double reqImageWidthMM, double reqImageHeightMM,
- int resizeBehaviour) throws FileNotFoundException, IOException,
- IllegalArgumentException {
+ int resizeBehaviour) throws IOException, IllegalArgumentException {
// Convert the String into column and row indices then chain the
// call to the overridden addImageToSheet() method.
CellReference cellRef = new CellReference(cellNumber);
@@ -305,7 +303,7 @@ public class AddDimensionedImage {
*/
public void addImageToSheet(int colNumber, int rowNumber, Sheet sheet, Drawing drawing,
URL imageFile, double reqImageWidthMM, double reqImageHeightMM,
- int resizeBehaviour) throws FileNotFoundException, IOException,
+ int resizeBehaviour) throws IOException,
IllegalArgumentException {
ClientAnchor anchor = null;
ClientAnchorDetail rowClientAnchorDetail = null;
@@ -365,11 +363,11 @@ public class AddDimensionedImage {
imageType = Workbook.PICTURE_TYPE_JPEG;
}
else {
- throw new IllegalArgumentException("Invalid Image file extension: " +
- FilenameUtils.getExtension(sURL));
+ throw new IllegalArgumentException("Invalid Image file : " +
+ sURL);
}
int index = sheet.getWorkbook().addPicture(
- IOUtils.toByteArray(imageFile.openStream()),type);
+ IOUtils.toByteArray(imageFile.openStream()), imageType);
drawing.createPicture(anchor, index);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org