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 2014/03/19 01:43:08 UTC

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

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