i found that, others have the same probleme:
http://www.nabble.com/XSSFWoorkbook.write()-problem-td21071450.html
This is not necessarily the same problem, that was about XSSFWorkbook
which is new and under beta.
You are using HSSFWorkbook and the trouble is that you are serving
binary information through struts2 and jsp2 and that is meant for
text. Excel files are binary.
curl -s http://localhost:8080/yourwebapps/yourtemplaterequest |
hexdump -n 8 -e
Please try this and we can see if we understand. Otherwise you really
have a server configuration problem with struts.
This is not the list for that, please try
http://www.nabble.com/Struts---User-f206.html
Regards,
Dave
On Jan 30, 2009, at 6:22 PM, rahali wrote:
i devlope a j2ee application with struts2 and jsp2 technology, i'm
under xp
service pack2, and my browsers are firfox, IE.
*my IDE is eclipse 3.2.1.
my java code is :
String fs = System.getProperty("file.separator");
POIFSFileSystem fs1 = new POIFSFileSystem(new FileInputStream(
ServletActionContext.getServletContext().getRealPath("") + fs +
"template" + fs + fileName));
HSSFWorkbook wb1 = new HSSFWorkbook(fs1, true);
pResponse.setHeader("Content-Disposition",
"attachment;filename="+fileName);
pResponse.setContentType("application/vnd.ms-excel");
// Write the output
OutputStream out = pResponse.getOutputStream();
wb1.write(out);
out.close();
i want just to load a file from my browser.
the input file hase colors, styles, borders .... (formattting)
but the output file lost its formatting.
accuelly, am using poi-3.0-alpha2-20060616.jar
i found that, others have the same probleme:
http://www.nabble.com/XSSFWoorkbook.write()-problem-td21071450.html
to circumvent my problem : I associate xls extension to OpenOffice.
then, when i load the file, its opened with OpenOffice.
--------------------------------------------------
David Fisher wrote:
I wonder if the problem is not with POI.
i laod my excel file with httpresponse and, my file lose the format,
i got a
message where the Ms Excel informe me that this file is endomaged.
but the
file is opened with MsExcel 2000 and openOffice.
Tell us about your workflow.
(1) Are you making your HTTP request from within Excel and
OpenOffice,
or are you making the request in a Browser like Internet Explorer and
then saving the file?
(2) What servlet container do you use? What version?
(3) Are you using a servlet or a JSP?
JSPs are meant for Text only and you get in trouble if you don't have
every "%>" immediately followed by a "<%". If you have this:
.... %>
<% ....
before your code then JSP will send a whitespace character in the
response and this could certainly cause trouble.
You can see if you use Josh's command but with the url you use to hit
your server.
curl -s http://localhost:8080/yourwebapps/yourtemplaterequest |
hexdump -n 8 -e
(4) Does your url end with ".xls"?
Older version of windows and IE seem to require this help. We used to
add an extra parameter to the request to fix the issue.
HTH,
Dave
On Jan 30, 2009, at 4:29 PM, Josh Micich wrote:
Hello Hicham,
The two files you uploaded open OK in POI (i.e.
WorkbookFactory.create()
completes normally).
I do not know how to verify the spreadsheet formats
You can also check the initial bytes of these files easily from a
unix
prompt with something like this:
$ curl -s http://www.nabble.com/file/p21746193/input.xls | hexdump -
n 8 -e
'16/1 "%02X " "\n"'
D0 CF 11 E0 A1 B1 1A E1
$ curl -s http://www.nabble.com/file/p21746193/outout+2+.xls |
hexdump -n 8
-e '16/1 "%02X " "\n"'
D0 CF 11 E0 A1 B1 1A E1
These 8 bytes are consistent what is expected in the 'Microsoft
Compound
Document' format. This is expected since POI didn't report an
error.
I am having trouble understanding what the exact problem is. I
tried
opening the two files in Excel (2007) and that was OK too.
regards,
Josh
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
--
View this message in context:
http://www.nabble.com/Can%27t-read-excel-2003-xls-file-tp21328806p21758247.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]