-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
31 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,39 @@ | ||
# Json2ExcelMiddleware | ||
# Json2ExcelMiddleware | ||
|
||
This middleware convert your .net controller json result to excel file without adding anything to any controller | ||
**Json2ExcelMiddleware** allows you to effortlessly convert your .NET controller's JSON responses into Excel files with minimal setup. | ||
|
||
how to add package: | ||
## Installation | ||
|
||
using pm> | ||
|
||
``` | ||
Install the package via NuGet: | ||
```bash | ||
Install-Package Json2ExcelMiddleware -Version 1.2.4 | ||
``` | ||
|
||
how to use: | ||
|
||
1) first add this line of code to your startup file configure section: | ||
|
||
```c# | ||
app.UseJson2Excel(); | ||
## How to Use | ||
|
||
1. **Configure Middleware** | ||
Add the following line to the `Configure` method in your `Startup.cs` after `app.UseRouting()`: | ||
```csharp | ||
app.UseJson2Excel(); | ||
``` | ||
2. **Set Header** | ||
Include this header in your HTTP request: | ||
``` | ||
x-excel:1 | ||
``` | ||
That’s it! The middleware works with all HTTP methods (GET, POST, PUT, etc.). | ||
|
||
## Example | ||
### Before | ||
A typical JSON response: | ||
```json | ||
[ | ||
{ "Name": "Alice", "Age": 25 }, | ||
{ "Name": "Bob", "Age": 30 } | ||
] | ||
``` | ||
* after app.UseRouting() | ||
|
||
2) add this header to your http request: | ||
|
||
``` | ||
x-excel:1 | ||
``` | ||
|
||
that's it! | ||
### After | ||
Downloadable Excel file with the same data! | ||
|
||
it works for every kind of http request (get,post,put,etc.) | ||
## License | ||
This project is licensed under [Apache License](https://github.com/stormaref/Json2ExcelMiddleware/blob/main/LICENSE) |