Josh Micich wrote:
>
> Please provide a stack trace of the buffer overrun exception. This
> might be enough to help us find the bug but usually more information
> is required.
>
> It is most helpful to also provide the sample XLS file that causes
> your problem. If there are confidentiality issues, you might be able
> to sanitise the data (change/delete private info) while making sure
> that the problem is still reproducible. If you fail to achieve a
> fully sanitised workbook, you will at least have learned which
> modifications cause the problem to go away.
>
> Some other details that might be critical are the exact modifications
> you made to the workbook via POI before calling wb.write() (i.e. send
> some simple java code that reproduces the problem). You should also
> experiment with reducing the sample code to the bare minimum that
> still reproduces the bug.
>
> The best place to put all this information is in a new bugzilla entry.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>
>
Hello
the stacktrace:
Exception in thread "main" java.lang.RuntimeException: Buffer overrun
at
org.apache.poi.util.LittleEndianByteArrayOutputStream.checkPosition(LittleEndianByteArrayOutputStream.java:51)
at
org.apache.poi.util.LittleEndianByteArrayOutputStream.write(LittleEndianByteArrayOutputStream.java:88)
at
org.apache.poi.util.StringUtil.putCompressedUnicode(StringUtil.java:240)
at
org.apache.poi.util.StringUtil.writeUnicodeString(StringUtil.java:180)
at
org.apache.poi.hssf.record.LbsDataSubRecord.serialize(LbsDataSubRecord.java:223)
at org.apache.poi.hssf.record.ObjRecord.serialize(ObjRecord.java:185)
at
org.apache.poi.hssf.usermodel.HSSFWorkbook$SheetRecordCollector.serialize(HSSFWorkbook.java:1209)
at
org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1258)
at
org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1158)
code for reading the workbook:
InputStream inp = new FileInputStream(filename);
Workbook wb = WorkbookFactory.create(inp);
Sheet s = wb.getSheetAt(0);
changing the first sheet:
for (int i=0;i<Headers.length-1;i++)
{ if (Correlation[i]<0) continue;
if (i==2) //noinspection StringContatenationInLoop
Contents[2] = Contents[1]+"; "+Contents[2];
Row r = Excelsheet.getRow(Correlation[i]-1);
Cell c = r.getCell(3);
int type = c.getCellType();
if (type==Cell.CELL_TYPE_STRING) c.setCellValue(Contents[i]);
if (type==Cell.CELL_TYPE_NUMERIC)
c.setCellValue(Double.parseDouble(
Contents[i].replace(",",".")));
}
saving again:
if(wb instanceof XSSFWorkbook) {
filename = new
StringBuilder().append(filename).append("x").toString();
}
FileOutputStream out = new FileOutputStream(filename);
wb.write(out); // Runtime exception (buffer overrun)
out.close();
I changed the workbook so that only the first sheet remained, but the
problem persisted.
kind regards
Olli
--
View this message in context:
http://old.nabble.com/buffer-overrun-with-certain-xls-file-tp27637833p27652999.html
Sent from the POI - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]