fpspreadsheet: Support the csv reader/writer options IgnoreOuterWhiteSpace and QuoteOuterWhiteSpace (see https://forum.lazarus.freepascal.org/index.php/topic,62151.0.html)

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@8696 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2023-02-07 16:54:19 +00:00
parent 7561497ce3
commit 7905e5a72e
2 changed files with 8 additions and 0 deletions

View File

@ -187,6 +187,7 @@ begin
Parser.Delimiter := CSVParams.Delimiter; Parser.Delimiter := CSVParams.Delimiter;
Parser.LineEnding := LineEndingAsString(CSVParams.LineEnding); Parser.LineEnding := LineEndingAsString(CSVParams.LineEnding);
Parser.QuoteChar := CSVParams.QuoteChar; Parser.QuoteChar := CSVParams.QuoteChar;
Parser.IgnoreOuterWhiteSpace := CSVParams.IgnoreOuterWhiteSpace;
// Indicate column counts between rows may differ: // Indicate column counts between rows may differ:
Parser.EqualColCountPerRow := false; Parser.EqualColCountPerRow := false;
Parser.SetSource(AStream); Parser.SetSource(AStream);
@ -345,6 +346,7 @@ begin
FCSVBuilder.Delimiter := CSVParams.Delimiter; FCSVBuilder.Delimiter := CSVParams.Delimiter;
FCSVBuilder.LineEnding := LineEndingAsString(CSVParams.LineEnding); FCSVBuilder.LineEnding := LineEndingAsString(CSVParams.LineEnding);
FCSVBuilder.QuoteChar := CSVParams.QuoteChar; FCSVBuilder.QuoteChar := CSVParams.QuoteChar;
FCSVBuilder.IgnoreOuterWhiteSpace := CSVParams.IgnoreOuterWhiteSpace;
FCSVBuilder.SetOutput(AStream); FCSVBuilder.SetOutput(AStream);
n := sheet.GetCellCount; n := sheet.GetCellCount;

View File

@ -92,6 +92,8 @@ type
@member LineEnding Specification for the line endings to be written (write-only) @member LineEnding Specification for the line endings to be written (write-only)
@member Delimiter Column delimiter (read/write) @member Delimiter Column delimiter (read/write)
@member QuoteChar Character used for quoting text in special cases (read/write) @member QuoteChar Character used for quoting text in special cases (read/write)
@member QuoteOuterWhiteSpace ...Determines whether cell content beginning/ending with white space will be quoted (write-only)
@member IgnoreOuterWhiteSpace...Ignores white space before/after cell content (read-only)
@member Encoding String identifying the endoding of the file, such as 'utf8', 'cp1252' etc (read/write) @member Encoding String identifying the endoding of the file, such as 'utf8', 'cp1252' etc (read/write)
@member DetectContentType Try to convert strings to their content type (read-only) @member DetectContentType Try to convert strings to their content type (read-only)
@member NumberFormat If empty numbers are written like in worksheet, otherwise this format string is applied (write-only) @member NumberFormat If empty numbers are written like in worksheet, otherwise this format string is applied (write-only)
@ -104,6 +106,8 @@ type
LineEnding: TsCSVLineEnding; // W: Specification for line ending to be written LineEnding: TsCSVLineEnding; // W: Specification for line ending to be written
Delimiter: Char; // RW: Column delimiter Delimiter: Char; // RW: Column delimiter
QuoteChar: Char; // RW: Character for quoting texts QuoteChar: Char; // RW: Character for quoting texts
QuoteOuterWhiteSpace: Boolean; // W: Quote when cell content begins/ends with white space.
IgnoreOuterWhiteSpace: Boolean; // R: Ignores white space before/after cell content.
Encoding: String; // RW: Encoding of file (code page, such as "utf8", "cp1252" etc) Encoding: String; // RW: Encoding of file (code page, such as "utf8", "cp1252" etc)
DetectContentType: Boolean; // R: try to convert strings to content types DetectContentType: Boolean; // R: try to convert strings to content types
NumberFormat: String; // W: if empty write numbers like in sheet, otherwise use this format NumberFormat: String; // W: if empty write numbers like in sheet, otherwise use this format
@ -203,6 +207,8 @@ var
LineEnding: leSystem; LineEnding: leSystem;
Delimiter: ';'; Delimiter: ';';
QuoteChar: '"'; QuoteChar: '"';
QuoteOuterWhiteSpace: true;
IgnoreOuterWhiteSpace: false;
Encoding: ''; // '' = auto-detect when reading, UTF8 when writing Encoding: ''; // '' = auto-detect when reading, UTF8 when writing
DetectContentType: true; DetectContentType: true;
NumberFormat: ''; NumberFormat: '';