> Hi *DisplayTagTeam*,
> 
> First of all, thank you for coming up with such a nice way of displaying
> tables in an excellent manner!
> 
> I came across a legacy code of ours which uses display tag 1.0. Need some
> help regarding the *Export *feature.
> 
> *Problem:*
> For English locale, it works just fine. The export.xls file shows all the
> content, including the column headers correctly.
> However, for Japanese locale, the headers (which should be in Japanese
> Language) are mangled.
> 
> Observations:
> 
>    1. [Opening With] Notepad, the export.xls file has the correct textual
>    contents.
>    Eg. Like this: [Note: My browser shows Japanese content here in the
>    headers]
>    "メール" "ユーザ名SoftwareSuper" "ユーザ管理グループ"
> "役割"
>    "t...@tester.com" "10013" "" "Administrator
>    "
> 
>    But the expected behaviour should be that, *an xls file is not a text
>    file and is heavily encoded and thus note readable from a text editor.*
>    [Question] What is causing the problem here? or When can this problem
>    happen? I would like to encode the xls file just as a standard Windows
>    excel file, instead of a simple text open-able file. What should I do
> or
>    take care of?

1. Make sure your JSP ist in UTF-8
2. Switch to CSV
3. Use my custom implementation:

import org.apache.commons.lang.StringUtils;
import org.displaytag.export.CsvView;

/**
 * Excelkompatibler CSV-Export:
 * <ol>
 * <li>Feldtrenner muss ein Semikolon sein.</li>
 * <li>Bei UTF-8 Kodierung <strong><a
 * href="http://wiki.sdn.sap.com/wiki/display/ABAP/Excel+files+-+CSV+format";
 * >muss</a></strong> der BOM vorhanden sein, sonst ist die Datei für Excel
 * nicht sauber lesbar. Obwohl der BOM <a
 * href="http://unicode.org/faq/utf_bom.html#bom5";>nicht empfohlen</a> wird bei
 * UTF-8</li>.
 * </ol>
 */
public class ExcelCompatibleCsvView extends CsvView {

        @Override
        protected String getDocumentStart() {
                // Write Byte Order Mark
                return "\ufeff";
        }

        @Override
        protected String getCellEnd() {
                return ";";
        }

        @Override
        protected String escapeColumnValue(Object value) {
                String stringValue = StringUtils.trim(value.toString());
                if (!StringUtils.containsNone(stringValue, new char[] { '\n', 
';' })) {
                        return "\"" + //$NON-NLS-1$
                                        StringUtils.replace(stringValue, "\"", 
"\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                }

                return stringValue;
        }

}
-- 
Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir
belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
displaytag-user mailing list
displaytag-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/displaytag-user

Reply via email to