We use a number of unusual characters in our reports, and we use code like the following to add them where required (similar code is used for other characters):
- Code: Select all
public static CTRElt getDoubleAngleWithSpaces()
{
if (doubleAngleWithSpaces == null)
{
doubleAngleWithSpaces = new CTRElt();
Character dbleAngle = '\u00BB';
CTXstringWhitespace strDoubleAngleNSpace = Context.getsmlObjectFactory().createCTXstringWhitespace();
strDoubleAngleNSpace.setValue( " " + dbleAngle.toString() + " " );
strDoubleAngleNSpace.setSpace("preserve");
doubleAngleWithSpaces.setT(strDoubleAngleNSpace );
/* Add some property info as MS Excel gets awkward if there is no property info preceeding something with properties */
CTRPrElt propsDoubleAngle = Context.getsmlObjectFactory().createCTRPrElt();
CTColor colorGrey = Context.getsmlObjectFactory().createCTColor();
colorGrey.setTheme( 1L );
colorGrey.setTint( NOUGHT_POINT_SIX );
JAXBElement<CTColor> jbGreyColor = Context.getsmlObjectFactory().createCTFontColor( colorGrey );
propsDoubleAngle.getRFontOrCharsetOrFamily().add( jbGreyColor );
doubleAngleWithSpaces.setRPr( propsDoubleAngle );
}
return doubleAngleWithSpaces;
}
When compiled with Java 6 the above code gives a double right pointing arrow (double greater than), but with Java 7 it gives a black diamond with a white question mark inside (may just be what Excel displays unknown characters as?).
Also many of our reports have grouping of rows, and should initially open with the grouped rows fully collapsed. Again this works when compiled with Java 6 but not when compiled with Java 7. The grouping is done using the following code:
- Code: Select all
public void setOutlineLevelForRow( long rowId, int outlineLevel, boolean isCollapsed, boolean isHidden )
{
XLSXRow xLSXRow = gridRows.get( rowId );
Row row = xLSXRow.getRow();
//noinspection NumericCastThatLosesPrecision
row.setOutlineLevel( (short) outlineLevel );
row.setCollapsed( isCollapsed );
row.setHidden( isHidden );
if (outlineLevel > maxRowOutlineLevel)
{
setRowOutlineLevelOnSheet( outlineLevel );
maxRowOutlineLevel = outlineLevel;
}
}
private void setRowOutlineLevelOnSheet( int outlineLevel )
{
if (theWorkSheet.getJaxbElement().getSheetFormatPr() == null)
{
CTSheetFormatPr sheetFormatPr = new CTSheetFormatPr();
theWorkSheet.getJaxbElement().setSheetFormatPr( sheetFormatPr );
}
//noinspection NumericCastThatLosesPrecision
theWorkSheet.getJaxbElement().getSheetFormatPr().setOutlineLevelRow( (short) outlineLevel );
//noinspection MagicNumber
theWorkSheet.getJaxbElement().getSheetFormatPr().setDefaultRowHeight(
15.0D ); // required for automatic collapsing
}
I assume others are using Java 7 without problems so can anyone give me any pointers as to where the problems might be occurring?
On further investigation I notice an error as xlsx4j starts up which I suspect is the reason for these problems:
- Code: Select all
Context - java.vendor=Oracle Corporation
23-Jul-2015 18:26:52,635 INFO - Context - java.version=1.7.0_21
23-Jul-2015 18:26:52,965 INFO - NamespacePrefixMapperUtils - Using NamespacePrefixMapperSunInternal, which is suitable for Java 6
23-Jul-2015 18:26:52,968 DEBUG - ResourceUtils - Not using MOXy, since no resource: org/docx4j/wml/jaxb.properties
23-Jul-2015 18:26:52,968 DEBUG - Context - org/docx4j/wml/jaxb.properties not found via classloader.
23-Jul-2015 18:26:52,969 DEBUG - ResourceUtils - Not using MOXy, since no resource: org/docx4j/wml/jaxb.properties
23-Jul-2015 18:26:52,969 DEBUG - Context - org/docx4j/wml/jaxb.properties not found via classloader.
23-Jul-2015 18:26:52,969 INFO - Context - Using Java 6/7 JAXB implementation
23-Jul-2015 18:27:07,284 INFO - Context - Not using MOXy.
23-Jul-2015 18:27:08,195 ERROR - Context - Cannot initialize context
javax.xml.bind.JAXBException: Provider com.sun.xml.internal.bind.v2.ContextFactory could not be instantiated: javax.xml.bind.JAXBException: "org.plutext.jaxb.xmldsig" doesnt contain ObjectFactory.class or jaxb.index
- with linked exception:
[javax.xml.bind.JAXBException: "org.plutext.jaxb.xmldsig" doesnt contain ObjectFactory.class or jaxb.index]
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:146)
at javax.xml.bind.ContextFinder.find(ContextFinder.java:347)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:431)
at javax.xml.bind.JAXBContext.newInstance(JAXBContext.java:394)
at org.docx4j.jaxb.Context.<clinit>(Context.java:151)
at org.docx4j.openpackaging.parts.JaxbXmlPart.<init>(JaxbXmlPart.java:85)
at org.docx4j.openpackaging.parts.JaxbXmlPartXPathAware.<init>(JaxbXmlPartXPathAware.java:56)
at org.docx4j.openpackaging.parts.SpreadsheetML.JaxbSmlPart.<init>(JaxbSmlPart.java:34)
at org.docx4j.openpackaging.parts.SpreadsheetML.SharedStrings.<init>(SharedStrings.java:16)
at uk.co.stasys.ier.reports.xLSX.XLSXSpreadSheetIER.<init>(XLSXSpreadSheetIER.java:37)
at uk.co.stasys.ier.reports.IERXLSXFormatHandler.convertXML(IERXLSXFormatHandler.java:54)
at uk.co.stasys.reporting.creation.output.ReportOutputGenerator.generateReport(ReportOutputGenerator.java:85)
at uk.co.stasys.ier.reports.IERReportGenerator.generateReport(IERReportGenerator.java:59)
at uk.co.stasys.reporting.creation.main.ESmartReport.transformReport(ESmartReport.java:303)
at uk.co.stasys.reporting.creation.main.ESmartReport.transformReport(ESmartReport.java:278)
at uk.co.stasys.reporting.creation.main.ESmartReport.createReportParts(ESmartReport.java:199)
at uk.co.stasys.reporting.creation.main.ESmartReport.generateReport(ESmartReport.java:91)
at uk.co.stasys.reporting.creation.main.ReportCreationLauncher$LaunchReport.run(ReportCreationLauncher.java:272)
at java.lang.Thread.run(Thread.java:722)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
Caused by: javax.xml.bind.JAXBException: "org.plutext.jaxb.xmldsig" doesnt contain ObjectFactory.class or jaxb.index
at com.sun.xml.internal.bind.v2.ContextFactory.createContext(ContextFactory.java:216)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:172)
at javax.xml.bind.ContextFinder.newInstance(ContextFinder.java:132)
Is this likely to be the cause? How do I solve this problem?
Note: I am using Excel 2010 to open both sets of reports, and have not made any changes to the report code, just changed the compiler used.
Java 6 == JDK1.6.0_18
Java 7 == JDK1.7.0_21