You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2011/06/03 21:49:04 UTC

DO NOT REPLY [Bug 51321] New: XSSFCell.setCellValue should not strip off ending spaces

https://issues.apache.org/bugzilla/show_bug.cgi?id=51321

             Bug #: 51321
           Summary: XSSFCell.setCellValue should not strip off ending
                    spaces
           Product: POI
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: critical
          Priority: P2
         Component: XSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: jxz164@hotmail.com
    Classification: Unclassified


Created attachment 27106
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=27106
java code to reproduce the setCellValue bug in XSSFCell.java

I am creating a xlsx file with only two cells. One cell is created with value
"ABC " and the other cell is created with value "ABC      ". Please note that
the second cell differs from the first cell only with more ending spaces.
However, in the generated xlsx file, both cells are populated with value "ABC
". 

I believe the setCellValue method in XSSFCell.java has a bug. Perhaps it was
using a pre-evaluated result string incorrectly in this case.

Please see the attached code to reproduce this problem.

package org.apache.poi.ss.examples;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.*;

import java.io.FileOutputStream;

public class XSSFSetValueBug {

    public static void main(String[] args) throws Exception {
        Workbook wb = new XSSFWorkbook();  //or new HSSFWorkbook();
        Sheet sheet = wb.createSheet("sheet1");

        CreationHelper createHelper = wb.getCreationHelper();
        Cell cell0 = sheet.createRow(0).createCell(0);
        cell0.setCellValue(createHelper.createRichTextString("ABC "));

        Cell cell1 = sheet.createRow(1).createCell(0);
        cell1.setCellValue(createHelper.createRichTextString("ABC      "));

        // Write the output to a file
        FileOutputStream fileOut = new
FileOutputStream("C:\\workspace\\TestXSSFSetValueBug.xlsx");
        wb.write(fileOut);
        fileOut.close();
    }
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 51321] XSSFCell.setCellValue should not strip off ending spaces

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51321

--- Comment #3 from jxz164@hotmail.com 2011-06-07 14:29:41 UTC ---
OK. I have confirmed that this is fixed in the newly released poi-3.8-beta3.

Thanks!

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 51321] XSSFCell.setCellValue should not strip off ending spaces

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51321

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO

--- Comment #2 from Nick Burch <ni...@alfresco.com> 2011-06-03 19:54:02 UTC ---
There's code in XSSFRichTextString (which XSSFCell uses) to handle leading and
trailing spaces, which ought to be kicking in to solve this issue

Can you try with a recent nightly build / svn checkout and see if you still
have the problem?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 51321] XSSFCell.setCellValue should not strip off ending spaces

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51321

--- Comment #1 from jxz164@hotmail.com 2011-06-03 19:50:57 UTC ---
Both cells are populated with "ABC " to be more clear.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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


DO NOT REPLY [Bug 51321] XSSFCell.setCellValue should not strip off ending spaces

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=51321

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |RESOLVED
         Resolution|                            |FIXED

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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