From 3aa712c32b129af024c9d1107d0c83b8df58517b Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Tue, 6 Apr 2021 06:11:01 +0000 Subject: [PATCH] XSLX2CSV: Do not double-encode if the value is already having quotes and escape double-quotes Most CSV formats use "" (two quotes) to escape a "-character, we should do this in this example as well to produce files that can be parsed by other CSV processors correctly. Also cases where the value is already enclosed in quotes should not lead to additional quotes Add a simple initial test to module "examples" verify basic functionality of XSLX2CSV as I often rely on it for converting some very large xlsx-files to csv git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1888418 13f79535-47bb-0310-9956-ffa450edef68 --- examples/build.gradle | 3 +++ .../examples/xssf/eventusermodel/XLSX2CSV.java | 14 +++++++++++++- ooxml/build.gradle | 18 ++++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/examples/build.gradle b/examples/build.gradle index 559dd449cc..15ab280aa1 100644 --- a/examples/build.gradle +++ b/examples/build.gradle @@ -20,4 +20,7 @@ dependencies { implementation project(':scratchpad') implementation "org.apache.logging.log4j:log4j-core:${log4jVersion}" + + testImplementation project(path: ':ooxml', configuration: 'tests') + testImplementation project(path: ':main', configuration: 'tests') } diff --git a/examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java b/examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java index 627e0f7fb5..81235f0ef5 100644 --- a/examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java +++ b/examples/src/main/java/org/apache/poi/examples/xssf/eventusermodel/XLSX2CSV.java @@ -128,6 +128,12 @@ public class XLSX2CSV { for (int i=0; i