You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by m-...@daimlerchrysler.com on 2006/12/06 08:29:34 UTC
Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5
---Help urgent
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
Posted by Anthony Andrews <py...@yahoo.com>.
Firstly, I found out the VBA that you would have to code to insert the picture using an on activation macro;
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 07/12/2006 by XXXXXX
'
'
Range("A1").Select
ActiveSheet.Pictures.Insert( _
"C:\temp\my_image.jpg"). _
Select
End Sub
If you look in the top left hand corenr of the menu bar, you will see the excel logo. Place the mouse cursor over this and click on the right hand mouse button to open up a menu. The final entry in this menu should be 'View Code' and you should click on that.
The screen that opens looks very complex but it is not really and you should focues on the left hand drop down list first. From this, select the "Workbook" option. Now open the right hand drop down list and you should see lots of options; these are all triggers or stages where you can write the macro. Choose "Open" from that list and copy my code into it modifying the path to and name of the image file. Save everything away and close the spreadsheet. When you open it the image should be inseretd into cell A1. Of course, you can change the cells address by editing the Range command.
With regard to the JExcel code, that very much depends on what you want to do. If it helps, you can e-mail me directly - if we are to talk about JExcel, it is best to take if out of the group I think - and let me know just what you want to do.
m-n.rajulah@daimlerchrysler.com wrote: thanks a lot for the detailed reply ...Can you please let me know if
possible ..JExcel code snippet ...
pythonaddict@yahoo.com
07.12.2006 14:11
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I can think of three possible options.
The first is to look at using an on-activation macro to embed the image
for you. I do not know the VBA code that you would need to use but you can
embed a macro in the template spreadsheet file. This macro will be
preserved when you create the final file based upon it and using POI and
it would certainly be the first option I would explore.
Secondly, you could upgrade to a more recent version of POI that will
support images.
Finally, you could change to using JExcel rather than POI. I use both and
only began to use JExcel when one of my clients requested a system to
prepare invoices using Excel based on a template that included an image
that was their heading.
m-n.rajulah@daimlerchrysler.com wrote: the error is still there ..POI
2.5.1 does not support this feature .....Is
there any other way by which this can be implemented ..
[javac] ExcelKurveAction.java:688: cannot find symbol
[javac] symbol : variable PICTURE_TYPE_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
[javac] ^
[javaca:704: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
[javac] Note: * uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
pythonaddict@yahoo.com
06.12.2006 17:35
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Antwort: Re: Add images to a cell using POI
2.5 ---Help urgent
Not tested this so I cannot be sure but I think it is just a spelling
error.
You have entered;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
and I think it should be;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
You may have miss-typed the name of the static variable.
m-n.rajulah@daimlerchrysler.com wrote:
[javac]reports\action\ExcelKurveAction.java:669: cannot find symbol
[javac] symbol : variable PICTURE_TYP_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
[javac] ^
[javac]reports\action\ExcelKurveAction.java:686: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
Hope this helps
Regards
pythonaddict@yahoo.com
06.12.2006 08:32
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help
urgent
What error/exception are you seeing when you try to add the image? Could
you post the statctrace please - if there is one?
m-n.rajulah@daimlerchrysler.com wrote: private int loadPicture( String
path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
---------------------------------
Check out the all-new Yahoo! Mail beta - Fire up a more powerful email and get things done faster.
Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
Posted by m-...@daimlerchrysler.com.
thanks a lot for the detailed reply ...Can you please let me know if
possible ..JExcel code snippet ...
pythonaddict@yahoo.com
07.12.2006 14:11
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I can think of three possible options.
The first is to look at using an on-activation macro to embed the image
for you. I do not know the VBA code that you would need to use but you can
embed a macro in the template spreadsheet file. This macro will be
preserved when you create the final file based upon it and using POI and
it would certainly be the first option I would explore.
Secondly, you could upgrade to a more recent version of POI that will
support images.
Finally, you could change to using JExcel rather than POI. I use both and
only began to use JExcel when one of my clients requested a system to
prepare invoices using Excel based on a template that included an image
that was their heading.
m-n.rajulah@daimlerchrysler.com wrote: the error is still there ..POI
2.5.1 does not support this feature .....Is
there any other way by which this can be implemented ..
[javac] ExcelKurveAction.java:688: cannot find symbol
[javac] symbol : variable PICTURE_TYPE_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
[javac] ^
[javaca:704: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
[javac] Note: * uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
pythonaddict@yahoo.com
06.12.2006 17:35
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Antwort: Re: Add images to a cell using POI
2.5 ---Help urgent
Not tested this so I cannot be sure but I think it is just a spelling
error.
You have entered;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
and I think it should be;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
You may have miss-typed the name of the static variable.
m-n.rajulah@daimlerchrysler.com wrote:
[javac]reports\action\ExcelKurveAction.java:669: cannot find symbol
[javac] symbol : variable PICTURE_TYP_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
[javac] ^
[javac]reports\action\ExcelKurveAction.java:686: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
Hope this helps
Regards
pythonaddict@yahoo.com
06.12.2006 08:32
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help
urgent
What error/exception are you seeing when you try to add the image? Could
you post the statctrace please - if there is one?
m-n.rajulah@daimlerchrysler.com wrote: private int loadPicture( String
path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Re: Add images to a cell using POI 2.5 ---Help urgent
Posted by Anthony Andrews <py...@yahoo.com>.
I can think of three possible options.
The first is to look at using an on-activation macro to embed the image for you. I do not know the VBA code that you would need to use but you can embed a macro in the template spreadsheet file. This macro will be preserved when you create the final file based upon it and using POI and it would certainly be the first option I would explore.
Secondly, you could upgrade to a more recent version of POI that will support images.
Finally, you could change to using JExcel rather than POI. I use both and only began to use JExcel when one of my clients requested a system to prepare invoices using Excel based on a template that included an image that was their heading.
m-n.rajulah@daimlerchrysler.com wrote: the error is still there ..POI 2.5.1 does not support this feature .....Is
there any other way by which this can be implemented ..
[javac] ExcelKurveAction.java:688: cannot find symbol
[javac] symbol : variable PICTURE_TYPE_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
[javac] ^
[javaca:704: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
[javac] Note: * uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
pythonaddict@yahoo.com
06.12.2006 17:35
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Antwort: Re: Add images to a cell using POI
2.5 ---Help urgent
Not tested this so I cannot be sure but I think it is just a spelling
error.
You have entered;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
and I think it should be;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
You may have miss-typed the name of the static variable.
m-n.rajulah@daimlerchrysler.com wrote:
[javac]reports\action\ExcelKurveAction.java:669: cannot find symbol
[javac] symbol : variable PICTURE_TYP_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
[javac] ^
[javac]reports\action\ExcelKurveAction.java:686: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
Hope this helps
Regards
pythonaddict@yahoo.com
06.12.2006 08:32
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help
urgent
What error/exception are you seeing when you try to add the image? Could
you post the statctrace please - if there is one?
m-n.rajulah@daimlerchrysler.com wrote: private int loadPicture( String
path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Add images to a cell using POI 2.5 ---Help urgent
Posted by m-...@daimlerchrysler.com.
the error is still there ..POI 2.5.1 does not support this feature .....Is
there any other way by which this can be implemented ..
[javac] ExcelKurveAction.java:688: cannot find symbol
[javac] symbol : variable PICTURE_TYPE_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
[javac] ^
[javaca:704: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
[javac] Note: * uses or overrides a deprecated API.
[javac] Note: Recompile with -Xlint:deprecation for details.
[javac] Note: Some input files use unchecked or unsafe operations.
[javac] Note: Recompile with -Xlint:unchecked for details.
[javac] 2 errors
pythonaddict@yahoo.com
06.12.2006 17:35
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Antwort: Re: Add images to a cell using POI
2.5 ---Help urgent
Not tested this so I cannot be sure but I think it is just a spelling
error.
You have entered;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
and I think it should be;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
You may have miss-typed the name of the static variable.
m-n.rajulah@daimlerchrysler.com wrote:
[javac]reports\action\ExcelKurveAction.java:669: cannot find symbol
[javac] symbol : variable PICTURE_TYP_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
[javac] ^
[javac]reports\action\ExcelKurveAction.java:686: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
Hope this helps
Regards
pythonaddict@yahoo.com
06.12.2006 08:32
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help
urgent
What error/exception are you seeing when you try to add the image? Could
you post the statctrace please - if there is one?
m-n.rajulah@daimlerchrysler.com wrote: private int loadPicture( String
path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Re: Antwort: Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
Posted by Anthony Andrews <py...@yahoo.com>.
Not tested this so I cannot be sure but I think it is just a spelling error.
You have entered;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
and I think it should be;
wb.addPicture(bos.toByteArray(),HSSFWorkbook.PICTURE_TYPE_PNG);
You may have miss-typed the name of the static variable.
m-n.rajulah@daimlerchrysler.com wrote: [javac]reports\action\ExcelKurveAction.java:669: cannot find symbol
[javac] symbol : variable PICTURE_TYP_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
[javac] ^
[javac]reports\action\ExcelKurveAction.java:686: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
Hope this helps
Regards
pythonaddict@yahoo.com
06.12.2006 08:32
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help
urgent
What error/exception are you seeing when you try to add the image? Could
you post the statctrace please - if there is one?
m-n.rajulah@daimlerchrysler.com wrote: private int loadPicture( String
path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.
---------------------------------
Cheap Talk? Check out Yahoo! Messenger's low PC-to-Phone call rates.
Antwort: Re: Antwort: Re: Antwort: Re: Add images to a cell using
POI 2.5 ---Help urgent
Posted by m-...@daimlerchrysler.com.
[javac]reports\action\ExcelKurveAction.java:669: cannot find symbol
[javac] symbol : variable PICTURE_TYP_PNG
[javac] location: class org.apache.poi.hssf.usermodel.HSSFWorkbook
[javac] pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
[javac] ^
[javac]reports\action\ExcelKurveAction.java:686: cannot find symbol
[javac] symbol : method
createPicture(org.apache.poi.hssf.usermodel.HSSFClientAnchor,int)
[javac] location: class org.apache.poi.hssf.usermodel.HSSFPatriarch
[javac] patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
[javac] ^
Hope this helps
Regards
pythonaddict@yahoo.com
06.12.2006 08:32
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help
urgent
What error/exception are you seeing when you try to add the image? Could
you post the statctrace please - if there is one?
m-n.rajulah@daimlerchrysler.com wrote: private int loadPicture( String
path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.
Re: Antwort: Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
Posted by Anthony Andrews <py...@yahoo.com>.
What error/exception are you seeing when you try to add the image? Could you post the statctrace please - if there is one?
m-n.rajulah@daimlerchrysler.com wrote: private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
Thanks for the reply ..See I did the following as said in the guide ..but
gives error on addPicture () and CreatePicture() ....Iam using POI 2.5
.Have alook at the code snippet also if needed which states exactly what
you recomended .. ..also Iam trying to add a image through POI only ..
Thanks n Regards
HEpzibah
pythonaddict@yahoo.com
05.12.2006 18:39
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Antwort: Re: Add images to a cell using POI 2.5 ---Help urgent
.png should be fine.
I have cut the folowing from the user guide to see if it helps at all.
Images are part of the drawing support. To add an image
just call createPicture() on the drawing patriarch. At
the time of writing the following types are supported:
PNG
JPG
DIB
It is not currently possible to read
existing images and it should be noted that any existing
drawings may be erased once you add a image to a sheet.
// Create the drawing patriarch. This is the top level
container for
// all shapes. This will clear out any existing shapes for that sheet.
HSSFPatriarch patriarch = sheet5.createDrawingPatriarch();
HSSFClientAnchor anchor; anchor = new
HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7); anchor.setAnchorType( 2
); patriarch.createPicture(
anchor, loadPicture( "src/resources/logos/logoKarmokar4.png", wb ));
>From reading that it seems that you will have to insert the image rather
than copy it from the spreadsheet.
m-n.rajulah@daimlerchrysler.com wrote: Iam using .png
pythonaddict@yahoo.com
05.12.2006 13:48
Bitte antworten an
poi-user@jakarta.apache.org
An
poi-user@jakarta.apache.org
Kopie
Thema
Re: Add images to a cell using POI 2.5 ---Help urgent
I am pretty sure you should be able to use a template that includes an
image and then create a workbook based upon that template. What type of
image are you using (.jpg, .png, .bmp)? It may be that it is simply the
'wrong' type.
m-n.rajulah@daimlerchrysler.com wrote: I want to have a logo in a cell and
tried having it part of the template
and loading it ..
While trying to open gives error which otherwise works perfectly without
the image ..
Therefore tried the following code...
But POI 2.5 does not support createPicture() method of patriach and
addPicture () of workbook ..
Is there a way out for this ..please help ..
Regards
Hepzibah
private int loadPicture( String path, HSSFWorkbook wb ) throws IOException
{
int pictureIndex;
FileInputStream fis = null;
ByteArrayOutputStream bos = null;
try
{
fis = new FileInputStream( path);
bos = new ByteArrayOutputStream( );
int c;
while ( (c = fis.read()) != -1)
bos.write( c );
pictureIndex = wb.addPicture(
bos.toByteArray(),HSSFWorkbook.PICTURE_TYP_PNG);
}
finally
{
if (fis != null)
fis.close();
if (bos != null)
bos.close();
}
return pictureIndex;
}
private void addLogo( HSSFSheet sheet, HSSFWorkbook wb ) throws
IOException
{
HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
HSSFClientAnchor anchor;
anchor = new HSSFClientAnchor(0,0,0,100,(short)0,11,(short)0,14);
//anchor.setAnchorType(2);
patriarch.createPicture(anchor, loadPicture(
"/images/logos/DC.png", wb ));
}
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.
---------------------------------
Need a quick answer? Get one in minutes from people who know. Ask your
question on Yahoo! Answers.
---------------------------------
Want to start your own business? Learn how on Yahoo! Small Business.