@cj-tech-master/excelts 3.0.1-canary.20251230172852.9dca08f → 3.0.1-canary.20251230173853.c3c79fa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @cj-tech-master/excelts v3.0.1-canary.20251230172852.9dca08f
2
+ * @cj-tech-master/excelts v3.0.1-canary.20251230173853.c3c79fa
3
3
  * TypeScript Excel Workbook Manager - Read and Write xlsx and csv Files.
4
4
  * (c) 2025 cjnoname
5
5
  * Released under the MIT License
@@ -17112,9 +17112,32 @@ var DateFormatter = class DateFormatter {
17112
17112
  }
17113
17113
  };
17114
17114
 
17115
+ //#endregion
17116
+ //#region src/csv/csv-number.ts
17117
+ function formatNumberForCsv(value, decimalSeparator) {
17118
+ if (decimalSeparator !== ",") return String(value);
17119
+ return String(value).split(".").join(",");
17120
+ }
17121
+ function parseNumberFromCsv(value, decimalSeparator) {
17122
+ if (decimalSeparator !== ",") return Number(value);
17123
+ const trimmed = value.trim();
17124
+ if (/^-?\d+(,\d+)?([eE][+-]?\d+)?$/.test(trimmed)) return Number(trimmed.replace(",", "."));
17125
+ return Number(value);
17126
+ }
17127
+
17115
17128
  //#endregion
17116
17129
  //#region src/csv/csv-core.ts
17117
17130
  /**
17131
+ * CSV Parser and Formatter - RFC 4180 compliant
17132
+ *
17133
+ * A lightweight, cross-platform CSV implementation that works in both
17134
+ * Node.js and Browser environments with zero dependencies.
17135
+ *
17136
+ * High-performance RFC 4180 compliant CSV parser and formatter.
17137
+ *
17138
+ * @see https://tools.ietf.org/html/rfc4180
17139
+ */
17140
+ /**
17118
17141
  * Escape special regex characters
17119
17142
  */
17120
17143
  function escapeRegex(str) {
@@ -17347,7 +17370,7 @@ function parseCsv(input, options = {}) {
17347
17370
  * Format data as a CSV string
17348
17371
  */
17349
17372
  function formatCsv(data, options = {}) {
17350
- const { delimiter = ",", quote: quoteOption = "\"", escape: escapeOption, rowDelimiter = "\n", alwaysQuote = false, quoteColumns = false, quoteHeaders = false, headers, writeHeaders: writeHeadersOption, writeBOM = false, includeEndRowDelimiter = false, alwaysWriteHeaders = false, transform } = options;
17373
+ const { delimiter = ",", quote: quoteOption = "\"", escape: escapeOption, rowDelimiter = "\n", alwaysQuote = false, quoteColumns = false, quoteHeaders = false, headers, writeHeaders: writeHeadersOption, writeBOM = false, includeEndRowDelimiter = false, alwaysWriteHeaders = false, transform, decimalSeparator = "." } = options;
17351
17374
  const shouldWriteHeaders = writeHeadersOption ?? true;
17352
17375
  const quoteEnabled = quoteOption !== false && quoteOption !== null;
17353
17376
  const quote = quoteEnabled ? String(quoteOption) : "";
@@ -17362,7 +17385,7 @@ function formatCsv(data, options = {}) {
17362
17385
  };
17363
17386
  const formatField = (value, index, header, isHeader = false) => {
17364
17387
  if (value === null || value === void 0) return "";
17365
- const str = String(value);
17388
+ const str = typeof value === "number" ? formatNumberForCsv(value, decimalSeparator) : String(value);
17366
17389
  if (!quoteEnabled) return str;
17367
17390
  const forceQuote = alwaysQuote || shouldQuoteColumn(index, header, isHeader);
17368
17391
  const quoteRegex = /* @__PURE__ */ new RegExp(`[${escapeRegex(delimiter)}${escapeRegex(quote)}\r\n]`);
@@ -17430,11 +17453,12 @@ const SpecialValues = {
17430
17453
  /**
17431
17454
  * Create the default value mapper for CSV parsing
17432
17455
  */
17433
- function createDefaultValueMapper(dateFormats) {
17456
+ function createDefaultValueMapper(dateFormats, parserOptions) {
17434
17457
  const dateParser = DateParser.create(dateFormats);
17458
+ const decimalSeparator = parserOptions?.decimalSeparator ?? ".";
17435
17459
  return function mapValue(datum) {
17436
17460
  if (datum === "") return null;
17437
- const datumNumber = Number(datum);
17461
+ const datumNumber = typeof datum === "string" ? parseNumberFromCsv(datum, decimalSeparator) : Number(datum);
17438
17462
  if (!Number.isNaN(datumNumber) && datumNumber !== Infinity) return datumNumber;
17439
17463
  const date = dateParser.parse(datum);
17440
17464
  if (date) return date;
@@ -17469,9 +17493,9 @@ function parseCsvToWorksheet(content, workbook, options = {}) {
17469
17493
  "YYYY-MM-DD[T]HH:mm:ss",
17470
17494
  "YYYY-MM-DD"
17471
17495
  ];
17472
- const map = options.map || createDefaultValueMapper(dateFormats);
17496
+ const effectiveMap = options.map || createDefaultValueMapper(dateFormats, options.parserOptions);
17473
17497
  const rows = parseCsv(content, options.parserOptions);
17474
- for (const row of rows) worksheet.addRow(row.map(map));
17498
+ for (const row of rows) worksheet.addRow(row.map(effectiveMap));
17475
17499
  return worksheet;
17476
17500
  }
17477
17501
  /**