Saving excel file using HSSF api
I am using HSSF api to download an excel file. But the end users are not able to save the file. Some of them do not get the popup file download window so that they can choose to open or save. Is there a setting in the browser which shows up the window? The users may have different versions of excel on their pcs.
How to show the excel application menu 'file' so that users can save this file?
Any help would be appreciated.
Prakash,
I have followed your weblog and set the content dispostion.
HttpServletResponse res = request.getServletResponse(true);
try {
res.setContentType("application/vnd.ms-excel");
res.setHeader("Content-disposition", "inline; filename=report.xls");
wb.write(res.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
When I test this on my pc, I get file download window and I can choose 'open' or'save'. I also have tested this on some of my collegues PCs successfully. But the some of the end users are not getting this window.
when the same is file is downloaded by running an asp page the enire MSExcel application with standard tool bar and menus(file edit etc..) is showing up.
Why is it not poosible to get the same result using HSSF api?
Similar Messages
-
Drawing an image in excel sheet using HSSF API
Hi All,
Can any one please help me.
I am facing an issue with excel sheet while drawing image using HSSF API.
I am doing autofit for all the cells i have added. But the image is stretching along with the expanded cells.
I want the autofit option to work but the image should not stretch. Image should be the same size as is but the cells must expand.
Thanks in advanceHi Santosh
You can export the report to PDF
Else you can manually copy the logo\image to excel sheet.
Hope it will help.
Regards
Kultar -
How do I create/update an Excel file using the API?
Hi,
I've successfully created a "Web Intelligence" document using the API (POST /raylight/v1/documents). However, I need to do the same for an Excel file type and have been unable to do so. Attached are the different steps needed to accomplish this with the UI. I need to be able to do the same thing through the API.
I searched through the docs but haven't found anything regarding this particular aspect.
Does anyone have a clue?
ThanksThanks for the link. I'm using .Net and thought the process would be fairly similar. It is indeed, however, I'm stuck with the following error when committing on the infoStore object:
File Repository Server error :
ErrorCode: -2147210678
Here's the code I'm using:
var folderID = infoStore.Query("Select TOP 1 SI_ID From CI_INFOOBJECTS Where SI_KIND='Folder' And SI_NAME='myfolder'")[1].ID;
var infoObjects = infoStore.NewInfoObjectCollection();
var infoObject = infoObjects.Add(CrystalDecisions.Enterprise.InfoStore.CeKind.EXCEL);
infoObject.Title = "Book4.xlsx";
infoObject.Files.Add("C:\\Users\\myuser\\Documents\\Book4.xlsx");
infoObject.ParentID = folderID;
infoStore.Commit(infoObjects);
I know the problem is related to "infoObject.Files.Add" because when I omit this statement, it works but the file has no content.
Any idea why??? It's driving me crazy -
Error while saving xml file using PDFDocument API
Hi,
I am trying to save xml file using byte array obtained from interactive form element in webdynpro java.
The file gets saved but I get fllowing error message when I open the file.
The XML page cannot be displayed
Cannot view XML input using style sheet. Please correct the error and then click the Refresh button, or try again later.
An invalid character was found in text content. Error processing resource 'http://uxjciesk.wdf.sap.corp:50000/irj/go/km/doc...
The code I am trying to achieve the functionality is:
byte[] byteArray = wdContext.currentContextElement().getPdfSource();
IWDPDFDocumentHandler pdfDocumentHandler = WDPDFDocumentFactory.getDocumentHandler();
IWDPDFDocumentAccessibleContext documentAccessibleContext = pdfDocumentHandler.getDocumentAccessibleContext();
documentAccessibleContext.setPDF(byteArray);
IWDPDFDocument pdfDocument = documentAccessibleContext.execute();
ByteArrayInputStream dataInputStream = (ByteArrayInputStream) pdfDocument.getPDFAsStream();
further, the datainputstream is used to store the file. I am able to save same xdp template in pdf file format successfully, the error only occurs for xml file storage.
Please, advise.
Regards,
UrvashiHi Urvashi,
Try this code
String contentStr = getXMLData(wdContext.currentContextElement().getPdfSource().read(false));
String data = "";
ByteArrayOutputStream pdfSourceOutputStream = new ByteArrayOutputStream();
try {
InputStream pdfSourceInputStream = wdContext.currentContextElement().getData().read(false);
BufferedInputStream bufferedInputStream = new BufferedInputStream(wdContext.currentContextElement().getData().read(false));
int aByte;
while ((aByte = bufferedInputStream.read()) != -1) {
pdfSourceOutputStream.write(aByte);
pdfSourceOutputStream.flush();
pdfSourceOutputStream.close();
IWDPDFDocument pdfDocument = null;
try {
// Create an instance for PDFDocumnetHandler
IWDPDFDocumentHandler pdfDocumentHandler = WDPDFDocumentFactory.getDocumentHandler();
//Create an Inatance for PDFDocumentAccessibleContext
IWDPDFDocumentAccessibleContext documentAccessibleContext = pdfDocumentHandler.getDocumentAccessibleContext();
//set the pdf data as OutputStream to the PDFDocumentAccessibleContext instance
documentAccessibleContext.setPDF(pdfSourceOutputStream);
//call the server to get the data
pdfDocument = documentAccessibleContext.execute();
//get the xml data in a InputStream
ByteArrayInputStream dataInputStream = (ByteArrayInputStream) pdfDocument.getData();
} catch (Exception e) {
data = "Null";
} catch (IOException e) {
Regards,
Mathan -
Reading and Writing large Excel file using JExcel API
hi,
I am using JExcelAPI for reading and writing excel file. My problem is when I read file with 10000 records and 95 columns (file size about 14MB), I got out of memory error and application is crashed. Can anyone tell me is there any way that I can read large file using JExcelAPI throug streams or in any other way. Jakarta POI is also showing this behaviour.
Thanks and advanceSorry when out of memory error is occurred no stack trace is printed as application is crashed. But I will quote some lines taken from JProfiler where this problem is occurred:
reader = new FileInputStream(new File(filePath));
workbook = Workbook.getWorkbook(reader);
*sheeet = workbook.getSheet(0);* // here out of memory error is occured
JProfiler tree:
jxl.Workbook.getWorkBook
jxl.read.biff.File
jxl.read.biff.CompoundFile.getStream
jxl.read.biff.CompoundFile.getBigBlockStream Thanks -
Read an Excel file using POIFSFileSystem API
hello,
I'm working on J2EE web assignment. Following is my requirement
1) User select local excel file and hit submit
2) API takes that file read and create a new Excel file.
I am wondering if I can somehow get inputsteam on form post and then pass it to POI api
POI api syntax
POIFSFileSystem fs = new POIFSFileSystem(java.io.InputStream);
thanks,
Amitthere are plenty of tutorials and docs online
this site is for technical help, general questions should be submitted to Google -
Help needed saving excel file using servlet and mailing it as attachment
Hi,
I have to enhance an existing application in which (in jsp) using response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment=inline");
and stuff ..
we are asking user to view or save the file. But now i have to write code to save that xls, and send it as an attachment to other users of the application.
I am new to this plz help me out
Thanks in advance
Regards
AashiHi Orlando,
convert content to Hex format then,
lw_document = cl_document_bcs=>create_document(
i_type = 'RAW / HTM'
i_text = lw_main_text
i_subject = lw_subject ).
w_document->add_attachment(
i_attachment_type = 'XLS'
i_attachment_subject = lw_att_sub
i_att_content_text = p_int_soli[]
i_att_content_hex = p_int_solix[] ).
w_int_address = lw_smtp-low.
w_camuser = cl_cam_address_bcs=>create_internet_address( w_int_address ).
w_recipient = w_camuser.
thanks,
Anil -
Problem while writing data on xls file using jxl API
Hi,
I am getting problem while writing data on excel file using jxl api.
When i write data on file and all handles associated to the file are closed, file size increases but when i open the file nothing is written in it and when file is closed manually from excel window, file size decreased to its original that was before writing data.
here is code:
FileOutputStream os = new FileOutputStream(this.dirPath + this.fileName, true);
WritableWorkbook this.workbook = Workbook.createWorkbook(os);
after writing data following handler are closed:
this.os.flush();
this.workbook.write();
this.workbook.close();
this.os.close();
this.os = null;
can any body help me.
Thanks in advanceErr, I did help you. I did understand your problem; and I solved it for you. What was missing was that you apparently made no effort to understand what you were being told. Or even consider it. You just argued about it, as though you were the one with the solution, instead of the one whose code didn't work.
And the other thing that was missing was the part where you said 'thank you' to me for solving your problem. Somewhat more appropriate than biting the hand that fed you, frankly. I do this for nothing, on my own gas, and it's extremely irritating when people keep asking about problems I have already solved for them. I am entitled to discourage that. It's part of making them more efficient actually.
But it happens often enough that it also makes me think I'm just wasting my time. Probably I am. -
Hello everybody !
I want to use POI package (HSSF - interfacing with Excel files) and I cannot compile my Java file ! (I can run the file from netbeans !!!)
Maybe I don't know how should I manage the package installation!Prakash,
I have followed your weblog and set the content dispostion.
HttpServletResponse res = request.getServletResponse(true);
try {
res.setContentType("application/vnd.ms-excel");
res.setHeader("Content-disposition", "inline; filename=report.xls");
wb.write(res.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
When I test this on my pc, I get file download window and I can choose 'open' or'save'. I also have tested this on some of my collegues PCs successfully. But the some of the end users are not getting this window.
when the same is file is downloaded by running an asp page the enire MSExcel application with standard tool bar and menus(file edit etc..) is showing up.
Why is it not poosible to get the same result using HSSF api? -
Saving excel file attachment on phone
I received and excel file via email on my phone and would like to save it for later to use with the office plus program. I can open the file from my phone but do not know how to save it. Can anyone help.
Prakash,
I have followed your weblog and set the content dispostion.
HttpServletResponse res = request.getServletResponse(true);
try {
res.setContentType("application/vnd.ms-excel");
res.setHeader("Content-disposition", "inline; filename=report.xls");
wb.write(res.getOutputStream());
} catch (Exception e) {
e.printStackTrace();
When I test this on my pc, I get file download window and I can choose 'open' or'save'. I also have tested this on some of my collegues PCs successfully. But the some of the end users are not getting this window.
when the same is file is downloaded by running an asp page the enire MSExcel application with standard tool bar and menus(file edit etc..) is showing up.
Why is it not poosible to get the same result using HSSF api? -
Read an excel file using JSP in MII 12.1
Hi,
I want to read an excel file using jsp page. I dont want to use the UDS or ODBC for connecting to excel.
I am trying to use org.apache.poi to read the excel file in jsp page.
While running, its showing a compilation error "package org.apache.poi.hssf.usermodel does not exist"
I have the jar files for it, where do we need to upload it so that jsp page works.
Thanks a lot
Regards,
Neha MaheshwariThe user doesn't want to save the excel file in server.
I want to upload file and save its contents in database.
I have the code to read and save excel data in database but not able to get the location to deploy the jar file.
In general, if we are creating a jsp page in MII workbench which is using some jar file.
Whats the location to upload this jar file so that the jsp page works correctly? -
I would like to upload a excel file using jsp
Hi,
I would like to upload the excel file using jsp in my netbeans ide. Please help.
I don Know what is the error in this jsp file. It is not showing any thing and the file is also not getting uploaded.
Please gothru the code below.
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ page import="java.io.*" errorPage="err.jsp"%>
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link href="<html:rewrite page="/design.css" />" rel="stylesheet" type="text/css">
<title>Upload Page</title>
</head>
<body onKeyDown="DisablingBackFunctionality()" onLoad="DisablingBackFunctionality()">
<html:form action="download" >
<div style="position:absolute; left:100;top:200;">Select an excel File :<input type="file" name="uploadfile"></div>
<div style="position:absolute; left:190;top:250;"><input type="submit" name="Submit" value="Read"></div>
<div style="position:absolute; left:336;top:250;"><input type="reset" name="Reset" value="Clear"></div>
mainmenu
</html:form>
</body>
</html>
<%
String contentType = request.getContentType();
if ((contentType != null) && (contentType.indexOf("multipart/form-data") >= 0)) {
DataInputStream in = new DataInputStream(request.getInputStream());
int formDataLength = request.getContentLength();
byte dataBytes[] = new byte[formDataLength];
int byteRead = 0;
int totalBytesRead = 0;
while (totalBytesRead < formDataLength) {
byteRead = in.read(dataBytes, totalBytesRead, formDataLength);
totalBytesRead += byteRead;
String file = new String(dataBytes);
//out.println("<br> file :"+file);
String saveFile = file.substring(file.indexOf("filename=\"") + 10);
//out.println("<br> savefile :"+saveFile);
saveFile = saveFile.substring(0, saveFile.indexOf("\n"));
//out.println("<br> now file1 :"+saveFile);
saveFile = saveFile.substring(saveFile.lastIndexOf("\\") + 1, saveFile.indexOf("\""));
//out.println("<br> now file2 :"+saveFile);
//out.print(dataBytes);
String ext = "";
if (saveFile.indexOf(".") != -1) {
ext = saveFile.substring(saveFile.lastIndexOf("."));
int lastIndex = contentType.lastIndexOf("=");
//out.println("<br>lst index of"+lastIndex);
String boundary = contentType.substring(lastIndex + 1, contentType.length());
//out.println("<br> boundary"+boundary);
//out.println("<br> file :"+file);
int pos;
pos = file.indexOf("filename=\"");
//out.println("<br> now 0 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 1 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 2 :"+pos);
pos = file.indexOf("\n", pos) + 1;
//out.println("<br>now 3"+pos);
int boundaryLocation = file.indexOf(boundary, pos) - 4;
int startPos = ((file.substring(0, pos)).getBytes()).length;
int endPos = ((file.substring(0, boundaryLocation)).getBytes()).length;
FileOutputStream fileOut = new FileOutputStream("D:\\" + saveFile);
//FileOutputStream fileOut = new FileOutputStream(saveFile);
//fileOut.write(dataBytes);
fileOut.write(dataBytes, startPos, (endPos - startPos));
fileOut.flush();
fileOut.close();
session.setAttribute("fil", saveFile);
//out.println("File saved as " +saveFile);
%>
<script type="text/javascript" >
function DisablingBackFunctionality()
var URL;
var i ;
var QryStrValue;
URL=window.location.href ;
i=URL.indexOf("?");
QryStrValue=URL.substring(i+1);
if (QryStrValue!='X')
window.location=URL + "?X";
</script>
Please let me know the result as soon as possible. Its my very urgent.
Thanking Yu,
Muthu Kumar.RNo.
Mylenium -
hi!
i'm new with dom4j and i don't have any idea on how to do the following task:
i have an xml document which i have to save as an excel file using dom4j. my problem is i also have to insert records in the middle of the file. is it possible?
sample layout:
Worksheet Header (also have to plot a value)
Column Header (also have to plot a value)
-- need to insert records here --
Sub-total row
Total row
i would appreciate any help from you guys...
thanks in advance...Hi there!
First I haven't seen any application that uses dom4j to write excel's file, but I can recommend you to use Apache's POI to write and read from any excel's file, actually I'm working rigth now with it, and works fine with Office 2003.
http://jakarta.apache.org/poi/hssf/
For the XML you can use what ever you feel confortable with, dom4j, jdom, etc. I really like jdom thougth -
Unable to display double values in Excel sheet using JExcel API
Hi
I am writing code to generate report in the form of Excel Sheet using JExcel API.
Everything is going fine but whenever I want to put some double values in a cell it is only showing 2 decimal places. My problem is "I want to show upto five decimal places".
Any kind of reply might help me lot.
Thank U.If you enable the submit zero option, it still happens? This is a new feature on the display tabl
#NumericZero Enhancements
To display a numeric zero in place of an error message, you can enter #NumericZero in any of the three Replacement text fields. When you use the #NumericZero option:
· Excel formatting for the cell is retained.
· All calculations with dependency on the cell will compute correctly and will take the value of this cell as zero.
· This numeric zero is for display only. When you submit, the zero value is NOT submitted back to the data source.
You cannot set display strings for cells that contain an invalid member or dimension name (metadata error). Metadata errors produce standard descriptive error messages.
Errors are prioritized in the following order from highest to lowest. The error message for a higher-priority error takes precedence over that for a lower-priority error.
1. (Highest) Metadata errors
2. #No access
3. #Invalid/Meaningless
4. #No data\Missing -
How can I create an csv/excel file using pl/sql and then sending that file
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.968776 wrote:
How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
Whay do you want database (pl/sql) code to do these things?
Anyhow, you may be interested in :
{message:id=9360007}
{message:id=9984244}
Maybe you are looking for
-
What are the Pros and Cons while joining tables at DF and Universe level
Hi Experts, I am new to Data federator designer. I need help on the below. Could you please let me know the Pros and Cons while joining the source tables in data federator And While joining the DF target tables in universe designer. Regards, Gana
-
HT4589 Final Cut Pro wont launch anymore
I updated to the latest version of Final Cut Pro and now it wont launch. the window comes up and all I get is a spinning colourful wheel as a cursor and no way to operate the software.
-
Vendor evaluation - Automatic new evaluation
Hi, Vendor evaluation is maintained. But it does not get updated automatically after GR. We have to update them one by one (ME61/ME63). Is there a way to automatically revaluate multiple vendors at the same time. Regards, Pratap
-
HP6940 power interupted...now prints lots of boxes across printed page
HPDeskjet 6940 I've owned 3 of these and love the printer but think I just scrambled the printer's motherboard!? i was printing a 3 page Word document when i accidentally disconnected the cord between the printer and the pc. I immediately reconnected
-
Accidently deleted the little Mac spring icon from dock, can I get it back?
I accidently moved the little springy Mac icon that lived on the right hand side of the dock, next to the trash, out of the dock, and it disappeared with a puff of smoke. I am not sure what it was or whether I needed it..I think it was a web link to