fpspreadsheet: Avoid having unit fpCSV in the uses list of fpspreadsheetctrls because this would register the CSV reader.

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@7998 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
wp_xxyyzz
2021-04-16 11:20:05 +00:00
parent 00c3bdb639
commit 3fc88c42b6
3 changed files with 44 additions and 30 deletions

View File

@ -56,36 +56,7 @@ type
procedure WriteToStrings(AStrings: TStrings; AParams: TsStreamParams = []); override; procedure WriteToStrings(AStrings: TStrings; AParams: TsStreamParams = []); override;
end; end;
TsCSVLineEnding = (leSystem, leCRLF, leCR, leLF);
TsCSVParams = record // W = writing, R = reading, RW = reading/writing
SheetIndex: Integer; // W: Index of the sheet to be written
LineEnding: TsCSVLineEnding; // W: Specification for line ending to be written
Delimiter: Char; // RW: Column delimiter
QuoteChar: Char; // RW: Character for quoting texts
Encoding: String; // RW: Encoding of file (code page, such as "utf8", "cp1252" etc)
DetectContentType: Boolean; // R: try to convert strings to content types
NumberFormat: String; // W: if empty write numbers like in sheet, otherwise use this format
AutoDetectNumberFormat: Boolean; // R: automatically detects decimal/thousand separator used in numbers
TrueText: String; // RW: String for boolean TRUE
FalseText: String; // RW: String for boolean FALSE
FormatSettings: TFormatSettings; // RW: add'l parameters for conversion
end;
var var
CSVParams: TsCSVParams = (
SheetIndex: 0;
LineEnding: leSystem;
Delimiter: ';';
QuoteChar: '"';
Encoding: ''; // '' = auto-detect when reading, UTF8 when writing
DetectContentType: true;
NumberFormat: '';
AutoDetectNumberFormat: true;
TrueText: 'TRUE';
FalseText: 'FALSE';
{%H-});
sfidCSV: TsSpreadFormatID; sfidCSV: TsSpreadFormatID;
function LineEndingAsString(ALineEnding: TsCSVLineEnding): String; function LineEndingAsString(ALineEnding: TsCSVLineEnding): String;

View File

@ -84,6 +84,36 @@ type
MaxCharsInTextCell: Integer; MaxCharsInTextCell: Integer;
end; end;
{@@ Line ending used in CSV files }
TsCSVLineEnding = (leSystem, leCRLF, leCR, leLF);
{@@ Parameters controlling reading from and writing to CSV files
@member SheetIndex Index of the sheet to be written (write-only)
@member LineEnding Specification for the line endings to be written (write-only)
@member Delimiter Column delimiter (read/write)
@member QuoteChar Character used for quoting text in special cases (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 NumberFormat If empty numbers are written like in worksheet, otherwise this format string is applied (write-only)
@member AutoDetectNumberFormat Try to detect the decimal and thousand separator used in numbers (read-only)
@member TrueText String for boolean @true (read/write)
@member FalseText String for boolean @false (read/write)
@member FormatSettings Additional parameter for string conversion (read/write) }
TsCSVParams = record // W = writing, R = reading, RW = reading/writing
SheetIndex: Integer; // W: Index of the sheet to be written
LineEnding: TsCSVLineEnding; // W: Specification for line ending to be written
Delimiter: Char; // RW: Column delimiter
QuoteChar: Char; // RW: Character for quoting texts
Encoding: String; // RW: Encoding of file (code page, such as "utf8", "cp1252" etc)
DetectContentType: Boolean; // R: try to convert strings to content types
NumberFormat: String; // W: if empty write numbers like in sheet, otherwise use this format
AutoDetectNumberFormat: Boolean; // R: automatically detects decimal/thousand separator used in numbers
TrueText: String; // RW: String for boolean TRUE
FalseText: String; // RW: String for boolean FALSE
FormatSettings: TFormatSettings; // RW: add'l parameters for conversion
end;
const const
{@@ Explanatory name of sfBiff2 file format } {@@ Explanatory name of sfBiff2 file format }
STR_FILEFORMAT_EXCEL_2 = 'Excel 2.1'; STR_FILEFORMAT_EXCEL_2 = 'Excel 2.1';
@ -163,6 +193,19 @@ const
unique value simplifies many things... } unique value simplifies many things... }
FPS_LINE_ENDING = #10; FPS_LINE_ENDING = #10;
var
CSVParams: TsCSVParams = (
SheetIndex: 0;
LineEnding: leSystem;
Delimiter: ';';
QuoteChar: '"';
Encoding: ''; // '' = auto-detect when reading, UTF8 when writing
DetectContentType: true;
NumberFormat: '';
AutoDetectNumberFormat: true;
TrueText: 'TRUE';
FalseText: 'FALSE';
{%H-});
type type
{@@ Units for size dimensions {@@ Units for size dimensions

View File

@ -709,7 +709,7 @@ uses
Types, Math, StrUtils, TypInfo, LCLType, LCLIntf, LCLProc, Types, Math, StrUtils, TypInfo, LCLType, LCLIntf, LCLProc,
Dialogs, Forms, Clipbrd, Dialogs, Forms, Clipbrd,
fpsStrings, fpsCrypto, fpsReaderWriter, fpsUtils, fpsNumFormat, fpsImages, fpsStrings, fpsCrypto, fpsReaderWriter, fpsUtils, fpsNumFormat, fpsImages,
fpsHTMLUtils, fpsCSV, fpsExprParser, fpsConditionalFormat; fpsHTMLUtils, fpsExprParser, fpsConditionalFormat;
var var
cfBiff8Format: Integer = 0; cfBiff8Format: Integer = 0;