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,
Amit
there are plenty of tutorials and docs online
this site is for technical help, general questions should be submitted to Google
Similar Messages
-
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? -
Read a excel file using swings
Does anyone know about reading an excel file using swings?
Right now, I am using com.f1j.ss.*. But looking for more examples like reading and writing a excel file.
Please suggest me with some good examples?1- Swing allows you to design a graphical user interface (to display data from a db or excel file for example)
2- [Here |http://www.rgagnon.com/javadetails/java-0516.html] several ways to read/write excel. -
How to read the excel file using webdynpro abap?
Hi,
how to read and modify excel file using webdynpro abap?
Regards,
PavaniFor reading excel file follow the steps :
1. Use a File upload UI element and bind it with xstring.
2. Now your excel will be uploaded and stored in Xstring.
3. Convert Xstring to String data using FM 'HR_KR_XSTRING_TO_STRING'.
4. Now split the string at new line so as to make an internal table .
Ex . SPLIT l_string AT cl_abap_char_utilities=>newline INTO TABLE it_table.
here it_table is type table of string.
5.now loop at the internal table and separate the content of this table separated by tab.
Ex. SPLIT wa_table AT cl_abap_char_utilities=>horizontal_tab INTO TABLE it_new.
it_new type string_table.
6. For more info , refer this thread :
Re: How to upload excel file in Webdynpro application using ABAP -
Read&write Excel file using java
Hi everybody,
I have an assignment about methods that read and write an excel file using java (Eclipse SDK), so if anyone know about that please post the solution as soon as possible.
Thanks
Sendbadhttp://onesearch.sun.com/search/onesearch/index.jsp?qt=read+write+excel&subCat=siteforumid%3Ajava31&site=dev&dftab=siteforumid%3Ajava31&chooseCat=javaall&col=developer-forums
-
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 -
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? -
Read an excel file using java code
Hi,
I want to create an excel file on the client machine based on the personal details entered on the web page. And I want to save the file on the client machine in the form of CSV. Then I want to read the contents of the spreadsheet using Java Code from the using servlets. Can I read the contents of the file directly from the client machine or do i need to save the file on the server and then read the contents of it. Please help me solve this.Hi,
I want to create an excel file on the client machine
based on the personal details entered on the web
page. And I want to save the file on the client
machine in the form of CSV. Then I want to read the
contents of the spreadsheet using Java Code from the
using servlets. Can I read the contents of the file
directly from the client machine or do i need to save
the file on the server and then read the contents of
it. Please help me solve this.As stated I am rather certain that is impossible.
Servers don't access the file systems of client machines. -
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 -
Read / Write Excel file using package dbms_util and util_files
hi,
i am beginner to this so please elaborate the answer more conciselythere's a ton of reading on this subject on google my friend.
http://www.google.co.uk/search?hl=en&source=hp&biw=954&bih=517&q=plsql+read+write+excel&btnG=Google+Search&aq=f&aqi=&aql=&oq=plsql+read+write+excel
and check the forum faq, there's a topic on excel in here:
SQL and PL/SQL FAQ
Edited by: smon on Mar 2, 2011 3:39 AM -
Can't read special characters in an excel file using JDBC
Hi! I 've a code to read an excel file using JDBC-ODBC bridge. I can read the values, but any special characters is readed wrong, just symbols. The special characters are of spanish language. This is my code:
Locale currentLocale;
currentLocale = new Locale("es", "MX");
Locale.setDefault(currentLocale);
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Excel Driver (*.xls)};DBQ=comisionesperfiles.xls");
stmnt = c.createStatement();
String query = "Select * from [Hoja1$]" ;
ResultSet rs = stmnt.executeQuery( query );
while( rs.next() ){
String valor = rs.getString(2) ;
if(valor != null && !"null".equalsIgnoreCase(valor)){
if(!comisiones.contains(valor)){
System.out.println(valor);
comisiones.add( valor );
rs.close();
stmnt.close();As you can see, I've tried to set the locale, but it didn't work.
I'm using Excel 2003, Java Version 1.4.2_07 and Windows XP Professional (in latin american spanish).
Hope someone can help me!FYI: Apache's POI can read/write Excel files in Java:
http://jakarta.apache.org/poi/index.html -
Getting an Error after reading a excel file
hi
I am reading a excel file using POI
my code is
package businessLogic;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import org.apache.poi.hssf.eventusermodel.HSSFEventFactory;
import org.apache.poi.hssf.eventusermodel.HSSFListener;
import org.apache.poi.hssf.eventusermodel.HSSFRequest;
import org.apache.poi.hssf.record.BOFRecord;
import org.apache.poi.hssf.record.BoundSheetRecord;
import org.apache.poi.hssf.record.LabelSSTRecord;
import org.apache.poi.hssf.record.NumberRecord;
import org.apache.poi.hssf.record.Record;
import org.apache.poi.hssf.record.RowRecord;
import org.apache.poi.hssf.record.SSTRecord;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
* This example shows how to use the event API for reading a file.
public class EventExample implements HSSFListener
private SSTRecord sstrec;
* This method listens for incoming records and handles them as required.
* @param record The record that was found while reading.
public void processRecord(Record record)
try
switch (record.getSid())
// the BOFRecord can represent either the beginning of a sheet or the workbook
case BOFRecord.sid:
BOFRecord bof = (BOFRecord) record;
if (bof.getType() == bof.TYPE_WORKBOOK)
System.out.println("Encountered workbook");
// assigned to the class level member
} else if (bof.getType() == bof.TYPE_WORKSHEET)
System.out.println("Encountered sheet reference");
break;
case BoundSheetRecord.sid:
BoundSheetRecord bsr = (BoundSheetRecord) record;
System.out.println("New sheet named: " + bsr.getSheetname());
break;
case RowRecord.sid:
RowRecord rowrec = (RowRecord) record;
System.out.println("Row found, first column at " + rowrec.getFirstCol() + " last column at " + rowrec.getLastCol());
break;
case NumberRecord.sid:
NumberRecord numrec = (NumberRecord) record;
System.out.println("Cell found with value " + numrec.getValue()+ " at row " + numrec.getRow() + " and column " + numrec.getColumn());
break;
// SSTRecords store a array of unique strings used in Excel.
case SSTRecord.sid:
sstrec = (SSTRecord) record;
for (int k = 0; k < sstrec.getNumUniqueStrings(); k++)
System.out.println("String table value " + k + " = " + sstrec.getString(k));
break;
case LabelSSTRecord.sid:
LabelSSTRecord lrec = (LabelSSTRecord) record;
System.out.println("String cell found with value " + sstrec.getString(lrec.getSSTIndex()));
break;
catch(Exception ex)
* Read an excel file and spit out what we find.
* @param args Expect one argument that is the file to read.
* @throws IOException When there is an error processing the file.
public static void main(String[] args) throws IOException
// create a new file input stream with the input file specified
// at the command line
try
FileInputStream fin = new FileInputStream("C:/FTERPending/FTER format.xls");
// create a new org.apache.poi.poifs.filesystem.Filesystem
POIFSFileSystem poifs = new POIFSFileSystem(fin);
// get the Workbook (excel part) stream in a InputStream
InputStream din = poifs.createDocumentInputStream("Workbook");
// construct out HSSFRequest object
HSSFRequest req = new HSSFRequest();
// lazy listen for ALL records with the listener shown above
req.addListenerForAllRecords(new EventExample());
// create our event factory
HSSFEventFactory factory = new HSSFEventFactory();
// process our events based on the document input stream
factory.processEvents(req, din);
// once all the events are processed close our file input stream
fin.close();
// and our document input stream (don't want to leak these!)
din.close();
System.out.println("done.");
catch(Exception ex)
It prints correctly the output at the console and after that it throws an exception as
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.apache.poi.hssf.record.RecordFactory.createRecord(RecordFactory.java:224)
at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.genericProcessEvents(HSSFEventFactory.java:183)
at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processEvents(HSSFEventFactory.java:101)
at businessLogic.EventExample.main(EventExample.java:103)
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:90)
at org.apache.poi.hssf.record.Record.<init>(Record.java:55)
at org.apache.poi.hssf.record.ObjRecord.<init>(ObjRecord.java:61)
... 8 more
I am not getting why this exception is cming
can anyone help me pls replyDoes your Excel file has the "AutoFilter" activated?
If that is the problem, you have here a solution for reading a file with AutoFilter : http://article.gmane.org/gmane.comp.jakarta.poi.user/4690 -
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. -
Error reading excel file using POI.
Hi ,
I am having some problem when reading the excel file.
While reading excel file I am getting error-java.io.IOException: Unable to read entire block; 4 bytes read; expected 512 bytes.
part of my code:-
InputStream stream = objFormFile.getInputStream();
POIFSFileSystem fs = new POIFSFileSystem(stream);//getting above error here.
HSSFWorkbook wb = new HSSFWorkbook(fs);
Case 1:
I download the file on the system ,save it ,and then directly upload it to the system ,I get the above error .
Case 2:
It works fine if I download the excel and manually open and save it and then upload it .
I am using JDK1.4.1 and poi-2.5.1-final-20040804.jar.
Can any one please help me out for the above problem?
Edited by: hruday on Jul 31, 2008 3:20 AMInstead of using POIFSFileSystem, try to directly create the HSSFWorkbook
InputStream stream = objFormFile.getInputStream();
//POIFSFileSystem fs = new POIFSFileSystem( stream );//getting above error here.
HSSFWorkbook wb = new HSSFWorkbook( stream ); -
Problem: this mac is not reading an excell file after upgrading to yosemite. My Mac is from 2009, it use to work perfectly but it wasn´t able to open some apps, thats why i upgrade it. Now it once i donwload the zip it appears with an ".ods" extension
i even already download a link
http://www.microsoft.com/en-us/download/confirmation.aspx?id=44026
which i read on another support page... but it doesnt allowed me to install it cause it says that i already have the disk of this program....
Im afraid to erase it and not being able to get it back...
What can i do!??
Thanks in advance for this kind answer!!!fsolution wrote:
Problem: this mac is not reading an excell file after upgrading to yosemite... Now it once i donwload the zip it appears with an ".ods" extension...
If the "it" refers to a compressed (zipped) spreadsheet that you downloaded, the ".ods" extension is used by LibreOffice and probably OpenOffice (which are free versions of MS Office) for spreadsheets, which would suggest that wherever you're getting that "Excel" file from has switched to one of those programs. I've tried opening an .ods file from LibreOffice using MS Office 2013 for Windows and it does open though with a warning that some things have been changed. I don't know if Office for Mac can normally open .ods files. But if your need is to just open .ods files, take a look at LibreOffice.
Maybe you are looking for
-
Condition value is Inactive in sales order
Hi Friends, I am facing the following problem, In the sales order, it is picking all condition records as per pricing procedure and calculates perfectly. But in the header net value field it is not updating. It is showing one condition record value
-
How do I email files from icloud drive on an iPhone?
I have few PDF files saved on icloud drive through my mac. I want to access those files on my iPhone and email them to others. How do i do that? Presently I am using google drive and it allows me to email my files from google drive on an iphone.
-
Wants to launch file thorough forms
Hi All, I am downloading the form data using Text_IO Package into CSV file. I want to display the window with the button as 'Lanch File', so that when pressed should open the file ex. consol.csv. in the MS Excel. My OS is Win XP. Also I want to calcu
-
Here is my issue: 1. I have and stateless session EJB deploy to OC4J (the preview release). 2. I have a servlet that access the the EJB using the "RMInitialContextFactory" factory. 3. When I deploy the servlet to Tomcat on a different box it works fi
-
How can I show embedded video in powerpoint on phone?
I have embedded video in my powerpoint using Office 365 on my desktop. The video plays fine on my desktop but it does not play on my phone. It simply shows the video as a picture. Does anybody know what the problem is? Thanks.