DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7830>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7830 [PATCH] Data Format support for HSSF Serializer Summary: [PATCH] Data Format support for HSSF Serializer Product: Cocoon 2 Version: Current CVS Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: general components AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] CC: [EMAIL PROTECTED] Index: src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java =================================================================== RCS file: /home/cvspublic/xml-cocoon2/src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java,v retrieving revision 1.3 diff -u -r1.3 EPStyle.java --- src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java 7 Mar 2002 07:50:09 -0000 1.3 +++ +src/java/org/apache/cocoon/components/elementprocessor/impl/poi/hssf/elements/EPStyle.java + 8 Apr 2002 11:54:19 -0000 @@ -201,13 +201,20 @@ } style.setWrapText(getWrapText()); style.setLocked(true); + + String format = getFormat(); + if (format != null) { + format = kludgeForGnumericMisformats(format); + short nformat = org.apache.poi.hssf.usermodel.HSSFDataFormat.getFormat(format); + getLogger().debug("setting format to "+ nformat); + style.setDataFormat(nformat); + } } else { invalid = true; } } - /** * @return true if horizontal alignment general bit is set * @@ -625,5 +632,27 @@ } return retval; } + + /** + * Takes in a Gnumeric format string and applies some rules to it. Some + * versions of Gnumeric seem to leave off the first parenthesis which + * causes them not to match the Excel-style format string. (which of course + * makes it a little hard to match) + */ + private String kludgeForGnumericMisformats(String format) { + String retval = format; + getLogger().debug("going out of the format kludger "+ retval); + getLogger().debug("first )="+format.indexOf(')')); + getLogger().debug("first (="+format.indexOf('(')); + if ( (format.indexOf(')') < format.indexOf('(')) && + (format.indexOf(')') != -1 ) + ) { + retval = "("+format; + } + getLogger().debug("going out of the format kludger "+ retval); + return retval; + } + + } // end public class EPStyle --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]