@cj-tech-master/excelts 3.0.1-canary.20251229011802.ccfcbcc → 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.20251229011802.ccfcbcc
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
@@ -1675,6 +1675,27 @@ var ExcelTS = (function(exports) {
1675
1675
  });
1676
1676
  }
1677
1677
  /**
1678
+ * Get row values as a 0-based sparse array (column 1 => index 0).
1679
+ *
1680
+ * This is useful when you want to compare/stringify values without the
1681
+ * leading separator produced by the 1-based sparse array returned by `values`.
1682
+ */
1683
+ getValues() {
1684
+ const values = [];
1685
+ this._cells.forEach((cell) => {
1686
+ if (cell && cell.type !== Enums.ValueType.Null) values[cell.col - 1] = cell.value;
1687
+ });
1688
+ return values;
1689
+ }
1690
+ /**
1691
+ * Convenience stringification for row values.
1692
+ *
1693
+ * Equivalent to `row.getValues().join(separator)`.
1694
+ */
1695
+ valuesToString(separator = ",") {
1696
+ return this.getValues().join(separator);
1697
+ }
1698
+ /**
1678
1699
  * Returns true if the row includes at least one cell with a value
1679
1700
  */
1680
1701
  get hasValues() {
@@ -17094,9 +17115,32 @@ var ExcelTS = (function(exports) {
17094
17115
  }
17095
17116
  };
17096
17117
 
17118
+ //#endregion
17119
+ //#region src/csv/csv-number.ts
17120
+ function formatNumberForCsv(value, decimalSeparator) {
17121
+ if (decimalSeparator !== ",") return String(value);
17122
+ return String(value).split(".").join(",");
17123
+ }
17124
+ function parseNumberFromCsv(value, decimalSeparator) {
17125
+ if (decimalSeparator !== ",") return Number(value);
17126
+ const trimmed = value.trim();
17127
+ if (/^-?\d+(,\d+)?([eE][+-]?\d+)?$/.test(trimmed)) return Number(trimmed.replace(",", "."));
17128
+ return Number(value);
17129
+ }
17130
+
17097
17131
  //#endregion
17098
17132
  //#region src/csv/csv-core.ts
17099
17133
  /**
17134
+ * CSV Parser and Formatter - RFC 4180 compliant
17135
+ *
17136
+ * A lightweight, cross-platform CSV implementation that works in both
17137
+ * Node.js and Browser environments with zero dependencies.
17138
+ *
17139
+ * High-performance RFC 4180 compliant CSV parser and formatter.
17140
+ *
17141
+ * @see https://tools.ietf.org/html/rfc4180
17142
+ */
17143
+ /**
17100
17144
  * Escape special regex characters
17101
17145
  */
17102
17146
  function escapeRegex(str) {
@@ -17329,7 +17373,7 @@ var ExcelTS = (function(exports) {
17329
17373
  * Format data as a CSV string
17330
17374
  */
17331
17375
  function formatCsv(data, options = {}) {
17332
- 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;
17376
+ 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;
17333
17377
  const shouldWriteHeaders = writeHeadersOption ?? true;
17334
17378
  const quoteEnabled = quoteOption !== false && quoteOption !== null;
17335
17379
  const quote = quoteEnabled ? String(quoteOption) : "";
@@ -17344,7 +17388,7 @@ var ExcelTS = (function(exports) {
17344
17388
  };
17345
17389
  const formatField = (value, index, header, isHeader = false) => {
17346
17390
  if (value === null || value === void 0) return "";
17347
- const str = String(value);
17391
+ const str = typeof value === "number" ? formatNumberForCsv(value, decimalSeparator) : String(value);
17348
17392
  if (!quoteEnabled) return str;
17349
17393
  const forceQuote = alwaysQuote || shouldQuoteColumn(index, header, isHeader);
17350
17394
  const quoteRegex = /* @__PURE__ */ new RegExp(`[${escapeRegex(delimiter)}${escapeRegex(quote)}\r\n]`);
@@ -17412,11 +17456,12 @@ var ExcelTS = (function(exports) {
17412
17456
  /**
17413
17457
  * Create the default value mapper for CSV parsing
17414
17458
  */
17415
- function createDefaultValueMapper(dateFormats) {
17459
+ function createDefaultValueMapper(dateFormats, parserOptions) {
17416
17460
  const dateParser = DateParser.create(dateFormats);
17461
+ const decimalSeparator = parserOptions?.decimalSeparator ?? ".";
17417
17462
  return function mapValue(datum) {
17418
17463
  if (datum === "") return null;
17419
- const datumNumber = Number(datum);
17464
+ const datumNumber = typeof datum === "string" ? parseNumberFromCsv(datum, decimalSeparator) : Number(datum);
17420
17465
  if (!Number.isNaN(datumNumber) && datumNumber !== Infinity) return datumNumber;
17421
17466
  const date = dateParser.parse(datum);
17422
17467
  if (date) return date;
@@ -17451,9 +17496,9 @@ var ExcelTS = (function(exports) {
17451
17496
  "YYYY-MM-DD[T]HH:mm:ss",
17452
17497
  "YYYY-MM-DD"
17453
17498
  ];
17454
- const map = options.map || createDefaultValueMapper(dateFormats);
17499
+ const effectiveMap = options.map || createDefaultValueMapper(dateFormats, options.parserOptions);
17455
17500
  const rows = parseCsv(content, options.parserOptions);
17456
- for (const row of rows) worksheet.addRow(row.map(map));
17501
+ for (const row of rows) worksheet.addRow(row.map(effectiveMap));
17457
17502
  return worksheet;
17458
17503
  }
17459
17504
  /**