mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CE-881 fix how booleans are written; after profiling, replace regex for cleansing test w/ indexOf calls
This commit is contained in:
@ -24,7 +24,6 @@ package com.kingsrook.qqq.backend.core.actions.reporting.excel.poi;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.apache.poi.ss.util.CellReference;
|
import org.apache.poi.ss.util.CellReference;
|
||||||
|
|
||||||
|
|
||||||
@ -34,8 +33,6 @@ import org.apache.poi.ss.util.CellReference;
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public class StreamedPoiSheetWriter
|
public class StreamedPoiSheetWriter
|
||||||
{
|
{
|
||||||
private static Pattern xmlSpecialChars = Pattern.compile(".*[&<>'\"].*");
|
|
||||||
|
|
||||||
private final Writer writer;
|
private final Writer writer;
|
||||||
private int rowNo;
|
private int rowNo;
|
||||||
|
|
||||||
@ -111,8 +108,11 @@ public class StreamedPoiSheetWriter
|
|||||||
{
|
{
|
||||||
writer.write(" s=\"" + styleIndex + "\"");
|
writer.write(" s=\"" + styleIndex + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String cleanValue = cleanseValue(value);
|
||||||
|
|
||||||
writer.write(">");
|
writer.write(">");
|
||||||
writer.write("<is><t>" + cleanseValue(value) + "</t></is>");
|
writer.write("<is><t>" + cleanValue + "</t></is>");
|
||||||
writer.write("</c>");
|
writer.write("</c>");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,8 +123,9 @@ public class StreamedPoiSheetWriter
|
|||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static String cleanseValue(String value)
|
public static String cleanseValue(String value)
|
||||||
{
|
{
|
||||||
// todo - profile...
|
if(value != null)
|
||||||
if(xmlSpecialChars.matcher(value).find())
|
{
|
||||||
|
if(value.indexOf('&') > -1 || value.indexOf('<') > -1 || value.indexOf('>') > -1 || value.indexOf('\'') > -1 || value.indexOf('"') > -1)
|
||||||
{
|
{
|
||||||
value = value.replace("&", "&");
|
value = value.replace("&", "&");
|
||||||
value = value.replace("<", "<");
|
value = value.replace("<", "<");
|
||||||
@ -132,6 +133,8 @@ public class StreamedPoiSheetWriter
|
|||||||
value = value.replace("'", "'");
|
value = value.replace("'", "'");
|
||||||
value = value.replace("\"", """);
|
value = value.replace("\"", """);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (value);
|
return (value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -191,13 +194,16 @@ public class StreamedPoiSheetWriter
|
|||||||
public void createCell(int columnIndex, Boolean value, int styleIndex) throws IOException
|
public void createCell(int columnIndex, Boolean value, int styleIndex) throws IOException
|
||||||
{
|
{
|
||||||
String ref = new CellReference(rowNo, columnIndex).formatAsString();
|
String ref = new CellReference(rowNo, columnIndex).formatAsString();
|
||||||
writer.write("<c r=\"" + ref + "\" t=\"n\"");
|
writer.write("<c r=\"" + ref + "\" t=\"b\"");
|
||||||
if(styleIndex != -1)
|
if(styleIndex != -1)
|
||||||
{
|
{
|
||||||
writer.write(" s=\"" + styleIndex + "\"");
|
writer.write(" s=\"" + styleIndex + "\"");
|
||||||
}
|
}
|
||||||
writer.write(">");
|
writer.write(">");
|
||||||
writer.write("<v>" + value + "</v>");
|
if(value != null)
|
||||||
|
{
|
||||||
|
writer.write("<v>" + (value ? 1 : 0) + "</v>");
|
||||||
|
}
|
||||||
writer.write("</c>");
|
writer.write("</c>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user