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 2021/10/06 20:49:34 UTC

[Bug 65619] New: with POI upgrade to 5.0.0, we see that it formats dates with extra slash

https://bz.apache.org/bugzilla/show_bug.cgi?id=65619

            Bug ID: 65619
           Summary: with POI upgrade to 5.0.0, we see that it formats
                    dates with extra slash
           Product: POI
           Version: 5.0.0-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: hethal.java@gmail.com
  Target Milestone: ---

We upgraded our POI from 4.1.2 to 5.0.0 and we are seeing the POI 5.0.0 upgrade
formats dates with extra slash
We are using SXSSFWorkbook and XSSFCellStyle and after upgrading to poi 5.0.0
when we compare our data Exports between the 4.1.2 POI libraries and the
upgraded 5.0.0 version we are encountering that there is format code
difference.

Prior to upgarde ( POI 4.1.2)

'Background color: Color [Window],   Foreground color: Color [WindowText],  
Font: [Font: Name=Calibri, Size=11, Units=3, GdiCharSet=1,
GdiVerticalFont=False],   Format code: dd mmm yyyy HH:mm:ss'

Post-upgrade( POI 5.0.0)

'Background color: Color [Window],   Foreground color: Color [WindowText],  
Font: [Font: Name=Calibri, Size=11, Units=3, GdiCharSet=1,
GdiVerticalFont=False],   Format code: dd\ mmm\ yyyy\ hh:mm:ss'

After the upgarde to poi 5.0.0, we are seeing the extra slash added to the date
format.

Is this a bug or intended?

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #4 from PJ Fanning <fa...@yahoo.com> ---
I can't reproduce any issue - I put a test case at
https://github.com/pjfanning/poi-gradle-example/tree/bug-65619 (NB a branch of
this project called bug-65619).

The code in this branch gives the same result if the build.gradle has poi 5.0.0
or poi 4.1.2.

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #6 from PJ Fanning <fa...@yahoo.com> ---
This is not a reproducible use case - maybe someone else will have a look but I
don't have time to look at this without a reproducible use case.

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WORKSFORME

--- Comment #12 from Dominik Stadler <do...@gmx.at> ---
It seems even with your test-case, it is not possible to reproduce this for us.
There are various reasons that can be related, e.g. using different locales,
using some unusual version of Java or other differences in your environment
compared to more usual setups. 

Maybe you can try some more to narrow down why the test-case works fine for us,
but seems to cause problems for you. 

If you find something that should be improved/fixed in Apache POI, please
re-open this issue with more comments.

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

PJ Fanning <fa...@yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

--- Comment #1 from PJ Fanning <fa...@yahoo.com> ---
If this has changed, it is not likely to be intentional. Could you provide a
more complex code sample for review?

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

hethal <he...@gmail.com> changed:

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

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #8 from hethal <he...@gmail.com> ---
Created attachment 38059
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=38059&action=edit
spreadsheet compare file with date format mismatch between 4.1.2 and 5.0.0.

Showing that there are back slashes in POI 5.0.0 that are not present in POI
4.1.2

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |regression

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #3 from hethal <he...@gmail.com> ---
you can take a look at the below code:
dateFormat = new SimpleDateFormat("dd MMM yyyy HH:mm:ss");

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #7 from PJ Fanning <fa...@yahoo.com> ---
the code in last comment is not POI code - you probably need someone in your
company to use a Java debugger to debug the code

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #9 from hethal <he...@gmail.com> ---
Below here is the code that we tried on POI 5.0.0 and POI 4.1.2 as well and
were able to reproduce that the POI 5.0.0 added the extra slashes as attache d
in the jpg image.

Code:
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Date;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.CreationHelper;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.junit.Test;

public class TestPoi {

    @Test
    public void test () throws IOException {
        SXSSFWorkbook workbook = new SXSSFWorkbook();
        SXSSFSheet sheet = workbook.createSheet("Test Sheet 1");
        Font font = workbook.createFont();
        CellStyle cs = workbook.createCellStyle();
        cs.setFont(font);
        Row row = sheet.createRow(0);
        Cell cell = row.createCell(1);
        cell.setCellValue(new Date());
        cell.setCellStyle(cs);
        CreationHelper ch = workbook.getCreationHelper();
        cs.setDataFormat(ch.createDataFormat().getFormat("dd MMM yyyy
HH:mm:ss"));
        cs.setAlignment(HorizontalAlignment.RIGHT);
        FileOutputStream fos = new FileOutputStream("c:/temp/test.xlsx");
        workbook.write(fos);
        fos.close();
        workbook.close();
        workbook.dispose();
    }
}

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #11 from PJ Fanning <fa...@yahoo.com> ---
I added this passing regression test - r1894016

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #10 from PJ Fanning <fa...@yahoo.com> ---
I ran the sample code and my output was fine (no slashes) - I have this in the
styles.xml - <numFmt numFmtId="164" formatCode="dd MMM yyyy HH:mm:ss"/>

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #2 from hethal <he...@gmail.com> ---
here is the code that we are using in our app


return new DataFormatter() {
                @Override
                public String formatRawCellContents (double value, int
formatIndex, String formatString) {
                    if ("GENERAL".equalsIgnoreCase(formatString)) {
                        return decimalFormat.format(value);
                    } else if (DateUtil.isADateFormat(formatIndex,
formatString) && DateUtil.isValidExcelDate(value)) {
                        DateFormat dateFormat;
                        if (StringUtils.containsIgnoreCase(formatString, "h"))
{
                            dateFormat = new SimpleDateFormat("dd MMM yyyy
HH:mm:ss");
                        } else {
                            dateFormat =  new SimpleDateFormat("dd MMM yyyy");
                        }
                        Date date = DateUtil.getJavaDate(value, false);
                        return dateFormat.format(date);
                    } else {
                        return super.formatRawCellContents(value, formatIndex,
formatString);
                    }
                }
            };

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

PJ Fanning <fa...@yahoo.com> changed:

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

-- 
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


[Bug 65619] with POI upgrade to 5.0.0, we see that it formats dates with extra slash

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

--- Comment #5 from hethal <he...@gmail.com> ---
Please take a look at the below code that we are using for our app:


public Builder dataFormat (String format) 
{
  return new Builder(fontTransform, cellStyleTransform.andThen(
    (cs, ch) -> cs.setDataFormat(ch.createDataFormat().getFormat("dd mmm 
        yyyy"))));
}

and looks like this code is using the `setDataFormat`, `createDataFormat` and
`getFormat` methods that are of the POI 5.0.0 jar.

-- 
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