POI-HSSF or Cocoon?
Hi,
In our system we have one webb client and one Java application client.
They both comunicate with the server through 2 difftrent servlets.
Now I want to implement a method that creates Excel-files on the
server that both the clients can call.
I have found information about POI in this forum. When I went to
http://jakarta.apache.org/poi/hssf/index.html to check it out I read a
recomendation to use Cocoon instead:
"If you're modifying spreadsheet data then use the usermodel api. You can also generate spreadsheets this way, but using Cocoon (which will do it this way indirectly) is the best way...we promise."
So I read about Cocoon too and now I am really confused!!!
Will they stop developing POI-HSSF?
Is Cocoon only for webb aplication?
Can someone please help me?
:-)Lisa
I thought Cocoon was a tool for transforming XML into something else. You can probably use Cocoon's ability to transform XML (using POI) into Excel I guess, but Cocoon is not a tool to create Excel spreasheets no.
Similar Messages
-
Excel File Management Apache POI HSSF vs. jxl jar
I've been reviewing Java technologies for managing Excel files, and I'm a little confused about the differences between Apache's POI HSSF implementation and JExcelApi, and utimately what technology it makes sense to use.
They are both open source, although POI is backed by Apache, where JExcelApi seems to be open source developed by Andy Khan. It seem Apache has a little more weight, therefore may be a better option.
Can someone who has exposure to these technologies please provide me with some insight.
Thanks.Hi
Thanks for your reply,
Now I hav used an alternate approach of using Apache POI.
But.......
I have created simple table in jsp and set content type to
<%@ page contentType="application/vnd.ms-excel" %>
when i navigate to this jsp it is getting displayed in excel format.
I wish if user clicks on to navigate for this jsp, he must get an option to either open, save or cancel the jsp.
Then on selecting save a dialogue gets appeared where he can select path and file name.
Please comment.
Thanks. -
HOw to implement POI -HSSF in JSP
Hello Everybody,
requirement: I have to generate reports of the output from a jsp into excel spreadsheet.
what i did: Changed the Content type to
response.setContentType("application/vnd.ms-excel");
I am getting the output in Excel. But, it is taking long time to display.
I have searched in the net. I got the information that, i can use POI-hssf to generate Excel report.
Can any one who have experience on this POI-hssf implementation, could guide me?I couldn't understand details as to what other factors i need to look upon to start using this api in my project. ?!
Regards.
AShviniNO, Pgeuens !
What i mean is :
I have droped idea of using HSSF in my code. I am NOT
going to use it.
I can't do it, because, for each user, their
requirement will be different and input will be
different for the report. I can't assume all the
possible inputs and prepare the report in advance !This doesn't seem to be a good reason to drop the idea. Why don't you design a generic interface +class which will allow the report generation as per a set of defined rules? -
Inserting an Image in Excel with POI HSSF
Has anyone been successful creating an Excel document with an
embedded image using POI HSSF?
Create a nicely formatted Excel is no, problem - but I can't
seem to figure the image part out. I am not calling the loadPicture
correctly, which is confusing CF.
<cfset patriarch = newSheet.createDrawingPatriarch()/>
<cfset patriarch.createPicture(createObject("java",
"org.apache.poi.hssf.usermodel.HSSFClientAnchor").init(),
loadPicture("asset/images/logo_e2eA.png",
workSheet))/>MinOP wrote:
> but I can't seem to figure the image part out. I am not
calling the loadPicture correctly, which is confusing CF.
You did not mention which version of POI. Did you verify your
version supports the patriarch.createPicture method? If you are
using a really old version it might not.
> loadPicture("asset/images/logo_e2eA.png",
workSheet))/>
Does the code actually have access to a loadPicture() method
or function? I think loadPicture() is a private method in one of
the example classes: org.apache.poi.hssf.usermodel.examples.*. So
you may have to write your own version of it. Assuming you have not
done so already... -
Poi hssf api to generate MS-Excel file
I am using apache's poi hssf api to generate an excel file. Is there any way I can FREEZE PANES of excel sheet.
thanks,
PramodYou're wanting to make certain areas of your spreadsheet un-editable, yes? POI currently does not support this, as mentioned in the FAQ: http://jakarta.apache.org/poi/faq.html#faq-5 .
-
Excel Parsing -org.apache.poi.hssf.record.RecordFormatException
Hi ,
I am running into org.apache.poi.hssf.record.RecordFormatException,
while creating excel work book.
Few of the worksheets in the workbook are password protected.
If i remove the password proted worksheets then i am able to load the
workbook and can parse it.
I am using apache poi 2.5.1.
Is it possible to load workbook having few password proted sheets using apache POI?
I appreaciate any help in this.
Thanks in advance
Mark
code.
POIFSFileSystem fs =new POIFSFileSystem(input);
HSSFWorkbook wb = new HSSFWorkbook(fs);
Exception log:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:80)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java(Compiled Code))
at java.lang.reflect.Constructor.newInstance(Constructor.java(Compiled Code))
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java(Compiled Code))
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java(Compiled Code))
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
at com.cargill.aim.examples.ExcelParseTest.main(ExcelParseTest.java:43)
Caused by: java.lang.ArrayIndexOutOfBoundsException
at java.lang.System.arraycopy(Native Method)
at org.apache.poi.hssf.record.UnknownRecord.<init>(UnknownRecord.java:62)
at org.apache.poi.hssf.record.SubRecord.createSubRecord(SubRecord.java:57)
at org.apache.poi.hssf.record.ObjRecord.fillFields(ObjRecord.java:99)
at org.apache.poi.hssf.record.Record.fillFields(Record.java(Compiled Code))
at org.apache.poi.hssf.record.Record.<init>(Record.java(Compiled Code))
at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
... 9 more
Exception in thread "main" org.apache.poi.hssf.record.RecordFormatException: Unable to construct record instance, the following exception occured: null
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java(Compiled Code))
at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java(Compiled Code))
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:163)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:130)
at com.cargill.aim.examples.ExcelParseTest.main(ExcelParseTest.java:43)Hi,
I am dealing with the similer problem but the same error. I am using the latest version of POI 3.0.1 and trying to read the cells which have auto formating enabled for date. I am getting the same error. Please let me know if you come across any solution to read the formatted cells using POI.
Thanks in advance!
- Alok -
POI-HSSF problem. saves in /runtime/bin, not /wwwroot
I am trying to get this to work in Solaris/Apache/MX7. When I
run the code, it always saves the files in
<cfusionserver>/runtime/bin/
with owner "nobody|other"
i need the files to read and write from
<cfusionserver>/wwwroot/
owner "www|www"
any suggestions?
files located in <cfserver>/WEB-INF/lib/
-rw-r--r-- 1 www www 802216 May 16 09:42
poi-2.5.1-final-20040804.jar
-rw-r--r-- 1 www www 55209 May 16 09:42
poi-contrib-2.5.1-final-20040804.jar
<CFSCRIPT>
workBook=createObject("java","org.apache.poi.hssf.usermodel.HSSFWorkbook").init();
newSheet=workBook.createSheet();
workBook.setSheetName(0, "My First Sheet");
row=newSheet.createRow(55);
cell=row.createCell(0);
cell.setCellValue("hello world!");
fileOutStream =
createObject("java","java.io.FileOutputStream").init("test6.xls");
// ****** output
workBook.write(fileOutStream);
fileOutStream.close();
</CFSCRIPT>
I have tried using
.init("/opt/coldfusionmx7/wwwroot/test6.xls"); but i get an error.
Thanks if you can help
Davealso, you might try creating a file object first, initing
that with your
full path, and then passing that object into the init method
of the output
stream
"Marc E" <[email protected]> wrote in message
news:e4dlop$3t4$[email protected]..
> what error do you get when trying the init("/opt....")?
>
> that's on the right track...just using the filename
itself is definitely
> not what you want.
>
> what you might do to get the full path you're looking
for is create a file
> in wwwroot and do a
>
<cfoutput>#getDirectoryFromPath(getCurrentTemplatePath())#</cfoutput>
>
> that'll tell you what coldfusion thinks it is, and from
there you should
> have what you need to pass into the file init
>
>
> "DaveF67" <[email protected]> wrote in
message
> news:e4d0n6$6vh$[email protected]..
>>I am trying to get this to work in
Solaris/Apache/MX7. When I run the
>>code, it
>> always saves the files in
>>
>> <cfusionserver>/runtime/bin/
>> with owner "nobody|other"
>>
>> i need the files to read and write from
>> <cfusionserver>/wwwroot/
>> owner "www|www"
>>
>> any suggestions?
>>
>> files located in <cfserver>/WEB-INF/lib/
>>
>> -rw-r--r-- 1 www www 802216 May 16 09:42
>> poi-2.5.1-final-20040804.jar
>> -rw-r--r-- 1 www www 55209 May 16 09:42
>> poi-contrib-2.5.1-final-20040804.jar
>>
>>
>> <CFSCRIPT>
>>
>>
workBook=createObject("java","org.apache.poi.hssf.usermodel.HSSFWorkbook").init
>> ();
>> newSheet=workBook.createSheet();
>> workBook.setSheetName(0, "My First Sheet");
>> row=newSheet.createRow(55);
>> cell=row.createCell(0);
>> cell.setCellValue("hello world!");
>> fileOutStream =
>>
createObject("java","java.io.FileOutputStream").init("test6.xls");
>> ******
>> output
>> workBook.write(fileOutStream);
>> fileOutStream.close();
>> </CFSCRIPT>
>> I have tried using
.init("/opt/coldfusionmx7/wwwroot/test6.xls"); but i
>> get an
>> error.
>>
>> Thanks if you can help
>> Dave
>>
>>
>>
>
> -
Hey guys,
Im looking for a way to copy an excel file and convert it into a html file. I have found a way to read excel files using POI-HSSF (Fantastic tool by the way). What Im wondering is now that I have the worksheets contents stored in java is there any kind of library that you would recommend that might generate the tables ripped from Excel to HTML automatically?
Thanks for your help in advance
ValehruYoGee,
Thanks for the response. Im afraid that the client has insisted that I convert the document to html. I presume that if it was streamed out that it would open an excel worksheet in the browser itself?
If anyone has any suggestions please let me know. Personally id prefer that they use openoffice and just convert the thing to a pdf but as they say the customer is always right. Im pretty sure that It will take me a fair bit of time trying to parse the data I receive via HSSF into proper valid HTML which looks similar if not identical to the data in the excel file.
Thanks again for your reply -
Inserting gif/jpeg image into excel through POI-HSSF
HI,
I am using jExcel to generate xls file from java. But I have to include image into the excel sheet. but jExcel supports only PNG file format to insert into excel sheet.
what about POI-HSSF? Does it support inserting images into Excel or not. if supports what type of images it will support?
I am in urgent need of it. Help me out in this issue
ThanksMinOP wrote:
> but I can't seem to figure the image part out. I am not
calling the loadPicture correctly, which is confusing CF.
You did not mention which version of POI. Did you verify your
version supports the patriarch.createPicture method? If you are
using a really old version it might not.
> loadPicture("asset/images/logo_e2eA.png",
workSheet))/>
Does the code actually have access to a loadPicture() method
or function? I think loadPicture() is a private method in one of
the example classes: org.apache.poi.hssf.usermodel.examples.*. So
you may have to write your own version of it. Assuming you have not
done so already... -
POI- HSSF Excel Page Orientation
Hello
Does anyone know if you can set the page orientation of an Excel sheet using POI's HSSF?
Thanks in advance
iveRefer to the POI documentation http://jakarta.apache.org/poi/apidocs/index.html
HSSFSheet.getPrintSetup() will give the page settings as a HSSFPrintSetup object. There are setter methods available to orient the page as you need. -
Poi HSSF?? invalidHeaderSignature
Hi,
This question is related to jakarta POI: read an excel file from a java program.
In my program I am just opening an excel file and dumping the contents to STDOUT.
It worked for some time, later it started giving
java.io.IOException: Invalid header signature; read 7521418675403179042, expected -2226271756974174256
15:32:25,274 INFO [STDOUT] at org.apache.poi.poifs.storage.HeaderBlockReader.<init>(HeaderBlockReader.java:88)
15:32:25,274 INFO [STDOUT] at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:83)
Then I thought my excel file might be corrupted, but I tried with 10 different excel files and all are giving same exception.
Files which used to work earlier stopped working.
May be I didn't save excel files in correct format. How should I save them in binary format.
I dont know how to get rid of this problem,
Any help on this would be greatly appreciated.
Thanks in advance
nmadhavaTrue that the headers will be set properly if you Save the file through MS Excel program. But users will always try to Save it from the browser Pop Up itself and so MS Excel prog wont come in to the scene.
You can try the below code do solve the invalid header signature issue while Saving straight from the Pop Up and using it later for processing using HSSF
response.setContentType("application/vnd.ms-excel;charset=euc-kr");
Anyway this worked fine for me
Bye
Noufal -
POI HSSF Excel 2002 Data error
Hello,
I'm using HSSF 3.0.2 Final version to create an excel document from java.
This document contains pictures and some text under each picture in a row below. There are four sheets in the workbook and each contains about 30-40 pictures.
I can create document fine and I can open it with Excel 2000,
but when I try to open it with Excel 2002 and gives me data error.
My understanding is that 2002 is supported and it seems to be a simple enough document without any fancy features
Any idea what could be wrong?You can post your error and excel file to poi's mailing list.
http://poi.apache.org/mailinglists.html -
POI HSSF XML to Excel DataFormat Problem
Hiho,
I�ve got the following problem:
I want to create an Excel File from an XML File with POI and DOM4J. This works fine...
Now I want to create some cells with a currency value in it, on which I want to calculate.
Here�s my code:
HSSFSheet sheet = wb.createSheet(s);
HSSFDataFormat format = wb.createDataFormat();
HSSFCellStyle intStyle = wb.createCellStyle();
intStyle.setDataFormat(format.getFormat("(�#.##0,00);(�#.##0,00)"));
for (cellit = rowelement.elementIterator(); cellit.hasNext();) {
cellelement = (Element) cellit.next();
String value = cellelement.getStringValue();
cell = row.createCell(columnnum);
s = cellelement.attributeValue("numeric");
if (s != null) {
cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);
if (value != null)
cell.setCellValue(value);
cell.setCellStyle(intStyle);
...I always get a value with a prefixed apostrophe in Excel, which says that there�s an int value in a string cell (I think). Has anyone an idea whats wrong with my code? Thankshttp://jakarta.apache.org/site/mail2.html#poi
-
hi All
please help me in solving that problem, this error occurs when running my project, its for generating report using jasper report tool, exact at the line
"JRXlsExporter exporter = new JRXlsExporter();"
her is the code
try
JasperCompileManager.compileReport("E:/jasper_template/report2.jrxml");
tteset = JasperFillManager.fillReport(jasperReport, new HashMap(),new JRResultSetDataSource(rset));
JasperExportManager.exportReportToPdfFile(tteset,"E:/test.pdf");
JRXlsExporter exporter = new JRXlsExporter();
exporter.setParameter(JRExporterParameter.JASPER_P RINT,tteset);
exporter.setParameter(JRExporterParameter.OUTPUT_F ILE_NAME,"E:/test.xls");
exporter.exportReport();
catch (JRException e)
e.printStackTrace();
}I think you have to include jasperreports-1.2.7.jar in the classpathWhat?
exporter.setParameter(JRExporterParameter.OUTPUT_F ILE_NAME,"E:/test.xls");mentions a file test.xls which I assume naturally is an excel file.
POI can be used to modify/read excel files in java.
HSSFColor is used in POI
This leads me to the conclusion that POI is missing from the classpath.
How on earth did you come to your conclusions? -
my requirement is not output any xml and xls file,
but byte to bind to the WDWebResource for FileDownload
below is my code that output physical file tm.xml and convert to physical file tm.xls
i dont want this file to store but just keep it in memory
previous tutorial is about Export to excel, but the column title is start with /MailList/EmailId not just EMAILID so i decide to use POI...
if i change this
if (type=="MailInbound"){
byte[] xmldocument=null;
xmldocument=xml_file.toString().getBytes("UTF-8");
InputStream in=null;
in.read(xmldocument);
generateInboundMailExcel(in);
how am i going to modify
public static void generateInboundMailExcel(InputStream xmlDocument) {
if (type=="MailInbound"){
FileOutputStream fout=new FileOutputStream("tm.xml");
OutputStreamWriter out=new OutputStreamWriter(fout,"UTF-8");
out.write(xml_file.toString());
out.flush();
out.close();
File xmlDocument = new File("tm.xml");
generateInboundMailExcel(xmlDocument);
public static void generateInboundMailExcel(File xmlDocument) {
try {// Creating a Workbook
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet spreadSheet = wb.createSheet("spreadSheet");
spreadSheet.setColumnWidth((short) 0, (short) (256 * 25));
spreadSheet.setColumnWidth((short) 1, (short) (256 * 25));
// Parsing XML Document
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
Document document = builder.parse(xmlDocument);
NodeList nodeList = document.getElementsByTagName("TablesemailinElement");
//Create font style
HSSFFont font=wb.createFont();
font.setFontHeightInPoints((short)10);
font.setFontName("Verdana");
font.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
HSSFCellStyle style=wb.createCellStyle();
style.setFont(font);
// Creating Rows
HSSFRow row = spreadSheet.createRow(0);
HSSFCell cell = row.createCell((short) 0);
cell.setCellValue("DATE IN");
cell.setCellStyle(style);
cell = row.createCell((short) 1);
cell.setCellValue("EMAIL ID");
cell.setCellStyle(style);
cell = row.createCell((short) 2);
cell.setCellValue("SUBJECT");
cell.setCellStyle(style);
for(int i=0;i<nodeList.getLength();i++){
HSSFRow rowno=spreadSheet.createRow(i+1);
HSSFCellStyle cellStyle = wb.createCellStyle();
cellStyle.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);
cellStyle.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
//***********take note for string and date*************
cell = rowno.createCell((short) 0);
cell.setCellValue(((Element) (nodeList.item(i)))
.getElementsByTagName("dateIn").item(0)
.getFirstChild().getNodeValue());
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell = rowno.createCell((short) 1);
cell.setCellValue(((Element) (nodeList.item(i)))
.getElementsByTagName("emailId").item(0)
.getFirstChild().getNodeValue());
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
cell = rowno.createCell((short) 2);
cell.setCellValue(((Element) (nodeList.item(i)))
.getElementsByTagName("subject").item(0)
.getFirstChild().getNodeValue());
cell.setCellType(HSSFCell.CELL_TYPE_STRING);
// Outputting to Excel spreadsheet
System.err.println("Outputing");
FileOutputStream output = new FileOutputStream(new File("tm.xls"));
wb.write(output);
output.flush();
output.close();
} catch (Exception e) {
System.out.println("Exception " + e.getMessage());ANYONE CAN HELP
i have successfully do the first part..
which is parse in the inputstream
public static byte[] generateInboundMailExcel(InputStream xmlDocument) {
//formatting the column
//output the file
byte[] b;
//manipulate the output
ByteArrayOutputStream out=new ByteArrayOutputStream;
wb.write(out);
//how do i output to byte[] instead of File
return b;
InputStream in;
in=getInputFromBufferedReader(sb);
generateInboundMailExcel(in);
public static InputStream getInputFromBufferedReader(StringBuffer sb){
InputStream is=null;
try{
is=new ByteArrayInputStream(sb.getBytes());
}catch(Exception e){
System.err.println("convert Exception:" +e.getMessage());
return is;
public static void generateInboundMailExcel(InputStream xmlDocument) {
//formatting the column
//output the file
FileOutputStream output = new FileOutputStream(new File("tm.xls"));
wb.write(output);
output.flush();
output.close();
Message was edited by:
yzme yzme
Message was edited by:
yzme yzme
Message was edited by:
yzme yzme
Maybe you are looking for
-
My in-laws are moving from the eastern part of Virginia up to the northern part of Virginia. They are currently renting a house. Now, is there a way of forwarding there calls to their cell phones and having the service in the rental house turned off?
-
Snow leopard very sluggish in general.
Since I upgraded to snow leopard on both of my machines they both have been extremely slow. Snow leopard claimed to be twice as fast, but I experience something that is 10 times as slow. I had no problems with Leopard. I have 2 macs: Mac Pro 8 cores
-
How to slow Motion Scroll Effects and anchors?
I am using a down pointing arrow to cue the user to scroll down to the next section. I thought I could automate by linking the arrow to an anchor that is positioned down the page. Cool, it works. However, the jump is so fast that all the fancy Motion
-
VT01N-Loading Sequence number functionality /BEV1/RPFLGNR in table VTTK.
Hi Gurus, While creating shipment in VT01N, in the process screen, one field Sequence number: is showing by default Zero. Loading Sequence Number in the Tour /BEV1/RPFLGNR in table VTTK. Sequence number of the load in the tour. When will this sequenc
-
TS4196 I am having problems un-installing iMessages(Beta) and re-installing iChat
Could someone help me with an answer to my problem. I installed the (BETA) version of iMessages, and now I want to un-install it and get my iChat bck. But, I am running into a problem. Each time I to the the iMessages menu, and select "Uninstall Mess