@niicojs/excel 0.2.2 → 0.2.3
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.
- package/README.md +145 -1
- package/dist/index.cjs +96 -0
- package/dist/index.d.cts +57 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts +57 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +96 -0
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/types.ts +39 -0
- package/src/worksheet.ts +112 -1
package/dist/index.d.ts
CHANGED
|
@@ -168,6 +168,39 @@ interface RichCellValue {
|
|
|
168
168
|
/** Cell style */
|
|
169
169
|
style?: CellStyle;
|
|
170
170
|
}
|
|
171
|
+
/**
|
|
172
|
+
* Configuration for converting a sheet to JSON objects.
|
|
173
|
+
*/
|
|
174
|
+
interface SheetToJsonConfig {
|
|
175
|
+
/**
|
|
176
|
+
* Field names to use for each column.
|
|
177
|
+
* If provided, the first row of data starts at row 1 (or startRow).
|
|
178
|
+
* If not provided, the first row is used as field names.
|
|
179
|
+
*/
|
|
180
|
+
fields?: string[];
|
|
181
|
+
/**
|
|
182
|
+
* Starting row (0-based). Defaults to 0.
|
|
183
|
+
* If fields are not provided, this row contains the headers.
|
|
184
|
+
* If fields are provided, this is the first data row.
|
|
185
|
+
*/
|
|
186
|
+
startRow?: number;
|
|
187
|
+
/**
|
|
188
|
+
* Starting column (0-based). Defaults to 0.
|
|
189
|
+
*/
|
|
190
|
+
startCol?: number;
|
|
191
|
+
/**
|
|
192
|
+
* Ending row (0-based, inclusive). Defaults to the last row with data.
|
|
193
|
+
*/
|
|
194
|
+
endRow?: number;
|
|
195
|
+
/**
|
|
196
|
+
* Ending column (0-based, inclusive). Defaults to the last column with data.
|
|
197
|
+
*/
|
|
198
|
+
endCol?: number;
|
|
199
|
+
/**
|
|
200
|
+
* If true, stop reading when an empty row is encountered. Defaults to true.
|
|
201
|
+
*/
|
|
202
|
+
stopOnEmptyRow?: boolean;
|
|
203
|
+
}
|
|
171
204
|
|
|
172
205
|
/**
|
|
173
206
|
* Represents a single cell in a worksheet
|
|
@@ -377,6 +410,29 @@ declare class Worksheet {
|
|
|
377
410
|
* Get all cells in the worksheet
|
|
378
411
|
*/
|
|
379
412
|
get cells(): Map<string, Cell>;
|
|
413
|
+
/**
|
|
414
|
+
* Convert sheet data to an array of JSON objects.
|
|
415
|
+
*
|
|
416
|
+
* @param config - Configuration options
|
|
417
|
+
* @returns Array of objects where keys are field names and values are cell values
|
|
418
|
+
*
|
|
419
|
+
* @example
|
|
420
|
+
* ```typescript
|
|
421
|
+
* // Using first row as headers
|
|
422
|
+
* const data = sheet.toJson();
|
|
423
|
+
*
|
|
424
|
+
* // Using custom field names
|
|
425
|
+
* const data = sheet.toJson({ fields: ['name', 'age', 'city'] });
|
|
426
|
+
*
|
|
427
|
+
* // Starting from a specific row/column
|
|
428
|
+
* const data = sheet.toJson({ startRow: 2, startCol: 1 });
|
|
429
|
+
* ```
|
|
430
|
+
*/
|
|
431
|
+
toJson<T = Record<string, CellValue>>(config?: SheetToJsonConfig): T[];
|
|
432
|
+
/**
|
|
433
|
+
* Get the bounds of data in the sheet (min/max row and column with data)
|
|
434
|
+
*/
|
|
435
|
+
private _getDataBounds;
|
|
380
436
|
/**
|
|
381
437
|
* Generate XML for this worksheet
|
|
382
438
|
*/
|
|
@@ -836,5 +892,5 @@ declare const parseRange: (range: string) => RangeAddress;
|
|
|
836
892
|
declare const toRange: (range: RangeAddress) => string;
|
|
837
893
|
|
|
838
894
|
export { Cell, PivotCache, PivotTable, Range, SharedStrings, Styles, Workbook, Worksheet, parseAddress, parseRange, toAddress, toRange };
|
|
839
|
-
export type { AggregationType, Alignment, BorderStyle, BorderType, CellAddress, CellError, CellStyle, CellType, CellValue, ColumnConfig, ErrorType, PivotFieldAxis, PivotTableConfig, PivotValueConfig, RangeAddress, RichCellValue, SheetFromDataConfig };
|
|
895
|
+
export type { AggregationType, Alignment, BorderStyle, BorderType, CellAddress, CellError, CellStyle, CellType, CellValue, ColumnConfig, ErrorType, PivotFieldAxis, PivotTableConfig, PivotValueConfig, RangeAddress, RichCellValue, SheetFromDataConfig, SheetToJsonConfig };
|
|
840
896
|
//# sourceMappingURL=index.d.ts.map
|