You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ram Kumar <ra...@gmail.com> on 2014/05/01 14:21:09 UTC

Exception

This is my first question in this forum, as I am pretty new to this forum.

I have been using Apache POI package for more than 3 years now but I havent
used it for generating a huge excel reports. We were just generating the
reports in hundreds before.

Currently I am trying to generate a huge report of approx 70000 row, but
I am getting the below error.

Invalid row number (-32768) outside allowable range (0..1048575)
java.lang.IllegalArgumentException: Invalid row number (-32768) outside
allowable range (0..1048575)
	at org.apache.poi.xssf.usermodel.XSSFRow.setRowNum(XSSFRow.java:323)
	at org.apache.poi.xssf.usermodel.XSSFSheet.createRow(XSSFSheet.java:412)

how to solve it kindly help me.



--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Exception-tp5715552.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Exception

Posted by Nick Burch <ap...@gagravarr.org>.
On Thu, 1 May 2014, Ram Kumar wrote:
> Invalid row number (-32768) outside allowable range (0..1048575)
> java.lang.IllegalArgumentException: Invalid row number (-32768) outside
> allowable range (0..1048575)
> 	at org.apache.poi.xssf.usermodel.XSSFRow.setRowNum(XSSFRow.java:323)
> 	at org.apache.poi.xssf.usermodel.XSSFSheet.createRow(XSSFSheet.java:412)

Without code it's hard to be sure, but my hunch is that you're passing in 
a short to createRow. Make sure you use an int!

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Exception

Posted by Gmail <ca...@gmail.com>.
Hi

It says your row number is negative. You may check whether you assigned an negative number to the variable, or the row number exceeds the max number the type(int?) can hold.


> On May 1, 2014, at 7:21, Ram Kumar <ra...@gmail.com> wrote:
> 
> This is my first question in this forum, as I am pretty new to this forum.
> 
> I have been using Apache POI package for more than 3 years now but I havent
> used it for generating a huge excel reports. We were just generating the
> reports in hundreds before.
> 
> Currently I am trying to generate a huge report of approx 70000 row, but
> I am getting the below error.
> 
> Invalid row number (-32768) outside allowable range (0..1048575)
> java.lang.IllegalArgumentException: Invalid row number (-32768) outside
> allowable range (0..1048575)
>    at org.apache.poi.xssf.usermodel.XSSFRow.setRowNum(XSSFRow.java:323)
>    at org.apache.poi.xssf.usermodel.XSSFSheet.createRow(XSSFSheet.java:412)
> 
> how to solve it kindly help me.
> 
> 
> 
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/Exception-tp5715552.html
> Sent from the POI - User mailing list archive at Nabble.com.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Exception

Posted by Ram Kumar <ra...@gmail.com>.
I am posting my method that I am using to write data in excel sheet.


public void createMonthExcelSheet(String stt[]){
        try{
            
                String str="";
                for(int p=0;p<stt.length;p++){
                    str+=stt[p];
                }
            String path=System.getProperty("user.dir");
            //String path="D:";
            //ByteArrayOutputStream outputStream = new
ByteArrayOutputStream();
            //String destinationFilePath = ""+path+"\\Report.xlsx";
            log.info("Preparing excel sheet.");
            //FileOutputStream fout = new
FileOutputStream(destinationFilePath);
            FileOutputStream fout = new
FileOutputStream(path+"\\Report.xlsx");
            //HSSFWorkbook workBook=new HSSFWorkbook();
            //Workbook workBook = new XSSFWorkbook();
            XSSFWorkbook workBook = new XSSFWorkbook();
            XSSFSheet spreadSheet=null;
            //Sheet spreadSheet=null;
            String m[]=str.split("::");
            
            for(int i=1;i<stt.length;i++){
                
               //int rem=i%3;
               //int div=i/3;
               String success="Sucess";
               String failed="Failed";
        
               String Main_Sheet="";
               if((i%2)==0){
                   Main_Sheet=success;
               }
               else{
                   Main_Sheet=failed;
               }
               
                
                spreadSheet = workBook.createSheet(Main_Sheet);
                int maxRow=SpreadsheetVersion.EXCEL2007.getLastRowIndex();
                System.out.println("no of row : "+maxRow);
                //Row row=spreadSheet.createRow((short)0);
                XSSFRow row=spreadSheet.createRow((short)0);
                //Cell cell;
                row.createCell(0).setCellValue("Call Date");
                row.createCell(1).setCellValue("Start Time");
                row.createCell(2).setCellValue("End Time");
                row.createCell(3).setCellValue("Account");
                row.createCell(4).setCellValue("Mobile");
                row.createCell(5).setCellValue("Duration");
                row.createCell(6).setCellValue("Call Status");
                row.createCell(7).setCellValue("Pulse");
                /*cell = row.createCell(0);
                cell.setCellValue("Call Date");
                
                cell = row.createCell(1);
                cell.setCellValue("Start Time");
            
                cell=row.createCell(2);
                cell.setCellValue("End Time");
            
                cell=row.createCell(3);
                cell.setCellValue("Account");
            
                cell=row.createCell(4);
                cell.setCellValue("Mobile");
            
                cell=row.createCell(5);
                cell.setCellValue("Duration");
            
                cell=row.createCell(6);
                cell.setCellValue("Call Status");
                
                cell=row.createCell(7);
                cell.setCellValue("Pulse");
                */
                
                String s[]=stt[i].split(";;");
                int n=0;
                for(int j=0;j<s.length;j++){
                    n++;
                    //Row row2 = spreadSheet.createRow((short)n);
                    XSSFRow row2 = spreadSheet.createRow((short)n);
                    String t[]=s[j].split("%%");
                    for(int k=0;k<t.length;k++){
                         row2.createCell(k).setCellValue(t[k]);
                       
//spreadSheet.createRow((short)n).createCell(k).setCellValue(t[k]);
                    }
                }
                }
            workBook.write(fout);
            //workBook.write(outputStream);
            //outputStream.writeTo(fout);
            //outputStream.close();
            fout.close();
            log.info("Excel sheet has prepared.");
        }
        catch(Exception e){
            log.error("Error : "+e.getMessage());
            e.printStackTrace();
        }
    }




--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Exception-tp5715552p5715560.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: Exception

Posted by David Kerber <rh...@gmail.com>.
Can you post some of your code that is generating the rows?  At first 
glance it looks like you're using too small of a variable type (not 
enough bits).


On 5/1/2014 8:21 AM, Ram Kumar wrote:
> This is my first question in this forum, as I am pretty new to this forum.
>
> I have been using Apache POI package for more than 3 years now but I havent
> used it for generating a huge excel reports. We were just generating the
> reports in hundreds before.
>
> Currently I am trying to generate a huge report of approx 70000 row, but
> I am getting the below error.
>
> Invalid row number (-32768) outside allowable range (0..1048575)
> java.lang.IllegalArgumentException: Invalid row number (-32768) outside
> allowable range (0..1048575)
> 	at org.apache.poi.xssf.usermodel.XSSFRow.setRowNum(XSSFRow.java:323)
> 	at org.apache.poi.xssf.usermodel.XSSFSheet.createRow(XSSFSheet.java:412)
>
> how to solve it kindly help me.
>
>
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/Exception-tp5715552.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org