OP-1084 Make CSV export an RFC-4180 open format and offer it in the export dialog - #1617
Open
giuseppesorge wants to merge 1 commit into
Open
OP-1084 Make CSV export an RFC-4180 open format and offer it in the export dialog#1617giuseppesorge wants to merge 1 commit into
giuseppesorge wants to merge 1 commit into
Conversation
…xport dialog Harden the three CSV writers in ExcelExporter to produce RFC-4180 output: quote/escape fields that contain the separator, a double quote or a line break; consistent UTF-8 BOM; CRLF row terminator. Fix latent bugs along the way - the resultset writer dropped the separator before the last column and emitted a trailing one, and exportDataToCSV wrote with the platform default charset and a trailing separator. Integral ids/counts are no longer run through locale grouping (e.g. 12345, not 12,345). Add a 'CSV - open format' filter to the export file chooser (selected by default) and disable the accept-all filter; add exportTable/exportResultset dispatch helpers that pick the format from the file extension. JasperReportsManager now delegates report export to exportResultset, which also handles .csv. Strengthen TestExcelExporter with content/format assertions (BOM, separator, RFC-4180 quoting, no trailing separator, extension dispatch).
Contributor
Author
|
Related PRs (same branch
JIRA: https://openhospital.atlassian.net/browse/OP-1084 @dbmalkovsky one design call I'd like your steer on: I set the CSV ("open format") filter as the default in the export Save dialog (Excel stays available), since that matches the GDPR open-format intent of the ticket. If you'd rather keep Excel as the default with CSV merely offered, it's a one-line change — happy to flip it either way. |
This was referenced Jun 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OP-1084 — Export to an open file format (CSV)
JIRA: https://openhospital.atlassian.net/browse/OP-1084
Problem
Every user-facing data export currently produces only a proprietary Microsoft format (
.xlsxvia POI XSSF, or.xlsvia HSSF). The shared export file chooser (ExcelExporter.getJFileChooserExcel) offered no open format. The class already contained threeexportToCSVmethods, but they were unused/unwired and not RFC 4180 compliant:;,"or a line break corrupted the file;exportDataToCSVusednew FileWriter(...)(platform default charset);exportDataToCSVemitted a trailing separator on every row.Change (core)
escapeCSV(quote a field that contains the separator, a", CR or LF; double any embedded"), sharedwriteCSVRow/formatValue, consistent UTF-8 with BOM, CRLF row terminator. Integral ids/counts are emitted verbatim (no locale grouping, so a code12345stays12345, not12,345); decimals use the locale format with grouping disabled.CSV - open format (*.csv)filter togetJFileChooserExcel, selected by default, and disabled the accept-all filter (this also removes a latentClassCastExceptionon the(FileNameExtensionFilter) getFileFilter()cast used by the report exporters).exportTable(JTable, File[, int])andexportResultset(ResultSet, File)that select the format from the file extension.JasperReportsManagernow delegates its six report-export branches toexportResultset(which also handles.csv).TestExcelExporterwith content/format assertions (BOM, separator, RFC 4180 quoting, no trailing separator, extension dispatch).Notes for review
setFileFilter(csvFilter)→excelFilter) if you would rather Excel stayed the default with CSV merely available.java.sql.Date.toString()), which is more interoperable than thedd/MM/yyyyused for timestamps; not changed here to keep the diff focused.Verification
TestExcelExporter12/12 andstat.Tests4/4 green; companion GUImvn packagegreen.;-separated, with no trailing separator, integer codes without grouping, special characters preserved, and fields quoted only when needed.