T
T
taylor962020-04-06 17:11:20
Java
taylor96, 2020-04-06 17:11:20

How to write quotes \" to excel file using CSVPrinter?

When writing a row to an excel file, I use CSVPrinter, respectively with the "EXCEL" format.

output = new OutputStreamWriter(
                    new FileOutputStream("so_spp_personorg_" + settings.getReplicaIdSpP().toLowerCase() + ".csv", true), "Windows-1251");
writers.add(writerSpPPersonOrg = new CSVPrinter(output, CSVFormat.EXCEL));

Some cells require quotation marks to be displayed.
When trying to write like this:
line = new StringBuilder("MigrationId=\"" + orgId + settings.getReplicaIdSpO() + "\"" + ";_;_;_;_; ;_;_;_;_;_;улица,");
row = line.toString().split(",");
writerSpOAddrdataOrgf.printRecord(row);

the quotes are displayed BUT the whole string ends up in one cell.
"MigrationId=\"" + orgId + settings.getReplicaIdSpO() + "\"" // Должно быть в одной ячейке

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Orkhan, 2020-04-06
@taylor96

Hello!
Here, your question is answered - https://stackoverflow.com/questions/31257529/inclu...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question