]> source.dussan.org Git - poi.git/commitdiff
fixed bug #46715 - Column width from original xlsx file is discarded
authorYegor Kozlov <yegor@apache.org>
Wed, 25 Feb 2009 19:12:53 +0000 (19:12 +0000)
committerYegor Kozlov <yegor@apache.org>
Wed, 25 Feb 2009 19:12:53 +0000 (19:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@747895 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRow.java
src/ooxml/java/org/apache/poi/xssf/usermodel/helpers/ColumnHelper.java

index c461c0c5bb05263531b195969aeafd5f302d7b28..7e6538a4351103ef9eec66210bf6d784f00f3fdb 100644 (file)
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46719 - fixed XSSFSheet.shiftRows to correctly preserve row heights</action>
+           <action dev="POI-DEVELOPERS" type="fix">46715 - preserve custom column widths across re-serialization of XSSFWorkbook</action>
            <action dev="POI-DEVELOPERS" type="add">46703 - added setDisplayZeros / isDisplayZeros to common interface org.apache.poi.ss.usermodel.Sheet</action>
            <action dev="POI-DEVELOPERS" type="add">46708 - added getMergedRegion(int) to common interface org.apache.poi.ss.usermodel.Sheet</action>
            <action dev="POI-DEVELOPERS" type="fix">fixed Sheet.autoSizeColumn() to use cached formula values when processing formula cells </action>
            <action dev="POI-DEVELOPERS" type="fix">Fixed formula parser to handle names with backslashes</action>
            <action dev="POI-DEVELOPERS" type="add">46660 - added Workbook getHidden() and setHidden(boolean)</action>
-           <action dev="POI-DEVELOPERS" type="fix">46693 - Fixed bugs serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
+           <action dev="POI-DEVELOPERS" type="fix">46693 - Fixed serialization bugs in records: CHARTFORMAT, SHTPROPS, SXVD and SXVDEX</action>
            <action dev="POI-DEVELOPERS" type="fix">46627 - Fixed offset of added images if Pictures stream contains pictures with zero length</action>
         </release>
         <release version="3.5-beta5" date="2009-02-19">
index b85e04df0caf7b48f494e129da272496bfd22261..f47785ddfd3f9e2c4fe725dee56ee617f91703f3 100644 (file)
@@ -34,6 +34,8 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.5-beta6" date="2009-??-??">
+           <action dev="POI-DEVELOPERS" type="fix">46719 - fixed XSSFSheet.shiftRows to correctly preserve row heights</action>
+           <action dev="POI-DEVELOPERS" type="fix">46715 - preserve custom column widths across re-serialization of XSSFWorkbook</action>
            <action dev="POI-DEVELOPERS" type="add">46703 - added setDisplayZeros / isDisplayZeros to common interface org.apache.poi.ss.usermodel.Sheet</action>
            <action dev="POI-DEVELOPERS" type="add">46708 - added getMergedRegion(int) to common interface org.apache.poi.ss.usermodel.Sheet</action>
            <action dev="POI-DEVELOPERS" type="fix">fixed Sheet.autoSizeColumn() to use cached formula values when processing formula cells </action>
index 7c8ff976a1ab437f48deba435a2ca0afb9ccedc0..0b55e52b7c476fdb2ad3b7e24c2443705273ad65 100644 (file)
@@ -425,54 +425,4 @@ public class XSSFRow implements Row, Comparable<XSSFRow> {
         }
         setRowNum(rownum);
     }
-
-    protected void updateFormulasAfterCellShift(FormulaShifter shifter) {
-        for(Cell c : this){
-            XSSFCell cell = (XSSFCell)c;
-
-            CTCell ctCell = cell.getCTCell();
-            if(ctCell.isSetF()){
-                CTCellFormula f = ctCell.getF();
-                String formula = f.getStringValue();
-                if(formula.length() > 0) {
-                    String shiftedFormula = shiftFormula(formula, shifter);
-                    if (shiftedFormula != null) {
-                        f.setStringValue(shiftedFormula);
-                    }
-                }
-
-                if(f.isSetRef()){ //Range of cells which the formula applies to.
-                    String ref = f.getRef();
-                    String shiftedRef = shiftFormula(ref, shifter);
-                    if(shiftedRef != null) f.setRef(shiftedRef);
-                }
-            }
-
-        }
-    }
-
-    /**
-     * Shift a formula by the specified number of rows
-     * <p>
-     * Example: shiftFormula("A1+B1+C1", 3) will return "A4+B4+C4"
-     * </p>
-     *
-     * @param formula the formula to shift
-     * @param shifter the FormulaShifter object that operates on the parsed formula tokens
-     * @return the shifted formula if the formula was changed,
-     *   <code>null</code> if the formula wasn't modified
-     */
-    private String shiftFormula(String formula, FormulaShifter shifter){
-        XSSFSheet sheet = getSheet();
-        XSSFWorkbook wb = sheet.getWorkbook();
-        int sheetIndex = wb.getSheetIndex(sheet);
-        XSSFEvaluationWorkbook fpb = XSSFEvaluationWorkbook.create(wb);
-        Ptg[] ptgs = FormulaParser.parse(formula, fpb, FormulaType.CELL, sheetIndex);
-        String shiftedFmla = null;
-        if (shifter.adjustFormula(ptgs, sheetIndex)) {
-            shiftedFmla = FormulaRenderer.toFormulaString(fpb, ptgs);
-        }
-        return shiftedFmla;
-    }
-
 }
index 30da5efd426f78ec6b44e99f58fde8a21c6edf30..d4e4456c613a0e5012cf3a6bb4f0368f1b48128e 100644 (file)
@@ -219,13 +219,14 @@ public class ColumnHelper {
     }
 
     public void setColumnAttributes(CTCol fromCol, CTCol toCol) {
-       toCol.setWidth(fromCol.getWidth());
-       toCol.setHidden(fromCol.getHidden());
-       toCol.setBestFit(fromCol.getBestFit());
-        toCol.setStyle(fromCol.getStyle());
-        if(fromCol.getOutlineLevel()!=0){
-               toCol.setOutlineLevel(fromCol.getOutlineLevel());
-        }
+       if(fromCol.isSetBestFit()) toCol.setBestFit(fromCol.getBestFit());
+        if(fromCol.isSetCustomWidth()) toCol.setCustomWidth(fromCol.getCustomWidth());
+        if(fromCol.isSetHidden()) toCol.setHidden(fromCol.getHidden());
+        if(fromCol.isSetStyle()) toCol.setStyle(fromCol.getStyle());
+        if(fromCol.isSetWidth()) toCol.setWidth(fromCol.getWidth());
+        if(fromCol.isSetCollapsed()) toCol.setCollapsed(fromCol.getCollapsed());
+        if(fromCol.isSetPhonetic()) toCol.setPhonetic(fromCol.getPhonetic());
+        if(fromCol.isSetOutlineLevel()) toCol.setOutlineLevel(fromCol.getOutlineLevel());
     }
 
     public void setColBestFit(long index, boolean bestFit) {