poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From one...@apache.org
Subject svn commit: r1711939 - in /poi/trunk/src/ooxml: java/org/apache/poi/xssf/usermodel/XSSFCell.java testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
Date Mon, 02 Nov 2015 10:47:19 GMT
Author: onealj
Date: Mon Nov  2 10:47:19 2015
New Revision: 1711939

URL: http://svn.apache.org/viewvc?rev=1711939&view=rev
Log:
bug58348: add test for copying formula with unregistered UDF

Modified:
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java?rev=1711939&r1=1711938&r2=1711939&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java Mon Nov  2 10:47:19
2015
@@ -121,6 +121,9 @@ public final class XSSFCell implements C
     /**
      * Copy cell value, formula, and style, from srcCell per cell copy policy
      * If srcCell is null, clears the cell value and cell style per cell copy policy
+     * 
+     * This does not shift references in formulas. Use {@link XSSFRowShifter} to shift references
in formulas.
+     * 
      * @param srcCell
      * @param policy
      * @throws IllegalArgumentException if copy cell style and srcCell is from a different
workbook

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java?rev=1711939&r1=1711938&r2=1711939&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestXSSFCell.java Mon Nov
 2 10:47:19 2015
@@ -530,6 +530,19 @@ public final class TestXSSFCell extends
     }
     
     @Test
+    public final void testCopyCellFrom_CellCopyPolicy_formulaWithUnregisteredUDF() {
+        setUp_testCopyCellFrom_CellCopyPolicy();
+        
+        srcCell.setCellFormula("MYFUNC2(123, $A5, Sheet1!$B7)");
+        
+        // Copy formula verbatim (no shifting). This is okay because copyCellFrom is Internal.
+        // Users should use higher-level copying functions to row- or column-shift formulas.
+        final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(true).build();
+        destCell.copyCellFrom(srcCell, policy);
+        assertEquals("MYFUNC2(123, $A5, Sheet1!$B7)", destCell.getCellFormula());
+    }
+    
+    @Test
     public final void testCopyCellFrom_CellCopyPolicy_style() {
         setUp_testCopyCellFrom_CellCopyPolicy();
         srcCell.setCellValue((String) null);
@@ -637,7 +650,7 @@ public final class TestXSSFCell extends
     private final void setUp_testCopyCellFrom_CellCopyPolicy() {
         @SuppressWarnings("resource")
         final XSSFWorkbook wb = new XSSFWorkbook();
-        final XSSFRow row = wb.createSheet().createRow(0);
+        final XSSFRow row = wb.createSheet("Sheet1").createRow(0);
         srcCell = row.createCell(0);
         destCell = row.createCell(1);
         



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message