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: | HSSF | Assignee: | 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. |
I am not sure how to add a clone method to ArrayRecord object. Thank you in advance for your help. |
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) { } } } }