pmtool / EXCEL_IMPORT_SETUP.md
devarshia5's picture
Upload 487 files
d97b8f9 verified
|
Raw
History Blame Contribute Delete
3.77 kB
# Excel Import Setup Instructions
## Required Dependencies
To use the Excel import functionality, you need to install the following npm packages:
```bash
npm install xlsx
npm install @types/xlsx --save-dev
```
## Features Added
### 1. Excel Import Component (`ExcelImport.tsx`)
- **Template Download**: Generates and downloads a properly formatted Excel template
- **File Upload**: Accepts .xlsx and .xls files
- **Data Validation**: Validates all required fields and data formats
- **Error Reporting**: Shows detailed errors and warnings
- **Batch Processing**: Handles large imports efficiently
### 2. Bulk Import Hook (`useBulkImport.ts`)
- **Batch Processing**: Processes assets in batches of 10 to avoid server overload
- **Error Handling**: Tracks successful and failed imports
- **Progress Feedback**: Provides detailed feedback on import results
- **Cache Invalidation**: Automatically refreshes the assets list after import
### 3. Updated Assets Page
- **Import Button**: Added "Import Excel" button in the header
- **Import Modal**: Large modal for the import process
- **Integration**: Seamlessly integrated with existing asset management
## Excel Template Format
The template includes the following columns:
| Column | Required | Type | Example |
|--------|----------|------|---------|
| Asset Type | Yes | String | Laptop, Desktop, Monitor, Extended Screen, Keyboard, Mouse, Wired Mouse, Wireless Mouse, Laptop Stand, Printer, Scanner, Tablet, Phone, Other |
| Brand/Model | Yes | String | Dell Latitude 5430 |
| Serial Number | Yes | String | DL5430-001 |
| Asset Condition | Yes | String | Excellent, Good, Fair, Poor |
| Purchase Date | No | Date | 2024-01-15 |
| Warranty Expiry | No | Date | 2027-01-15 |
| Purchase Cost | No | Number | 1200.00 |
| Current Value | No | Number | 1000.00 |
| Location | No | String | Office Floor 1 |
| Notes | No | String | Primary development laptop |
## Validation Rules
### Required Fields
- **Asset Type**: Must be one of the predefined types
- **Brand/Model**: Cannot be empty
- **Serial Number**: Cannot be empty
- **Asset Condition**: Must be Excellent, Good, Fair, or Poor
### Optional Fields
- **Dates**: Must be valid date format (YYYY-MM-DD or Excel date)
- **Numbers**: Must be valid positive numbers
- **Text Fields**: No specific validation
## Usage Instructions
1. **Download Template**:
- Click "Import Excel" button
- Click "Download Template" to get the formatted Excel file
2. **Fill Template**:
- Open the downloaded template
- Fill in your asset data following the format
- Save the file
3. **Import Data**:
- Click "Import Excel" button
- Select your filled Excel file
- Click "Process File" to validate
- Review any errors or warnings
- Click "Import X Assets" to complete the import
## Error Handling
The system provides comprehensive error handling:
- **File Format Errors**: Invalid Excel files
- **Missing Required Fields**: Clear indication of what's missing
- **Invalid Data Types**: Date and number format validation
- **Duplicate Serial Numbers**: Server-side validation
- **Batch Processing Errors**: Individual asset import failures
## Performance Considerations
- **Batch Size**: Processes 10 assets at a time
- **Memory Efficient**: Streams large Excel files
- **Progress Feedback**: Real-time import status
- **Error Recovery**: Continues processing even if some assets fail
## Security Notes
- **File Type Validation**: Only accepts Excel files
- **Data Sanitization**: All input data is validated
- **Server-Side Validation**: Additional validation on the backend
- **Error Logging**: Failed imports are logged for debugging