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 2016/09/28 15:27:54 UTC

[Bug 60184] New: Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

            Bug ID: 60184
           Summary: Saved file that uses a XSSFFont without a specifically
                    set FontFamily won't open in Excel
           Product: POI
           Version: 3.15-FINAL
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: anna@vaadin.com

Steps to reproduce:
* open a spreadsheet created with Excel.
* create a new cell style with workbook.createCellStyle()
* create a new XSSFFont with workbook.createFont()
* add the font to the new style
* add the style to one cell
* save the sheet to a new file
* try to open the created file in Excel

If you add FontFamily to the new font, the resulting file opens without issues.
Otherwise it complains about corrupted style.

The issue is apparently also present in some sheets with pre-existing styling
that are simply loaded to POI and then saved into another sheet. See
https://dev.vaadin.com/ticket/20180 for example files and more details.

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

Javen O'Neal <on...@apache.org> 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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

--- Comment #5 from anna@vaadin.com ---
Not-so-nice workaround:

Copy over StylesTable.java to local projet, change writeTo to contain

        for (XSSFFont f : fonts) {
            if (FontFamily.NOT_APPLICABLE.getValue() == f.getFamily()) {
                f.setFamily(FontFamily.SWISS);
            }
            ctfnt[idx++] = f.getCTFont();
        }

instead of

        for(XSSFFont f : fonts) ctfnt[idx++] = f.getCTFont();

and do that again every time you update the version.

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

Greg Woolsey <gw...@apache.org> changed:

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

--- Comment #9 from Greg Woolsey <gw...@apache.org> ---
Fixed in 3.17, r1794111.  No longer creating an empty family entry as a side
effect of calling the getter.

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

--- Comment #3 from anna@vaadin.com ---
Does the status change mean that you couldn't reproduce the issue with Excel
Viewer?

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

--- Comment #4 from anna@vaadin.com ---
Behaviour was already present in 3.12, not sure about older ones. Don't have a
unit test, tested manually in existing project. I tested the files attached to
the linked ticket on Excel 2013 and Excel Viewer, with Libre Office they worked
fine.

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

Marek Branicky <ma...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All
           Severity|normal                      |blocker

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

Greg Woolsey <gw...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gwoolsey@apache.org

--- Comment #8 from Greg Woolsey <gw...@apache.org> ---
I just now found this issue, wish I'd seen it earlier.  I see the problem now.

XSSFFont can be created without a family.  This is what happens when calling
XSSFWorkbook.createFont().  This is fine per the OOXML XSD.

However, XSSFFont.getFamily() creates an empty family element if none exist. 
This is invalid, as the family element is required to have a val attribute.

Further, it's really bad practice for things that are defined as property
getters to have side effects like this.

Since the API's been out there a while, we should maintain backward
compatibility, but I don't like it too much.

I think in the missing element case it should just return 0, the index for
NOT_APPLICABLE, which appears to coincide with "auto" in the spec, but NOT
create a family element.

Better would be a method that returns an instance of the enum or null if not
defined, or NOT_APPLICABLE if null is undesirable.  For now though, I'll just
update to not create the empty element if missing.

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

Javen O'Neal <on...@apache.org> 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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

--- Comment #7 from ps26oct@gmail.com ---
I obtained poi src from git read only repo and built it accordingly. Using MS
Excel 2016 (with a MS office home subscription, which expired recently but
doesn't restrict much of the functionality of excel 2016 that I needed for
trying to reproduce the error), I was unable to reproduce the issue. Here's the
code which I used:

import java.io.*;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class bz60184 {

        public static void main(String[] args) throws IOException,
InvalidFormatException {

                File f = new File("file.xlsx"); //already created with excel in
the user.dir

                XSSFWorkbook wb = new XSSFWorkbook(f);
                XSSFCellStyle styl  = wb.createCellStyle();
                XSSFFont font = wb.createFont();
                styl.setFont(font);
                wb.getSheetAt(0).getRow(0).getCell(0).setCellStyle(styl);
                File f2 = new File("save.xlsx");
                if(f2.exists())
                        f2.delete();

                FileOutputStream os = new FileOutputStream(f2);
                wb.write(os);
                wb.close();
                os.close();
                System.out.println("DONE");

        }

}


//OS - WIN 10 ; JDK - jdk_8u102

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

--- Comment #6 from Marek Branicky <ma...@gmail.com> ---
Guys is this fixed in version POI 3.15 or do you plan to fix it in near future?

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

--- Comment #1 from Javen O'Neal <on...@apache.org> ---
Created attachment 34312
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=34312&action=edit
unit test

I am unable to reproduce this on the trunk (currently a few commits after 3.15)
using LibreOffice 4.2.8.2. I can check with Microsoft Excel later.

Is this behavior a regression in 3.15?
Can you verify that my unit test is the same as yours (if not, could you submit
your unit test)?

-- 
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 60184] Saved file that uses a XSSFFont without a specifically set FontFamily won't open in Excel

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

--- Comment #2 from anna@vaadin.com ---
LibreOffice doesn't have the problem, Excel does. Also reproducible in Excel
Viewer.

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