@@ -99,10 +99,13 @@ const driver = new ExcelDriver({
9999
100100## How It Works
101101
102- ### Data Storage
102+ ### Data Storage Format
103103
104+ ** Important** : The Excel file must follow this structure:
105+
106+ - ** One file** contains multiple worksheets
104107- ** Each worksheet = One object type** (e.g., ` users ` , ` products ` )
105- - ** First row = Column headers** (field names)
108+ - ** First row = Column headers** (field names like ` id ` , ` name ` , ` email ` )
106109- ** Subsequent rows = Data records**
107110
108111Example Excel structure:
@@ -113,13 +116,45 @@ Example Excel structure:
113116| user-1 | Alice | alice@example.com | admin | 2024-01-01T00:00:00Z |
114117| user-2 | Bob | bob@example.com | user | 2024-01-02T00:00:00Z |
115118
119+ ** Sheet: products**
120+ | id | name | price | category |
121+ | ----| ------| -------| ----------|
122+ | prod-1 | Laptop | 999.99 | Electronics |
123+
116124### Workflow
117125
1181261 . ** Load** : Reads Excel file into memory on initialization
1191272 . ** Query** : Performs operations in-memory (fast!)
1201283 . ** Persist** : Writes changes back to Excel file
1211294 . ** Auto-save** : Enabled by default for data safety
122130
131+ ### Error Handling
132+
133+ The driver provides clear error messages for common issues:
134+
135+ ** Corrupted or Invalid Files:**
136+ ```
137+ Failed to read Excel file - File may be corrupted or not a valid .xlsx file
138+ ```
139+
140+ ** File Format Issues:**
141+ - Missing headers: Worksheets without headers in the first row are skipped with a warning
142+ - Empty rows: Completely empty rows are automatically skipped
143+ - Missing ID field: IDs are auto-generated if not present
144+
145+ ** File Access Issues:**
146+ ```
147+ Failed to read Excel file - Permission denied. Check file permissions.
148+ Failed to read Excel file - File is locked by another process. Close it and try again.
149+ ```
150+
151+ ** Data Format Mismatch:**
152+ If an existing Excel file doesn't match the expected format (no headers, wrong structure), the driver will:
153+ 1 . Log a warning to the console
154+ 2 . Skip problematic worksheets
155+ 3 . Continue loading valid worksheets
156+ 4 . You can check console output for warnings about skipped data
157+
123158## API Reference
124159
125160### CRUD Operations
@@ -339,6 +374,38 @@ for (const record of records) {
339374- ** File locking** : Not suitable for concurrent multi-process writes
340375- ** Performance** : Slower than dedicated databases for large datasets
341376- ** Query optimization** : No indexes or query optimization
377+ - ** File format** : Only supports .xlsx format (Excel 2007+), not .xls (Excel 97-2003)
378+
379+ ## Data Format Requirements
380+
381+ To ensure proper operation, Excel files must follow these requirements:
382+
383+ ### File Structure
384+ ✅ ** Valid .xlsx file** (Excel 2007+ format)
385+ ✅ ** First row contains headers** (column names)
386+ ✅ ** One worksheet per object type**
387+ ✅ ** Consistent column structure** within each worksheet
388+
389+ ### Common Issues and Solutions
390+
391+ | Issue | Symptom | Solution |
392+ | -------| ---------| ----------|
393+ | Corrupted file | ` FILE_READ_ERROR: File may be corrupted ` | Open in Excel, save as new .xlsx file, or restore from backup |
394+ | No headers | Warning: ` Worksheet has no headers ` | Add column names in first row (id, name, email, etc.) |
395+ | File locked | ` File is locked by another process ` | Close the file in Excel or other applications |
396+ | Permission denied | ` Permission denied ` | Check file permissions, run with appropriate access rights |
397+ | Wrong format | Data not loading | Ensure first row has headers, data starts from row 2 |
398+ | Empty rows | Rows skipped | Empty rows are automatically ignored, check console warnings |
399+
400+ ### Validating Your Excel File
401+
402+ Before using an Excel file with the driver:
403+
404+ 1 . ** Check file format** : Ensure it's ` .xlsx ` (not ` .xls ` , ` .csv ` , or other formats)
405+ 2 . ** Verify headers** : First row of each worksheet should contain column names
406+ 3 . ** Check for corruption** : Open file in Excel to verify it's not corrupted
407+ 4 . ** Review structure** : Each worksheet should represent one object type
408+ 5 . ** Test with small file first** : Start with a simple file to verify compatibility
342409
343410## Best Practices
344411
@@ -347,6 +414,8 @@ for (const record of records) {
3474143 . ** Backup files** : Keep backups of important Excel files
3484154 . ** Validate data** : Excel doesn't enforce schemas - validate in your app
3494165 . ** Batch operations** : Use ` createMany ` /` updateMany ` for better performance
417+ 6 . ** Monitor console warnings** : Check for warnings about skipped worksheets or rows
418+ 7 . ** Use version control** : Track Excel file changes with git for critical data
350419
351420## TypeScript Support
352421
0 commit comments