Details

    • Type: New Feature New Feature
    • Status: Closed Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.1
    • Component/s: Export
    • Labels:
      None
    • Application server:
      All

      Description

      It would be nice to use POI to export excel files.
      The actual export mecanism don't translate well things like dates, or numbers (i18n issues).
      1. excelhssfview.java
        7 kB
        Karsten Voges
      2. excelhssfview.java
        6 kB
        fabrizio giustina

        Activity

        Hide
        Karsten Voges added a comment -
        I am suggesting a second Excel export (called XLS(Poi)), which needs to be set to true (e.g.: export.poi=true) in the display.porperties.
        Since I worked a lot with POI lately and made it work with displaytag I would like to contribute it.
        Just let me know how, where, etc.
        With this I would recommend to restructure the org.displaytag.export package.
        So PDFView and ExcelPOIView can share a base class, just like the text versions.
        Show
        Karsten Voges added a comment - I am suggesting a second Excel export (called XLS(Poi)), which needs to be set to true (e.g.: export.poi=true) in the display.porperties. Since I worked a lot with POI lately and made it work with displaytag I would like to contribute it. Just let me know how, where, etc. With this I would recommend to restructure the org.displaytag.export package. So PDFView and ExcelPOIView can share a base class, just like the text versions.
        Hide
        fabrizio giustina added a comment -
        I already have a POI-based export view for displaytag, but I'd like to find a smarted way to distribute custom export views without embedding everything in the main distribution (the list of dependencies needed for compiling is already really huge).

        Anyway, I am attaching here the file if somebody needs it now. Just add POI to the classpath, compile it, and replace the original excel export class in display.properties
        Show
        fabrizio giustina added a comment - I already have a POI-based export view for displaytag, but I'd like to find a smarted way to distribute custom export views without embedding everything in the main distribution (the list of dependencies needed for compiling is already really huge). Anyway, I am attaching here the file if somebody needs it now. Just add POI to the classpath, compile it, and replace the original excel export class in display.properties
        Hide
        andy pruitt added a comment -
        I would bet that most folks would prefer to use the POI exporter over the basic one. How about handling it like the pdf exporter, so that if POI is in the classpath it will the use the POI exporter, but would otherwise default to the basic exporter?
        Show
        andy pruitt added a comment - I would bet that most folks would prefer to use the POI exporter over the basic one. How about handling it like the pdf exporter, so that if POI is in the classpath it will the use the POI exporter, but would otherwise default to the basic exporter?
        Hide
        Karsten Voges added a comment -
        thx for your file.
        I vote for distributing it in the same way as the PDF/iText version.
        Unfortunately I am not that deep into the source to suggest a better way to include/distribute special views.
        Anyway, I guess there isn´t much beside XML, PDF and Excel. maybe you should move the export package to a different jar, so people not interested in it, do not need to include it and do have some dependecies less during the build.
        Show
        Karsten Voges added a comment - thx for your file. I vote for distributing it in the same way as the PDF/iText version. Unfortunately I am not that deep into the source to suggest a better way to include/distribute special views. Anyway, I guess there isn´t much beside XML, PDF and Excel. maybe you should move the export package to a different jar, so people not interested in it, do not need to include it and do have some dependecies less during the build.
        Hide
        Karsten Voges added a comment -
        Inserted a small patch into the doExport method tagged by
        /* start of patch by Karsten Voges */
        /* end of patch by Karsten Voges */

        The patch formats the width of the colums either according to the maxLenght, set in the colum tag or to the lenght of the header cell, which can be adjusted by putting tailing whitespaces in the message.properties

        Anyone interested in a configurable style?
        Show
        Karsten Voges added a comment - Inserted a small patch into the doExport method tagged by /* start of patch by Karsten Voges */ /* end of patch by Karsten Voges */ The patch formats the width of the colums either according to the maxLenght, set in the colum tag or to the lenght of the header cell, which can be adjusted by putting tailing whitespaces in the message.properties Anyone interested in a configurable style?
        Hide
        Karsten Voges added a comment -
        inserted the following method to escape tabs and returns:

           /***
        * Escaping for excel format.
        * <ul>
        * <li>Escaped to remove tabs and returns. Only \n is valid for excel</li>
        * </ul>
        * @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object)
        */
        protected String escapeColumnValue(Object value) {
        if (value != null) {
        String returnString = value.toString();
        // escape the String to get the tabs, returns, newline explicit as \t \r \n
        returnString = StringEscapeUtils.escapeJava(StringUtils.trimToEmpty(returnString));
        // remove tabs, insert four whitespaces instead
        returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", " ");
        // remove the return, only newline valid in excel
        returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " ");
        // unescape so that \n gets back to newline
        returnString = StringEscapeUtils.unescapeJava(returnString);
        return returnString;
        }
        return null;
        }
        Show
        Karsten Voges added a comment - inserted the following method to escape tabs and returns:    /*** * Escaping for excel format. * <ul> * <li>Escaped to remove tabs and returns. Only \n is valid for excel</li> * </ul> * @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object) */ protected String escapeColumnValue(Object value) { if (value != null) { String returnString = value.toString(); // escape the String to get the tabs, returns, newline explicit as \t \r \n returnString = StringEscapeUtils.escapeJava(StringUtils.trimToEmpty(returnString)); // remove tabs, insert four whitespaces instead returnString = StringUtils.replace(StringUtils.trim(returnString), "\\t", " "); // remove the return, only newline valid in excel returnString = StringUtils.replace(StringUtils.trim(returnString), "\\r", " "); // unescape so that \n gets back to newline returnString = StringEscapeUtils.unescapeJava(returnString); return returnString; } return null; }
        Hide
        added a comment -
        for MULTILANGuAGE support yir must set

        cell.setEncoding( HSSFCell.ENCODING_UTF_16 )

        than you able to see text in different language;
        Show
        added a comment - for MULTILANGuAGE support yir must set cell.setEncoding( HSSFCell.ENCODING_UTF_16 ) than you able to see text in different language;
        Hide
        andy pruitt added a comment -
        Ok, I've committed a modified version that incorporates most of these changes, and is capable of handling the numeric export of text values.

        I've not added the column width functionality, will take a look at it later. It looks like there is no way to do it automatically in POI? :(
        Show
        andy pruitt added a comment - Ok, I've committed a modified version that incorporates most of these changes, and is capable of handling the numeric export of text values. I've not added the column width functionality, will take a look at it later. It looks like there is no way to do it automatically in POI? :(
        Hide
        fabrizio giustina added a comment -
        Excel export using poi will be distributed in a separate jar (can be found in the displaytag-export-poi CVS module, see http://cvs.sourceforge.net/viewcvs.py/displaytag/displaytag-export-poi/ )

        Should incorporate all the patches except for the column width setting, plese open a separate issue in Jira for that, if needed.
        Show
        fabrizio giustina added a comment - Excel export using poi will be distributed in a separate jar (can be found in the displaytag-export-poi CVS module, see http://cvs.sourceforge.net/viewcvs.py/displaytag/displaytag-export-poi/ ) Should incorporate all the patches except for the column width setting, plese open a separate issue in Jira for that, if needed.

          People

          • Reporter:
            raw
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: