ASF Bugzilla – Attachment 35132 Details for
Bug 61297
got this message: this error should NEVER happen while trying to copy rows in Excel
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
got this message: this error should NEVER happen!
ModelBackTest_excel.java (text/x-csrc), 2.40 KB, created by
Ted Ji
on 2017-07-13 21:50:06 UTC
(
hide
)
Description:
got this message: this error should NEVER happen!
Filename:
MIME Type:
Creator:
Ted Ji
Created:
2017-07-13 21:50:06 UTC
Size:
2.40 KB
patch
obsolete
>/* > * To change this license header, choose License Headers in Project Properties. > * To change this template file, choose Tools | Templates > * and open the template in the editor. > */ >package modelbacktest_excel; > >import java.io.File; >import java.io.FileOutputStream; >import java.io.IOException; >import org.apache.poi.openxml4j.exceptions.InvalidFormatException; >import org.apache.poi.openxml4j.opc.OPCPackage; >import org.apache.poi.ss.usermodel.CellCopyPolicy; >import org.apache.poi.ss.usermodel.Row; >import org.apache.poi.xssf.usermodel.XSSFSheet; >import org.apache.poi.xssf.usermodel.XSSFWorkbook; > >/** > * > * @author a140727 > */ >public class ModelBackTest_excel { > > /** > * @param args the command line arguments > */ > public static void main(String[] args) { > // TODO code application logic here > System.out.println("start test"); > try { > OPCPackage pkg = OPCPackage.open(new File("C:/Users/A140727/Desktop/Temp/Backtesting_template.xlsx")); > XSSFWorkbook wb = new XSSFWorkbook(pkg); > System.out.println("number of sheets=" + wb.getNumberOfSheets()); > for (int i=0; i < wb.getNumberOfSheets(); i++) { > System.out.println("sheet=" + wb.getSheetName(i)); > } > XSSFSheet xsheet = wb.getSheet("template_4_8_16"); > System.out.println("row= " + xsheet.getFirstRowNum() + " " + xsheet.getLastRowNum()); > > // copy and duplicate row > int start_row1 = 3; > int end_row1 = 23; > int start_row2 = 26; > for (int i=start_row1; i<=end_row1; i++) { > int i_new = i + end_row1 - start_row1 + 3; > Row row = xsheet.getRow(i); > if (row==null) System.out.println("row " + i + " is null" + " new= " + i_new); > else System.out.println("row=" + i + " no. cells=" + row.getLastCellNum() + " new= " + i_new); > //copy rows > System.out.println("... copy rows"); > xsheet.copyRows(5, 6, 26, new CellCopyPolicy()); > FileOutputStream out = new FileOutputStream(new File("C:/Users/A140727/Desktop/Temp/Backtesting_template_out.xlsx")); > wb.write(out); > out.close(); > pkg.close(); > } > > pkg.close(); > } catch (IOException e) {} > catch (InvalidFormatException e) {} > System.out.println("done"); > } > >}
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 61297
: 35132 |
35133