excel2json init

This commit is contained in:
lirui
2026-02-09 20:08:26 +08:00
commit 36f5d247b1
37 changed files with 4046 additions and 0 deletions

35
src/lib/types.ts Normal file
View File

@@ -0,0 +1,35 @@
export type DataType = 'string' | 'number' | 'boolean' | 'date';
export type DateFormat =
| 'YYYY-MM-DD'
| 'YYYY/MM/DD'
| 'YYYY-MM-DD HH:mm'
| 'YYYY/MM/DD HH:mm'
| 'YYYY-MM-DD HH:mm:ss'
| 'timestamp';
export interface MappingConfig {
/** Excel original header name (read-only) */
source: string;
/** Target key name in JSON output */
target: string;
/** Data type for conversion */
type: DataType;
/** Date format string (only used when type is 'date') */
format?: DateFormat;
/** If true, exclude this key from JSON when cell is empty */
excludeIfEmpty: boolean;
/** Default value when cell is empty and excludeIfEmpty is false */
defaultValue?: string;
/** Whether this column is included in output */
enabled: boolean;
}
/** A single row of raw Excel data, keyed by original header */
export type RowData = Record<string, unknown>;
/** Template file structure for import/export */
export type MappingTemplate = Pick<
MappingConfig,
'source' | 'target' | 'type' | 'format' | 'excludeIfEmpty' | 'defaultValue'
>[];