Import Specification¶
Detailed specification for importing Excel costing templates into CostEngine (MfgIQ).
Overview¶
The import module processes Excel costing templates and extracts structured data for cost calculation. This document defines:
- Supported file formats
- Required data fields
- Validation rules
- Error handling
- Mapping configurations
Supported File Formats¶
Excel Files¶
| Format | Extension | Support Level | Notes |
|---|---|---|---|
| Excel 2007+ | .xlsx |
Full | Recommended format |
| Excel 97-2003 | .xls |
Full | Legacy support |
| CSV | .csv |
Partial | Data only, no formatting |
Maximum File Size: 10 MB
Maximum Sheets: 20 sheets per file
Maximum Rows: 10,000 rows per sheet
Standard Template Structure¶
Required Sheets¶
- Part Info - Basic part and RFQ details
- Material - Material specifications and BOM
- Routing - Operations and process steps
- Tooling - Tooling and fixture requirements
Optional Sheets¶
- Outside Process - Subcontracted operations
- Assumptions - Custom notes and overrides
- History - Previous quote references
Data Fields Specification¶
Part Info Sheet¶
| Field Name | Cell Reference | Data Type | Required | Validation |
|---|---|---|---|---|
| Part Number | B3 | Text | Yes | Max 50 chars |
| Drawing Number | B4 | Text | Yes | Max 50 chars |
| Revision | B5 | Text | No | Max 10 chars |
| Customer | B6 | Text | Yes | Max 100 chars |
| Order Quantity | B7 | Integer | Yes | > 0 |
| RFQ Date | B8 | Date | No | Valid date |
| Estimator Name | B9 | Text | No | Max 100 chars |
Material Sheet¶
| Field Name | Cell Reference | Data Type | Required | Validation |
|---|---|---|---|---|
| Material Grade | B3 | Text | Yes | Must exist in Material Master |
| Gross Weight (kg) | B4 | Decimal | Yes | > 0 |
| Net Weight (kg) | B5 | Decimal | Yes | > 0, ≤ Gross Weight |
| Material Form | B6 | Text | Yes | Enum: Bar, Plate, Sheet, Casting |
| Dimensions | B7 | Text | No | Max 100 chars |
| Scrap % | B8 | Decimal | No | 0-50% |
| RM Rate Override | B9 | Decimal | No | > 0 |
Routing Sheet¶
Routing data is in tabular format starting from row 5:
| Column | Field | Data Type | Required | Validation |
|---|---|---|---|---|
| A | Operation No | Integer | Yes | Unique, sequential |
| B | Operation Name | Text | Yes | Max 100 chars |
| C | Machine Type | Text | Yes | Must exist in Machine Master |
| D | Setup Time (hrs) | Decimal | No | ≥ 0, default 0 |
| E | Cycle Time (hrs) | Decimal | Yes | > 0 |
| F | Machine Rate Override | Decimal | No | > 0 |
| G | Scrap % | Decimal | No | 0-30% |
| H | Notes | Text | No | Max 200 chars |
Multi-row Operations: Continue until empty row encountered
Validation Rules¶
Pre-Import Validation¶
- File Structure
- File must be valid Excel format
- Must contain at least "Part Info", "Material", and "Routing" sheets
-
Sheet names are case-insensitive
-
Data Types
- Numeric fields must contain valid numbers
- Dates must be in Excel date format
-
Text fields must not exceed max length
-
Business Rules
- Net Weight ≤ Gross Weight
- At least one routing operation required
- Material grade must exist in master data
Post-Import Validation¶
- Calculated Fields
- Yield % = Net Weight / Gross Weight
- Yield must be between 50% and 100%
-
Total setup time should not exceed 24 hours
-
Cross-Sheet Validation
- Operation machine types must exist in Machine Master
- Material grade must exist in Material Master
-
Customer must exist in Customer Master (if strict mode enabled)
-
Warning Conditions (Non-blocking)
- Cycle time > 24 hours
- Scrap % > 20%
- Missing RFQ date
- No estimator name
Field Mapping Configuration¶
Auto-Detection¶
System attempts to auto-detect field locations by:
- Searching for known field labels (case-insensitive)
- Looking in common cell locations
- Analyzing data patterns
Detection Confidence Levels: - High (>90%): Auto-import without confirmation - Medium (70-90%): Show preview, request confirmation - Low (<70%): Require manual mapping
Manual Mapping¶
For non-standard templates:
- Upload Excel file
- System shows preview
- First 10 rows of each sheet
- Detected field mappings highlighted
- User maps fields
- Drag-and-drop or dropdown selection
- Required fields must be mapped
- Save mapping template
- Reusable for future uploads
- Shareable across team
Mapping Template Schema:
{
"template_name": "Legacy Format v2",
"file_identifier": "*.xls",
"mappings": {
"part_number": {"sheet": "Header", "cell": "C5"},
"material_grade": {"sheet": "Materials", "cell": "B10"},
"routing_table": {
"sheet": "Processes",
"start_row": 8,
"columns": {
"operation_name": "A",
"cycle_time": "D"
}
}
}
}
Error Handling¶
Error Categories¶
| Category | Severity | Action |
|---|---|---|
| File Corrupt | Critical | Reject import, show error |
| Missing Required Field | Critical | Reject import, show missing fields |
| Invalid Data Type | Critical | Reject import, show cell reference |
| Business Rule Violation | Error | Reject import, show violation |
| Warning Condition | Warning | Allow import, show warnings |
Error Messages¶
Template:
[SEVERITY] [Category]: [Description]
Location: [Sheet Name] Cell [Cell Reference]
Current Value: [Value]
Expected: [Expected Format/Range]
Suggested Action:
1. [Action 1]
2. [Action 2]
Example:
ERROR Missing Required Field: Material Grade is required
Location: Material Sheet, Cell B3
Current Value: (empty)
Expected: Valid material grade (e.g., SAE4140, EN8, SS304)
Suggested Action:
1. Enter material grade in cell B3, OR
2. Select from Material Master dropdown
Import Process Flow¶
graph TD
A[User Uploads Excel] --> B{File Valid?}
B -->|No| C[Show Error & Reject]
B -->|Yes| D{Known Template?}
D -->|Yes| E[Auto-Map Fields]
D -->|No| F[Manual Mapping UI]
F --> G[User Maps Fields]
G --> H[Save Mapping Template]
E --> I{Validation Pass?}
H --> I
I -->|Critical Errors| J[Show Errors & Reject]
I -->|Warnings Only| K[Show Warnings]
I -->|Success| L[Import Data]
K --> M{User Confirms?}
M -->|Yes| L
M -->|No| N[Cancel Import]
L --> O[Create Quote Draft]
O --> P[Redirect to Quote Builder]
Data Extraction Logic¶
Material Cost Data¶
- Extract material grade from specified cell
- Lookup current RM rate from Material Master
- Apply override if present in Excel
- Extract gross/net weights
- Calculate yield percentage
- Extract scrap percentage (default 0%)
- Apply material scrap factor
Routing Data¶
- Identify routing table range (start row to first empty row)
- For each row:
- Extract operation details
- Validate operation sequence
- Lookup machine rate from Machine Master
- Apply override if present
- Calculate setup cost per piece
- Calculate cycle cost
- Apply operation scrap factor
Cascading Calculations¶
- Start with final quantity from Part Info
- Work backward through operations
- Apply scrap % at each stage
- Calculate required input quantity for material
- Store scrap factors for explainability
Import API¶
REST Endpoint¶
POST /api/v1/imports/excel
Request:
{
"file": "base64_encoded_excel_content",
"filename": "costing_template.xlsx",
"mapping_template_id": "optional_template_id",
"options": {
"strict_validation": true,
"auto_create_quote": true
}
}
Response (Success):
{
"status": "success",
"import_id": "imp_20260124_001",
"quote_id": "Q-2026-0042",
"warnings": [
{
"field": "rfq_date",
"message": "RFQ date not provided, using current date"
}
],
"summary": {
"part_number": "RH-2024-05",
"material": "SAE4140",
"operations_count": 5,
"estimated_cost": 529.00
}
}
Response (Error):
{
"status": "error",
"errors": [
{
"field": "material_grade",
"location": "Material!B3",
"message": "Material grade 'XYZ123' not found in Material Master",
"severity": "critical"
}
],
"import_id": "imp_20260124_001"
}
Performance Targets¶
| Metric | Target | Notes |
|---|---|---|
| Upload Time | < 3 sec | For 5 MB file |
| Validation Time | < 2 sec | Standard template |
| Mapping UI Load | < 1 sec | Preview 10 rows |
| Full Import | < 10 sec | Including quote creation |
Security Considerations¶
- File Upload
- Virus scan all uploads
- Validate file extensions
-
Limit file size to prevent DoS
-
Data Privacy
- Uploaded files stored encrypted
- Auto-delete after 30 days if not imported
-
Access logged and auditable
-
Injection Prevention
- Sanitize all text inputs
- No formula execution from Excel
- Escape special characters
Related Documentation¶
- Costing Formats Index → - Overview of all costing formats
- Export Specification → - Quote output format specification
- Excel Import Use Cases → - Detailed import scenarios
- Data Pipeline → - Technical architecture for data processing