<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Reading Excel file using POI API in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819292#M1490708</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use "componentRequest.getPublicResourcePath()"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thread is closed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 May 2008 15:34:43 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-05-30T15:34:43Z</dc:date>
    <item>
      <title>Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaq-p/3819286</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have gone through SDN and am following this weblog to read an Excel file using POI api. I am using JSPDynpage.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1405" target="test_blank"&gt;https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1405&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I basically want to read the contents of an excel file and pass them to a function module. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Following is my code :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;


public void readfile(){
System.err.println("readfile called");
try{
System.err.println("inside try");
InputStream fs = new FileInputStream("c:/GL/Book3.xls");
//POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Book3.xls"));
System.err.println("created filesystem");

HSSFWorkbook wb = new HSSFWorkbook(fs);
System.err.println("created workbook");

HSSFSheet sheet = wb.getSheetAt(0);
System.err.println("picked up sheet");

for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) {
HSSFRow row = (HSSFRow)rit.next();
System.err.println("first FOR printing row :- " + row);
for (Iterator cit = row.cellIterator(); cit.hasNext(); ) {
HSSFCell cell = (HSSFCell)cit.next();
System.err.println("second FOR printing cell :- " + cell.getStringCellValue()+"\t"); 
}
}

}catch(Exception e){
                             System.out.print("Exception Occured " + e.toString()); 
                          }

}


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The problem that im facing with the above code is that It prints till the line : System.err.println("inside try"); and after that there is no output.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 23 May 2008 19:50:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaq-p/3819286</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-23T19:50:53Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819287#M1490703</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think the problem seems to be here :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
InputStream fs = new FileInputStream("c:/GL/Book3.xls");
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have attached the excel sheet in my project folder which is below the "dist" folder. It is like this MyProject-&amp;gt;Book3.xls&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any Ideas on how I can pass this excel sheet from the above project folder to &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
InputStream fs = new FileInputStream(".....xls");
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: S.B on May 27, 2008 4:07 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 14:07:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819287#M1490703</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T14:07:02Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819288#M1490704</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; Hi All,&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I have gone through SDN and am following this weblog to read an Excel file using POI api. I am using JSPDynpage.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;A href="https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1405" target="test_blank"&gt;https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/1405&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; I basically want to read the contents of an excel file and pass them to a function module. &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Following is my code :&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;/CODE&gt;&lt;PRE&gt;&lt;CODE&gt;&lt;CODE&gt;
&amp;gt; 

&amp;gt; InputStream fs = new FileInputStream("c:/GL/Book3.xls");
&amp;gt; 
&amp;gt; &lt;/CODE&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; The problem that im facing with the above code is that It prints till the line : System.err.println("inside try"); and after that there is no output.&lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; &lt;/P&gt;&lt;P&gt;&amp;gt; Any suggestions ?&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Put the excel file in the folder :  /dist/PORTAL-INF/folder_name/&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;Now  use componentRequest.getWebresourcePath()+"folder_name/file_name" to access the file. component request is a  readily available variable in jsp and if you need it in javadynpage componentRequest = (IPortalComponentRequest) this.getRequest(); should work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;InputStream fs = new FileInputStream(componentRequest.getWebresourcePath()+"folder_name/file_name");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Placing the excel file in KM or on portal FS and reading from it another way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 15:52:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819288#M1490704</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T15:52:10Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819289#M1490705</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Bobby,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my code and it still doesnt read beyond - System.err.println("inside try");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
public void readfile(){
		System.err.println("america called");
	            try{
				System.err.println("inside try");
				IPortalComponentRequest componentRequest = (IPortalComponentRequest) this.getRequest();
				
				InputStream fs = new FileInputStream(componentRequest.getWebResourcePath()+"resources/Book3.xls");

			//POIFSFileSystem fs = new POIFSFileSystem(new FileInputStream("Book3.xls"));
				System.err.println("created filesystem");
				
				HSSFWorkbook wb = new HSSFWorkbook(fs);
				System.err.println("created workbook");
				
				HSSFSheet sheet = wb.getSheetAt(0);
				System.err.println("picked up sheet");
				
				for (Iterator rit = sheet.rowIterator(); rit.hasNext(); ) {
						HSSFRow row = (HSSFRow)rit.next();
						System.err.println("first FOR printing row Avaya1:- " + row);
						for (Iterator cit = row.cellIterator(); cit.hasNext(); ) {
							HSSFCell cell = (HSSFCell)cit.next();
							System.err.println("second FOR printing cell Avaya2:- " + cell.getStringCellValue()+"\t");
					
						}
					}

				
				
				
				
				
	            }catch(Exception e){
	System.out.print("Exception Occured " + e.toString()); 	
	            }

}


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should print me the contents of the Excel file in the log with system.err.println.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: S.B on May 27, 2008 7:26 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 17:25:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819289#M1490705</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T17:25:22Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819290#M1490706</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is the error log in the log file when It tries to read the excel file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

