ASF Bugzilla – Attachment 35597 Details for
Bug 57423
shiftRows() produces a corrupted xlsx file
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
JUnit test class.
TestShiftBug.java (text/plain), 1.92 KB, created by
Luca
on 2017-12-10 16:51:46 UTC
(
hide
)
Description:
JUnit test class.
Filename:
MIME Type:
Creator:
Luca
Created:
2017-12-10 16:51:46 UTC
Size:
1.92 KB
patch
obsolete
>package test; > >import java.io.FileOutputStream; >import java.io.IOException; >import java.util.Arrays; >import java.util.Collection; > >import org.apache.poi.EncryptedDocumentException; >import org.apache.poi.ss.usermodel.Sheet; >import org.apache.poi.ss.usermodel.Workbook; >import org.apache.poi.xssf.usermodel.XSSFWorkbook; >import org.junit.Test; >import org.junit.runner.RunWith; >import org.junit.runners.Parameterized; > >@RunWith(Parameterized.class) >public class TestShiftBug { > > /** > * Bug: sheet.shiftRows method produces and unreadable file if third argument is in module greater than the number of rows being shifted and rows being shifted do not include last row. > * Result: testShiftResult_1_1, testShiftResult_2_1, testShiftResult_2_2 are readable, testShiftResult_1_2, testShiftResult_1_3, testShiftResult_2_3 are unreadable. > * OS: Windows 7. > * Excel: Microsoft Excel. > */ > @Test > public void testShift() { > try ( > FileOutputStream fileOut = new FileOutputStream("testShiftResult_"+rowsToShift+"_"+positionsToShift+".xlsx"); > Workbook wb = new XSSFWorkbook(); > ){ > Sheet sh = wb.createSheet(); > sh.createRow(0).createCell(0).setCellValue("a"); > sh.createRow(1).createCell(0).setCellValue("b"); > sh.createRow(2).createCell(0).setCellValue("c"); > sh.shiftRows(sh.getFirstRowNum(), sh.getFirstRowNum()+rowsToShift-1, positionsToShift); > wb.write(fileOut); > } catch (IOException | EncryptedDocumentException e) { > e.printStackTrace(); > } > } > > @Parameterized.Parameters > public static Collection<Integer[]> testShiftParameters() { > return Arrays.asList(new Integer[][] { > { 1, 1 }, > { 1, 2 }, > { 1, 3 }, > { 2, 1 }, > { 2, 2 }, > { 2, 3 } > }); > } > > private int rowsToShift; > private int positionsToShift; > > public TestShiftBug(int rowsToShift, int positionsToShift) { > this.rowsToShift = rowsToShift; > this.positionsToShift = positionsToShift; > } > > >}
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 57423
:
32353
|
32354
| 35597 |
36711
|
36712
|
36713