Bug 57231

Summary: clone worksheet throws exception: The class org.apache.poi.hssf.record.ArrayRecord needs to define a clone method
Product: POI Reporter: Anthony <anthony.ap>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 3.10-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: All   
Attachments: workbook containing hidden MASTER sheet, that I am trying to clone.

Description Anthony 2014-11-17 19:48:48 UTC
Created attachment 32210 [details]
workbook containing hidden MASTER sheet, that I am trying to clone.

public void addNewWorksheet4() {
		
	   FileInputStream fileIn   = null;
       FileOutputStream fileOut = null;
       int idx;
       int foundIdx;
       
       try
       {    	   
           fileIn = new FileInputStream(Environment.getExternalStorageDirectory()+File.separator + "uesystems/leakmgr/MixedGasReport.xls");
           POIFSFileSystem fs = new POIFSFileSystem(fileIn);
           HSSFWorkbook wb    = new HSSFWorkbook(fs);
           HSSFSheet sheet    = null;
           
           foundIdx = locateWorkSheetByName(wb, "master");
           
       	   HSSFSheet newSheet = wb.cloneSheet(foundIdx);
		   idx = wb.getSheetIndex(newSheet);
		   wb.setSheetName(idx, "newName");
           
           // Write the output to a file
           fileOut = new FileOutputStream(Environment.getExternalStorageDirectory()+File.separator + "uesystems/leakmgr/MixedGasReport2.xls");
           wb.write(fileOut);
       } 
       catch(FileNotFoundException ex) {
    	   Log.v(TAG, "FileNotFoundException: " + ex.toString());
       }
       catch(IOException ex) {
    	   Log.v(TAG, "IOException: " + ex.toString());
       }
       catch(Exception ex) {
    	   Log.v(TAG, "Exception: " + ex.toString());
       }
       finally {
           if (fileOut != null)  {
        	   try {
                   fileOut.close();
        	   }
        	   catch(Exception ex) {
        		   
        	   }
           }
           if (fileIn != null) {
	    	   try {
	               fileIn.close();
	    	   }
	    	   catch(Exception ex) {
	    		   
	    	   }
           }
       }
       		
	}
Comment 1 Anthony 2014-11-17 19:50:35 UTC
I am not sure how to add a clone method to ArrayRecord object.
Thank you in advance for your help.
Comment 2 Dominik Stadler 2014-12-22 08:21:13 UTC
Fixed via r1647255, should be available in the next nightly build.