homena / jmesa

Automatically exported from code.google.com/p/jmesa
0 stars 0 forks source link

escape double-quote in csv export please #262

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
see http://www.rfc-editor.org/rfc/rfc4180.txt
page 2, paragraph 7

Original issue reported on code.google.com by stas.agarkov on 11 May 2010 at 7:10

GoogleCodeExporter commented 9 years ago
Good point. I did not know there were any requirements beyond just being 
separated by
a comma! Are you running into an issue with this right now?

Original comment by jeff.johnston.mn@gmail.com on 12 May 2010 at 2:40

GoogleCodeExporter commented 9 years ago
I have write own CsvCellRenderer, where for the content of the cell call 
StringEscapeUtils.escapeCsv from org.apache.commons.lang package, and then put 
in 
the beginning and end of quotes.

Original comment by stas.agarkov on 12 May 2010 at 10:08

GoogleCodeExporter commented 9 years ago
Can you send those changes to me? Sounds like a great improvement!

If so send them to jeff.johnston.mn@gmail.com and I will include it in the next 
release.

Original comment by jeff.johnston.mn@gmail.com on 12 May 2010 at 1:06

GoogleCodeExporter commented 9 years ago
public class RfcCsvCellRendererImpl
    extends CsvCellRendererImpl {

    public RfcCsvCellRendererImpl(Column column, CellEditor cellEditor) {
        super(column, cellEditor);
    }

    @Override
    public Object render(Object item, int rowcount) {
        StringBuilder data = new StringBuilder();

        String property = getColumn().getProperty();

        Object value = getCellEditor().getValue(item, property, rowcount);
        String stringValue = StringEscapeUtils.escapeCsv(value.toString());
        data.append(stringValue);
        data.append(getDelimiter());

        return data.toString();
    }
}

but you need to check not put it StringEscapeUtils quotes. if you put, then 
their 
second set did not need.

Original comment by stas.agarkov on 13 May 2010 at 5:49

GoogleCodeExporter commented 9 years ago
Putting the value in quotes is now being done by default.

Original comment by jeff.johnston.mn@gmail.com on 10 Mar 2011 at 9:24