ASP.NET Core Web API for Excel Data Processing & Bulk Database Operations
Excel Data API is a robust .NET 8 Web API designed to handle bulk data import from Excel files through Power Automate integration. The API provides comprehensive data validation, error handling, and efficient database operations.
- π Bulk Data Insert: Efficiently process and insert large datasets from Excel files
- β Data Validation: Comprehensive validation with detailed error reporting
- π Power Automate Integration: Seamless integration with Microsoft Power Automate flows
- π Detailed Logging: Complete audit trail with user tracking
- π‘οΈ Error Handling: Robust error handling with user-friendly responses
- π SQL Server Integration: Optimized database operations with connection pooling
ExcelDataAPI/
βββ Controllers/ # API Controllers
β βββ BulkInsertController.cs
βββ Models/ # Data Models & DTOs
β βββ BulkInsertRequest.cs
β βββ BulkInsertResponse.cs
β βββ ExcelInputRow.cs
β βββ ExcelOutputRow.cs
β βββ FinancialDataRow.cs
β βββ ValidationResult.cs
βββ Services/ # Business Logic
β βββ DataService.cs
β βββ ValidationService.cs
βββ Program.cs # Application Entry Point
- Framework: .NET 8.0
- Web Framework: ASP.NET Core
- Database: SQL Server
- Data Access: Microsoft.Data.SqlClient
- API Documentation: Swagger/OpenAPI
- Architecture: Clean Architecture with Service Layer
- .NET 8.0 SDK
- SQL Server (LocalDB, Express, or Full)
- Visual Studio 2022 / VS Code (optional)
- Power Automate (for integration)
git clone https://github.com/quangxuan98765/excel-data-processing-api
cd ExcelDataAPI-Project
Update connection string in appsettings.json
:
{
"ConnectionStrings": {
"DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=YourDatabase;Trusted_Connection=true;"
}
}
cd ExcelDataAPI
dotnet restore
dotnet build
dotnet run
- Swagger UI:
https://localhost:7xxx/swagger
- API Base URL:
https://localhost:7xxx/api
Bulk insert financial data with validation.
Request Body:
{
"data": [
{
"soTaiKhoan": "1234567890",
"tenTaiKhoan": "Nguyen Van A",
"soTien": 1000000,
"ngayGiaoDich": "2024-01-15",
"moTa": "Thu nhαΊp thΓ‘ng 1"
}
],
"idNguoiDung": "USER001",
"nguoiNhap": "Admin User"
}
Response:
{
"success": true,
"message": "Xα» lΓ½ thΓ nh cΓ΄ng 1/1 bαΊ£n ghi",
"totalRows": 1,
"successRows": 1,
"errorRows": 0,
"errors": [],
"processedData": [...]
}
The API is designed to work seamlessly with Power Automate flows:
- Excel Online Connector: Read data from Excel files
- HTTP Connector: Send data to API endpoint
- Data Transformation: Format data according to API schema
- Error Handling: Process API responses and handle errors
- Navigate to
/swagger
- Expand the
POST /api/BulkInsert/financial-data
endpoint - Click "Try it out"
- Enter sample data and execute
$body = @{
data = @(
@{
soTaiKhoan = "1234567890"
tenTaiKhoan = "Test Account"
soTien = 1000000
ngayGiaoDich = "2024-01-15"
moTa = "Test transaction"
}
)
idNguoiDung = "TEST_USER"
nguoiNhap = "Test Admin"
} | ConvertTo-Json -Depth 3
Invoke-RestMethod -Uri "https://localhost:7xxx/api/BulkInsert/financial-data" -Method POST -Body $body -ContentType "application/json"
CREATE TABLE FinancialData (
Id BIGINT IDENTITY(1,1) PRIMARY KEY,
SoTaiKhoan NVARCHAR(50) NOT NULL,
TenTaiKhoan NVARCHAR(255) NOT NULL,
SoTien DECIMAL(18,2) NOT NULL,
NgayGiaoDich DATE NOT NULL,
MoTa NVARCHAR(500),
IDNguoiDung NVARCHAR(100) NOT NULL,
NguoiNhap NVARCHAR(255) NOT NULL,
NgayTao DATETIME2 DEFAULT GETDATE(),
NgayCapNhat DATETIME2 DEFAULT GETDATE()
);
- Input validation and sanitization
- SQL injection prevention
- Data type validation
- Business rule validation
- Comprehensive error logging
- Authentication & Authorization (JWT)
- File upload endpoint for direct Excel processing
- Data export functionality
- Real-time processing status
- Batch processing queues
- Advanced reporting features
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Developer: Quang
Email: [email protected]
LinkedIn: Quang XuΓ’n
GitHub: @quangxuan98765
β Star this repository if you find it helpful!
This project demonstrates professional .NET development practices, clean architecture, and real-world API design patterns. Perfect for learning, portfolio showcasing, and practical business applications.