Bug 37584 - Create a row in a worksheet
Summary: Create a row in a worksheet
Status: RESOLVED WONTFIX
Alias: None
Product: POI
Classification: Unclassified
Component: POIFS (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-21 23:59 UTC by Monica Najar
Modified: 2005-11-28 08:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Monica Najar 2005-11-21 23:59:09 UTC
Hi! I am working with a 3.2.3 jboss server.
I have the next code:

try {
	
		fileIn = new FileInputStream("C:\\Aplicaciones\\DFSS\\081105
\\CheckList\\CheckList.xls");
		POIFSFileSystem fs = new POIFSFileSystem(fileIn);
		HSSFWorkbook wb = new HSSFWorkbook(fs);
		HSSFSheet sheet = wb.getSheetAt(0);
		HSSFRow row = null;
		HSSFCell cell = null;
		int i;
		int r;
		r = sheet.getLastRowNum() + 1;
		System.out.print(r);
		boolean ext = false;
   		for (i = 0; i < r; i++) {
    		row = sheet.getRow(i);
    		cell = row.getCell((short)0);
    		if (cell.toString().equalsIgnoreCase(fdm)) {
    			ext = true;
    		}
    	}
    	
    	try {
    		if (ext == false) {
    			short sht = new Integer(r).shortValue();
    			row = sheet.getRow(r);
            	if (row == null) {
            		row = sheet.createRow(sht);
            	}
            	cell = row.getCell((short)0);
    			cell.setCellValue(fdm);
    		}
    	} catch(Exception e) {
    		System.out.print(e.getMessage() + " Exception error");
    	} finally {
            if (fileOut != null)
                fileOut.close();
            if (fileIn != null)
                fileIn.close();
        }

	    fileOut = new FileOutputStream("C:\\Aplicaciones\\DFSS\\081105
\\CheckList\\CheckList.xls");
		wb.write(fileOut);
		fileOut.close();
		
	} finally {
		if (fileOut != null)
			fileOut.close();
		if (fileIn != null)
			fileIn.close();
	}


but in the line in where I try to create a new row... it gives me an error
     if (row == null) {
     	row = sheet.createRow(sht);
     }

I've already try with an int value and with a short value but it still gives me 
the error

exception 

org.apache.jasper.JasperException
	at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:254)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:256)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke
(JBossSecurityMgrRealm.java:220)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke
(ContainerStatsValve.java:76)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2417)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:171)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:172)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
(SecurityAssociationValve.java:65)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:577)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.coyote.tomcat4.CoyoteAdapter.service
(CoyoteAdapter.java:197)
	at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:781)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnectio
n(Http11Protocol.java:549)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:605)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:677)
	at java.lang.Thread.run(Thread.java:534)


root cause 

java.lang.NullPointerException
	at org.apache.jsp.spreadsheet_jsp._jspService(spreadsheet_jsp.java:84)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.jasper.servlet.JspServletWrapper.service
(JspServletWrapper.java:210)
	at org.apache.jasper.servlet.JspServlet.serviceJspFile
(JspServlet.java:295)
	at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:247)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:193)
	at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:256)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.jboss.web.tomcat.security.JBossSecurityMgrRealm.invoke
(JBossSecurityMgrRealm.java:220)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.valves.CertificatesValve.invoke
(CertificatesValve.java:246)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.jboss.web.tomcat.tc4.statistics.ContainerStatsValve.invoke
(ContainerStatsValve.java:76)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardContext.invoke
(StandardContext.java:2417)
	at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:180)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.valves.ErrorDispatcherValve.invoke
(ErrorDispatcherValve.java:171)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:172)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke
(SecurityAssociationValve.java:65)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.valves.AccessLogValve.invoke
(AccessLogValve.java:577)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:641)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:174)
	at 
org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex
t(StandardPipeline.java:643)
	at org.apache.catalina.core.StandardPipeline.invoke
(StandardPipeline.java:480)
	at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
	at org.apache.coyote.tomcat4.CoyoteAdapter.service
(CoyoteAdapter.java:197)
	at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:781)
	at 
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnectio
n(Http11Protocol.java:549)
	at org.apache.tomcat.util.net.TcpWorkerThread.runIt
(PoolTcpEndpoint.java:605)
	at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run
(ThreadPool.java:677)
	at java.lang.Thread.run(Thread.java:534)
Comment 1 Ruediger Pluem 2005-11-22 21:47:29 UTC
Wrong project. I assume you want help for POI.
Comment 2 Andy Oliver 2005-11-23 15:43:05 UTC
inappropriate way to ask a question
Comment 3 Monica Najar 2005-11-23 15:50:12 UTC
I would like to know how can I fixed this error.
Or you mean this is not the place to ask for this?(In reply to comment #2)
> inappropriate way to ask a question




Comment 4 Andy Oliver 2005-11-23 16:11:09 UTC
mail list.  Its a bug in your code, not poi.
Comment 5 Monica Najar 2005-11-23 16:57:04 UTC
And could you tell me where is the bug? Is because I have been checking my code 
and looking for examples in the web and it seems to be right... I need some help
(In reply to comment #4)
> mail list.  Its a bug in your code, not poi.

Comment 6 Monica Najar 2005-11-24 16:48:10 UTC
I need to install Ant and Forrest so POI can work correctly?
(In reply to comment #4)
> mail list.  Its a bug in your code, not poi.

Comment 7 Andy Oliver 2005-11-28 17:05:45 UTC
I will not answer any questions in the bugzilla.  You must ask on the mailing
list.