ASF Bugzilla – Attachment 32617 Details for
Bug 57770
cloneSheet(...) takes forever
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Java code
TestCloneSheet.java (text/plain), 1.44 KB, created by
Michael
on 2015-03-27 17:51:09 UTC
(
hide
)
Description:
Java code
Filename:
MIME Type:
Creator:
Michael
Created:
2015-03-27 17:51:09 UTC
Size:
1.44 KB
patch
obsolete
>import java.io.*; >import java.util.*; > >import org.apache.poi.xssf.usermodel.*; >import org.apache.poi.ss.usermodel.*; > >public class TestCloneSheet >{ > public static void main(String[] args) > { > TestCloneSheet test = new TestCloneSheet(); > try{ > File templateFile = new File("TestTemplate.xlsx"); > if (!templateFile.exists()) { > throw new FileNotFoundException("The template 'TestTemplate.xlsx' not found!"); > } > > XSSFWorkbook template = (XSSFWorkbook)WorkbookFactory.create(templateFile); > > File reportFile = new File("TestReport.xlsx"); > if(reportFile.exists() && !reportFile.delete()){ > throw new Exception("Failed to delete existing file TestReport.xlsx"); > } > > if(!reportFile.createNewFile()){ > throw new Exception("Failed to create new file TestReport.xlsx"); > } > > XSSFWorkbook report = test.copy(template); > > FileOutputStream fos = new FileOutputStream(reportFile); > report.write(fos); > fos.close(); > > System.out.println("Success!"); > } catch(Exception e) { > e.printStackTrace(); > } > } > > public XSSFWorkbook copy(XSSFWorkbook template) throws Exception > { > XSSFWorkbook report = new XSSFWorkbook(); > for(int i = 0; i < template.getNumberOfSheets(); i++) > { > XSSFSheet sourceSheet = template.getSheetAt(i); > XSSFSheet destSheet = report.createSheet(sourceSheet.getSheetName()); > > destSheet = template.cloneSheet(i); > } > > template.close(); > return report; > } >}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 57770
: 32617 |
32626