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

--- Comment #19 from Dean Walker <[email protected]> ---
I've seen this behaviour in various places (I'm using POI 3.10 Beta 1).
This disconnection happens during the first save where new 'container' objects
are created.
For example:
        // Fonts
        CTFonts ctFonts = CTFonts.Factory.newInstance();
        ctFonts.setCount(fonts.size());
        CTFont[] ctfnt = new CTFont[fonts.size()];
        idx = 0;
        for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
        ctFonts.setFontArray(ctfnt);
        styleSheet.setFonts(ctFonts);

Here CTFonts is a container for a CTFont array.
If we reuse the existing container, the problem goes away, example:

        // Fonts
        CTFonts ctFonts = styleSheet.getFonts();
        if (ctFonts == null) {
            ctFonts = CTFonts.Factory.newInstance();
        }
        ctFonts.setCount(fonts.size());
        CTFont[] ctfnt = new CTFont[fonts.size()];
        idx = 0;
        for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();
        ctFonts.setFontArray(ctfnt);
        styleSheet.setFonts(ctFonts);

This works for my use case where I read an existing spreadsheet, update cell
values only, and then save the modified spreadsheet. I've not tried the use
case where fonts (or other objects) are programatically modified or added or
deleted.
There are numerous places in StylesTable.writeTo() where I have applied this
same solution.
I also encountered the same problem with named ranges and applied the same
solution to XSSFWorkBook.saveNamedRanges().
There may be other places where the same symptom appears depending on the
features you use in your spreadsheet.
This solution is not ideal (it cures the symptom rather than the cause) but I
hope this information will help resolve this bug.

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to