View | Details | Raw Unified | Return to bug 64595
Collapse All | Expand All

(-)a/src/ooxml/java/org/apache/poi/xssf/streaming/SheetDataWriter.java (-1 / +1 lines)
Lines 298-304 public class SheetDataWriter implements Closeable { Link Here
298
                        String value = cell.getStringCellValue();
298
                        String value = cell.getStringCellValue();
299
                        if(value != null && !value.isEmpty()) {
299
                        if(value != null && !value.isEmpty()) {
300
                            _out.write("<v>");
300
                            _out.write("<v>");
301
                            _out.write(value);
301
                            outputQuotedString(value);
302
                            _out.write("</v>");
302
                            _out.write("</v>");
303
                        }
303
                        }
304
                        break;
304
                        break;
(-)a/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestSXSSFBugs.java (+28 lines)
Lines 47-52 import org.junit.Test; Link Here
47
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
47
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCellType;
48
48
49
public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
49
public final class TestSXSSFBugs extends BaseTestBugzillaIssues {
50
50
    public TestSXSSFBugs() {
51
    public TestSXSSFBugs() {
51
        super(SXSSFITestDataProvider.instance);
52
        super(SXSSFITestDataProvider.instance);
52
    }
53
    }
Lines 238-241 public final class TestSXSSFBugs extends BaseTestBugzillaIssues { Link Here
238
            }
239
            }
239
        }
240
        }
240
    }
241
    }
242
243
    @Test
244
    public void test64595() throws Exception {
245
        try (Workbook workbook = new SXSSFWorkbook(100)) {
246
            Sheet sheet = workbook.createSheet("RawData");
247
            Row row = sheet.createRow(0);
248
            Cell cell;
249
250
            cell = row.createCell(0);
251
            cell.setCellValue("Ernie & Bert");
252
253
            cell = row.createCell(1);
254
            // Set a precalculated formula value containing a special character.
255
            cell.setCellValue("Ernie & Bert are cool!");
256
            cell.setCellFormula("A1 & \" are cool!\"");
257
258
            // While unfixed reading the workbook would throw a POIXMLException
259
            // since the file was corrupt due to missing quotation.
260
            try (Workbook wbBack = SXSSFITestDataProvider.instance.writeOutAndReadBack(workbook)) {
261
                assertNotNull(wbBack);
262
                cell = wbBack.getSheetAt(0).getRow(0).getCell(1);
263
                assertEquals("Ernie & Bert are cool!", cell.getStringCellValue());
264
                assertEquals("A1 & \" are cool!\"", cell.getCellFormula());
265
            }
266
        }
267
    }
268
241
}
269
}

Return to bug 64595