at com.sap.engine.services.httpserver.server.io.HttpInputStream.read(HttpInputStream.java:192)
	at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
	at java.io.BufferedInputStream.read1(BufferedInputStream.java:222)
	at java.io.BufferedInputStream.read(BufferedInputStream.java:277)
	at com.sapportals.portal.prt.util.http.MultiPartParser$PartInputStream.read(MultiPartParser.java:132)
	at java.io.InputStream.read(InputStream.java:89)
	at com.sapportals.portal.prt.util.http.FilePart.&amp;lt;init&amp;gt;(FilePart.java:38)
	at com.sapportals.portal.prt.util.http.MultiPartParser.parseParts(MultiPartParser.java:534)
	at com.sapportals.portal.prt.util.http.MultiPartParser.getFileParts(MultiPartParser.java:477)
	at com.sap.ip.portal.prt.service.facilities.UploadHandler.getFilePart(UploadHandler.java:106)
	at com.sap.ip.portal.admin.portalanywhere.ArchiveUploader.doUpload(ArchiveUploader.java:60)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:324)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.handleRequestEvent(AbstractPortalComponent.java:706)
	at com.sapportals.portal.prt.component.AbstractPortalComponent.handleEvent(AbstractPortalComponent.java:412)
	at com.sapportals.portal.prt.pom.ComponentNode.handleEvent(ComponentNode.java:252)
	at com.sapportals.portal.prt.pom.PortalNode.fireEventOnNode(PortalNode.java:368)
	at com.sapportals.portal.prt.core.PortalRequestManager.runRequestCycle(PortalRequestManager.java:707)
	at com.sapportals.portal.prt.connection.ServletConnection.handleRequest(ServletConnection.java:240)
	at com.sapportals.portal.prt.dispatcher.Dispatcher$doService.run(Dispatcher.java:524)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sapportals.portal.prt.dispatcher.Dispatcher.service(Dispatcher.java:407)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.sap.engine.services.servlets_jsp.server.servlet.InvokerServlet.service(InvokerServlet.java:156)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:401)
	at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:266)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:386)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:364)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:1039)
	at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:265)
	at com.sap.engine.services.httpserver.server.Client.handle(Client.java:95)
	at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:175)
	at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
	at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
	at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
	at java.security.AccessController.doPrivileged(Native Method)
	at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:102)
	at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:172)


&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any clues?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 18:59:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819290#M1490706</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T18:59:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819291#M1490707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have created a new folder directly under "dist". The folder is called "resources". This folder contains my excel file.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now when I run the following code, &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

IPortalComponentRequest componentRequest = (IPortalComponentRequest) this.getRequest();
String FileURL = componentRequest.getWebResourcePath() + "/resources/Book3.xls";
InputStream fs = new FileInputStream(FileURL);
System.err.println("created filesystem");
HSSFWorkbook wb = new HSSFWorkbook(fs);				

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It throws the exception : &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
FileNotFoundException Occured java.io.FileNotFoundException: /irj/portalapps/NewJcoTest/resources/Book3.xls (No such file or directory)this.name in bean
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;but when I pick the same path (http://portalserver:54000//irj/portalapps/NewJcoTest/resources/Book3.xls) and put it in a new browser window, it opens the excel sheet in the brouser.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any Ideas ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 27 May 2008 20:19:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819291#M1490707</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-27T20:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819292#M1490708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Use "componentRequest.getPublicResourcePath()"&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thread is closed.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 May 2008 15:34:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819292#M1490708</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-05-30T15:34:43Z</dc:date>
    </item>
    <item>
      <title>Re: Reading Excel file using POI API</title>
      <link>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819293#M1490709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IPortalComponentRequest componentRequest = (IPortalComponentRequest) this.getRequest();&lt;/P&gt;&lt;P&gt;String FileURL = componentRequest.getPublicResourcePath()+ "/resources/EmployeeDetails.xls";&lt;/P&gt;&lt;P&gt;InputStream fs = new FileInputStream(FileURL);&lt;/P&gt;&lt;P&gt;HSSFWorkbook wb = new HSSFWorkbook(fs);&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to read the excel file. only first three lines are excueted. cannot able to create the workbook .can u tell how u achieved this. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Shanthakumar&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 18 Nov 2008 15:03:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/reading-excel-file-using-poi-api/qaa-p/3819293#M1490709</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-11-18T15:03:09Z</dc:date>
    </item>
  </channel>
</rss>

