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 2013/11/20 05:29:30 UTC

[Bug 55800] New: cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

            Bug ID: 55800
           Summary: cloneStyleFrom(CellStyle cellStyle) creates error
                    "Unreadable content".
           Product: POI
           Version: 3.9
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: tienduong.nk@gmail.com

Created attachment 31058
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31058&action=edit
Full java code of this copy.

Source file: InStyleSheet.xlsx (existing)
Destination file: Output.xlsx (not existing yet)

Create new file Output.xlsx
Write data value to cell A1.
Clone CellStyle in cell A1 of InStyleSheet.xlsx to apply on A1 of Output.xlsx
This is done by using:
        Cell oldCell = inpWb.getSheetAt(0).getRow(0).getCell(0);
        CellStyle cellStyle = outWb.createCellStyle();
        cellStyle.cloneStyleFrom(oldCell.getCellStyle());
        newCell.setCellStyle(cellStyle);

Save Output.xlsx and exit.

Error: 
Java: no error.
Excel: Complains: Excel found unreadable content in "Output.xlsx". Do you want
to recover the contents of this workbook? If you trust the source of this
workbook, click Yes.

-- 
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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

Dominik Stadler <do...@gmx.at> 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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

--- Comment #5 from kiransringeri@gmail.com ---
The reason is it won't copy the XSSFCellFill and XSSFCellBorder. This also
gives problem with borders. I have added a method in
org.apache.poi.xssf.model.StylesTable which will help in creating a copy of
workbook. 

public void copyTo(StylesTable stylesTable){
        stylesTable.numberFormats.clear();
        stylesTable.fonts.clear();
        stylesTable.fills.clear();
        stylesTable.borders.clear();
        stylesTable.styleXfs.clear();
        stylesTable.xfs.clear();
        stylesTable.dxfs.clear();

        for(String str : numberFormats.values())
            stylesTable.putNumberFormat(str);

        for(XSSFFont font : fonts){
            XSSFFont fontNew = new XSSFFont(font.getCTFont());
            fontNew.registerTo(stylesTable);
        }
        for(XSSFCellFill fill : fills){
            XSSFCellFill fillNew = new XSSFCellFill(fill.getCTFill());
            stylesTable.putFill(fillNew);
        }
        for(XSSFCellBorder border : borders){
            XSSFCellBorder borderNew = new
XSSFCellBorder(border.getCTBorder());
            stylesTable.putBorder(borderNew);
        }
        for(CTXf ctxf : styleXfs){
            CTXf ctxfNew = (CTXf)ctxf.copy();
            stylesTable.putCellStyleXf(ctxfNew);
        }
        for(CTXf ctxf : xfs){
            CTXf ctxfNew = (CTXf)ctxf.copy();
            stylesTable.putCellXf(ctxfNew);
        }
        for(CTDxf dxf : dxfs){
            CTDxf dxfNew = (CTDxf)dxf.copy();
            stylesTable.putDxf(dxfNew);
        }
    }

-- 
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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

Nick Burch <ap...@gagravarr.org> changed:

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

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
Does this happen for all cell styles, or just this one?

Can you identify what about the cell style breaks it? Eg style in A1 clones
fine, A2 is A1 plus XXXX, which then fails? That'll help narrow down what's
going wrong

-- 
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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

--- Comment #2 from Tien Duong <ti...@gmail.com> ---
Hi. This problem happened for all cells in the sheet. 
I tried the sheet with few hundred cells data, all cells got formatting issue. 
In the code that I sent, I only checked 1 cell, it came with the same issue. 

Conclusion: Error happened for all 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


[Bug 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

kiransringeri@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kiransringeri@gmail.com

-- 
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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

--- Comment #4 from Tien Duong <ti...@gmail.com> ---
My test was:
- Create brand new One.xlsx file. Do formatting for cell A1 as follow:

cellStyle.setFillForegroundColor(IndexedColors.YELLOW.getIndex());
cellStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
myCell.setCellStyle(cellStyle);

- Save file. Close.

- Create brand new Two.xlsx file. Clone cellstyle from One.xlxs :
Cell oldCell = oneWorkbook.getSheetAt(0).getRow(0).getCell(0);
cellStyle2.cloneStyleFrom(oldCell.getCellStyle());
newCell.setCellStyle(cellStyle2);

- Save file. Close.

===> Error happened for Two.xlxs (Unreadable content.)

-- 
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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

--- Comment #6 from j.zimmer@t-p.com ---
Hello,

will there be a bugfix available in the near future?

Thanks in advance

-- 
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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

j.zimmer@t-p.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |j.zimmer@t-p.com

-- 
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 55800] cloneStyleFrom(CellStyle cellStyle) creates error "Unreadable content".

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

--- Comment #3 from Nick Burch <ap...@gagravarr.org> ---
All cells in that workbook, or all cells in all workbooks?

For example, if you create a new empty workbook, can you clone from that? What
about if you start with an empty workbook, and begin styling a cell there. Does
it fail immediately? When it almost looks like a cell in your problem file?
When it exactly matches?

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