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 2019/06/16 11:29:09 UTC

[Bug 63509] New: XSSFSheet addIgnoredErrors(CellReference cell, IgnoredErrorType... ignoredErrorTypes) creates corrupt file

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

            Bug ID: 63509
           Summary: XSSFSheet addIgnoredErrors(CellReference cell,
                    IgnoredErrorType... ignoredErrorTypes) creates corrupt
                    file
           Product: POI
           Version: unspecified
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: p.beauvoir@dadabeatnik.com
  Target Milestone: ---

This bug is in POI 4.1.0

It works OK on POI 4.0.1

I am using XSSFSheet addIgnoredErrors(CellReference cell,  IgnoredErrorType...
ignoredErrorTypes) like this:

XSSFSheet sheet;
Cell cell;

sheet.addIgnoredErrors(new CellReference(cell),
IgnoredErrorType.NUMBER_STORED_AS_TEXT);

When the XSSFWorkbook is saved to "file.xlsx" Excel reports an error when
opening it:

"Excel found unreadable content in file.xlsx"

Inside the Excel file at sheet1.xml I see this:

<ignoredErrors>
    <ignoredError sqref="SheetName!A1" numberStoredAsText="true" />
</ignoredErrors>

In POI 4.0.1 the same thing is written as:

<ignoredErrors>
    <ignoredError sqref="A1" numberStoredAsText="true" />
</ignoredErrors>

So it seems that 4.1.0 is prefixing the Sheet name to to sqref and Excel barfs.

-- 
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 63509] XSSFSheet.addIgnoredErrors(CellReference, IgnoredErrorType) creates corrupt Excel file

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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |62828
           Severity|normal                      |regression

--- Comment #4 from Dominik Stadler <do...@gmx.at> ---
This is likely caused by r1850210 which fixed bug #62828, seems Excel is
inconsistent in which style of cell-reference is supported where, so we might
need to use special formatting when writing this part of the XLSX file.


Referenced Bugs:

https://bz.apache.org/bugzilla/show_bug.cgi?id=62828
[Bug 62828] CellReference(Cell) ctor does not initialize sheetName
-- 
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 63509] XSSFSheet.addIgnoredErrors(CellReference, IgnoredErrorType) creates corrupt Excel file

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

p.beauvoir@dadabeatnik.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|XSSFSheet                   |XSSFSheet.addIgnoredErrors(
                   |addIgnoredErrors(CellRefere |CellReference,
                   |nce cell,                   |IgnoredErrorType) creates
                   |IgnoredErrorType...         |corrupt Excel file
                   |ignoredErrorTypes) creates  |
                   |corrupt file                |

-- 
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 63509] XSSFSheet addIgnoredErrors(CellReference cell, IgnoredErrorType... ignoredErrorTypes) creates corrupt file

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

--- Comment #2 from p.beauvoir@dadabeatnik.com ---
Workaround:

CellReference has this constructor which ensures that _sheetName is null:

public CellReference(int pRow, int pCol, boolean pAbsRow, boolean pAbsCol) {
    this(null, pRow, pCol, pAbsRow, pAbsCol);
}

So call that constructor like this:

XSSFSheet sheet;
Cell cell;

sheet.addIgnoredErrors(new CellReference(cell.getRowIndex(),
cell.getColumnIndex(), false, false), IgnoredErrorType.NUMBER_STORED_AS_TEXT);

-- 
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 63509] XSSFSheet.addIgnoredErrors(CellReference, IgnoredErrorType) creates corrupt Excel file

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

--- Comment #6 from p.beauvoir@dadabeatnik.com ---
> Fixed

Nice. Thanks.

-- 
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 63509] XSSFSheet addIgnoredErrors(CellReference cell, IgnoredErrorType... ignoredErrorTypes) creates corrupt file

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

p.beauvoir@dadabeatnik.com changed:

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

--- Comment #1 from p.beauvoir@dadabeatnik.com ---
In 4.0.1 the CellReference constructor is this:

public CellReference(Cell cell) {
   this(cell.getRowIndex(), cell.getColumnIndex(), false, false);
}

This means that _sheetName is null. And so the Sheet name is not prefixed to
the cell.

In 4.1.0 the CellReference constructor is this:

public CellReference(Cell cell) {
   this(cell.getSheet().getSheetName(), cell.getRowIndex(),
cell.getColumnIndex(), false, false);
}


This means that _sheetName is not null. And so the Sheet name is prefixed to
the cell leading to the problem.

-- 
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 63509] XSSFSheet addIgnoredErrors(CellReference cell, IgnoredErrorType... ignoredErrorTypes) creates corrupt file

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

--- Comment #3 from p.beauvoir@dadabeatnik.com ---
Created attachment 36629
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=36629&action=edit
Test snippet that demonstrates the bug

-- 
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 63509] XSSFSheet.addIgnoredErrors(CellReference, IgnoredErrorType) creates corrupt Excel file

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

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

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

--- Comment #5 from Dominik Stadler <do...@gmx.at> ---
Applied a fix via r1861817 which does not include the sheetName in references
when setting ignored errors for cells.

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