ASF Bugzilla – Attachment 31951 Details for
Bug 56893
Overflow in UnicodeString results in corrupted file when setCellValue() is called with a string larger than 32767
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Small JUnit test which demonstrates the problem with setCellValue(String)
HSSFSetCellValueTest.java (text/x-java), 1.18 KB, created by
Mirjan Merruko
on 2014-08-29 18:50:41 UTC
(
hide
)
Description:
Small JUnit test which demonstrates the problem with setCellValue(String)
Filename:
MIME Type:
Creator:
Mirjan Merruko
Created:
2014-08-29 18:50:41 UTC
Size:
1.18 KB
patch
obsolete
>import org.apache.poi.hssf.usermodel.HSSFWorkbook; >import org.apache.poi.ss.SpreadsheetVersion; >import org.apache.poi.ss.usermodel.Cell; >import org.apache.poi.ss.usermodel.Row; >import org.apache.poi.ss.usermodel.Sheet; >import org.apache.poi.ss.usermodel.Workbook; >import org.junit.Test; > >public class HSSFSetCellValueTest { > > @Test(expected = IllegalArgumentException.class) > public void testWillThrowExceptionAndSucceed() { > setCellValueOfLength(SpreadsheetVersion.EXCEL97.getMaxTextLength() + 1); > } > > @Test(expected = IllegalArgumentException.class) > public void testMustThrowExceptionButWillNot() { > setCellValueOfLength(3 * SpreadsheetVersion.EXCEL97.getMaxTextLength()); > } > > private void setCellValueOfLength(int i) { > Cell cell = getCleanCell(); > String value = createString(i); > cell.setCellValue(value); > } > > private Cell getCleanCell() { > Workbook workbook = new HSSFWorkbook(); > Sheet aSheet = workbook.createSheet(); > Row row = aSheet.createRow(0); > > return row.createCell(0); > } > > private String createString(int j) { > StringBuilder builder = new StringBuilder(j); > for (int i = 0; i < j; i++) > builder.append('a'); > > return builder.toString(); > } >}
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 56893
: 31951