Revert changes from rev. 1513916 as it severly broke writing valid xlsx files

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1515842 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2013-08-20 15:03:18 +00:00
parent 72d3a7d2a3
commit 4a675204cb
2 changed files with 9 additions and 7 deletions

View File

@ -2689,14 +2689,15 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
} }
protected void write(OutputStream out) throws IOException { protected void write(OutputStream out) throws IOException {
if(worksheet.sizeOfColsArray() == 1) { if(worksheet.sizeOfColsArray() == 1) {
CTCols col = worksheet.getColsArray(0); CTCols col = worksheet.getColsArray(0);
if(col.sizeOfColArray() != 0) { if(col.sizeOfColArray() == 0) {
// this is necessary so that we do not write an empty <cols/> item into the sheet-xml in the xlsx-file
// Excel complains about a corrupted file if this shows up there!
worksheet.setColsArray(null);
} else {
setColWidthAttribute(col); setColWidthAttribute(col);
} /*else { }
remove, see Bug 52233: worksheet.setColsArray(null);
}*/
} }
// Now re-generate our CTHyperlinks, if needed // Now re-generate our CTHyperlinks, if needed

View File

@ -462,7 +462,8 @@ public final class TestXSSFWorkbook extends BaseTestWorkbook {
sh.getCTWorksheet().getSheetPr().getTabColor().getIndexed()); sh.getCTWorksheet().getSheetPr().getTabColor().getIndexed());
} }
public void testColumnWidthPOI52233() throws Exception { // TODO: disabled as the fix for this had severe side-effects
public void doNotRuntestColumnWidthPOI52233() throws Exception {
XSSFWorkbook workbook = new XSSFWorkbook(); XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet(); XSSFSheet sheet = workbook.createSheet();
XSSFRow row = sheet.createRow(0); XSSFRow row = sheet.createRow(0);