Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ public JRCsvExporter createExporter(ActionInvocation invocation, JasperPrint jas

SimpleCsvExporterConfiguration config = new SimpleCsvExporterConfiguration();
config.setFieldDelimiter(reportDelimiter);
config.setRecordDelimiter(reportDelimiter);
exporter.setConfiguration(config);

SimpleExporterInput input = new SimpleExporterInput(jasperPrint);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import jakarta.servlet.ServletException;
import net.sf.jasperreports.engine.JasperCompileManager;
import org.apache.struts2.ActionContext;
import org.apache.struts2.ActionInvocation;
import org.apache.struts2.junit.StrutsTestCase;
import org.apache.struts2.mock.MockActionInvocation;
import org.apache.struts2.security.NotExcludedAcceptedPatternsChecker;
Expand Down Expand Up @@ -244,6 +245,27 @@ public void testExportToCsv() throws Exception {
assertThat(response.getContentAsString()).contains("Qux Report");
}

public void testCsvRecordsAreSeparatedByNewlines() throws Exception {
// given
result.setDataSource("{#{'firstName':'Foo', 'lastName':'Bar'}, #{'firstName':'Baz', 'lastName':'Qux'}}");
result.setReportParameters("#{'title':'Qux'}");
result.setFormat(JasperReport7Constants.FORMAT_CSV);
invocation.setAction(new JasperReport7Aware() {
@Override
public String getCsvDelimiter(ActionInvocation invocation) {
return ";";
}
});

// when
result.execute(this.invocation);

// then
String csv = response.getContentAsString();
assertThat(csv).doesNotContain("Qux Report;Hello");
assertThat(csv.lines()).containsExactly("Qux Report", "Hello Foo Bar!", "Hello Baz Qux!");
}

public void testExportToRtf() throws Exception {
// given
result.setDataSource("{#{'firstName':'ignore', 'lastName':'ignore'}}");
Expand Down
Loading