• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / displaytag / 1558

08 Dec 2025 01:09AM UTC coverage: 77.32% (-0.04%) from 77.358%
1558

push

github

web-flow
Merge pull request #1042 from hazendaz/renovate/javax-support-org.apache.commons-commons-text-1.x

Update dependency org.apache.commons:commons-text to v1.15.0 (javax-support)

1435 of 1999 branches covered (71.79%)

Branch coverage included in aggregate %.

4030 of 5069 relevant lines covered (79.5%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/displaytag/src/main/java/org/displaytag/export/ExcelView.java
1
/*
2
 * Copyright (C) 2002-2025 Fabrizio Giustina, the Displaytag team
3
 *
4
 * Permission is hereby granted, free of charge, to any person obtaining a copy
5
 * of this software and associated documentation files (the "Software"), to deal
6
 * in the Software without restriction, including without limitation the rights
7
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
 * copies of the Software, and to permit persons to whom the Software is
9
 * furnished to do so, subject to the following conditions:
10
 *
11
 * The above copyright notice and this permission notice shall be included in
12
 * all copies or substantial portions of the Software.
13
 *
14
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
 * THE SOFTWARE.
21
 */
22
package org.displaytag.export;
23

24
import org.apache.commons.lang3.StringUtils;
25
import org.apache.commons.lang3.Strings;
26

27
/**
28
 * Export view for excel exporting.
29
 */
30
public class ExcelView extends BaseExportView {
1✔
31

32
    /**
33
     * Gets the mime type.
34
     *
35
     * @return "application/vnd.ms-excel"
36
     *
37
     * @see org.displaytag.export.ExportView#getMimeType()
38
     */
39
    @Override
40
    public String getMimeType() {
41
        return "application/vnd.ms-excel"; //$NON-NLS-1$
1✔
42
    }
43

44
    /**
45
     * Gets the row end.
46
     *
47
     * @return the row end
48
     *
49
     * @see org.displaytag.export.BaseExportView#getRowEnd()
50
     */
51
    @Override
52
    protected String getRowEnd() {
53
        return "\n"; //$NON-NLS-1$
1✔
54
    }
55

56
    /**
57
     * Gets the cell end.
58
     *
59
     * @return the cell end
60
     *
61
     * @see org.displaytag.export.BaseExportView#getCellEnd()
62
     */
63
    @Override
64
    protected String getCellEnd() {
65
        return "\t"; //$NON-NLS-1$
1✔
66
    }
67

68
    /**
69
     * Gets the always append cell end.
70
     *
71
     * @return false
72
     *
73
     * @see org.displaytag.export.BaseExportView#getAlwaysAppendCellEnd()
74
     */
75
    @Override
76
    protected boolean getAlwaysAppendCellEnd() {
77
        return false;
1✔
78
    }
79

80
    /**
81
     * Gets the always append row end.
82
     *
83
     * @return false
84
     *
85
     * @see org.displaytag.export.BaseExportView#getAlwaysAppendRowEnd()
86
     */
87
    @Override
88
    protected boolean getAlwaysAppendRowEnd() {
89
        return false;
1✔
90
    }
91

92
    /**
93
     * Escaping for excel format.
94
     * <ul>
95
     * <li>Quotes inside quoted strings are escaped with a double quote</li>
96
     * <li>Fields are surrounded by " (should be optional, but sometimes you get a "Sylk error" without those)</li>
97
     * </ul>
98
     *
99
     * @param value
100
     *            the value
101
     *
102
     * @return the string
103
     *
104
     * @see org.displaytag.export.BaseExportView#escapeColumnValue(java.lang.Object)
105
     */
106
    @Override
107
    protected String escapeColumnValue(final Object value) {
108
        if (value != null) {
1!
109
            // quotes around fields are needed to avoid occasional "Sylk format invalid" messages from excel
110
            return "\"" //$NON-NLS-1$
1✔
111
                    + Strings.CS.replace(StringUtils.trim(value.toString()), "\"", "\"\"") //$NON-NLS-1$ //$NON-NLS-2$
1✔
112
                    + "\""; //$NON-NLS-1$
113
        }
114

115
        return null;
×
116
    }
117

118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc