Hi @Diwakar Devangam,
Since .rdlc
is based on .Net Framework, so you can use RDLC in windows platform. Linux is not support. You can follow my steps to implement this requirement.
Step 1
Create a Blazor Web Application and Windows Froms App.
Step 2
Create report in Windows Froms App, and copy it to Blazor Web Application.
Step 3
Click Report1.rdlc file (1) and right click Parameters folder to add a new Parameter(2). Then right click blank area to insert a testbox.
Then drag ReportParameter1 into the textbox. All configuration items in these steps use the default values, and you can directly click Next to create them.
Step 4
I am using Controller in Blazor Web App to render data.
Program.cs
using RDLC_BlazorWebApp.Components;
namespace RDLC_BlazorWebApp
{
public class Program
{
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddRazorComponents()
.AddInteractiveServerComponents();
// add this line
builder.Services.AddControllers();
var app = builder.Build();
if (!app.Environment.IsDevelopment())
{
app.UseExceptionHandler("/Error");
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseAntiforgery();
app.MapRazorComponents<App>()
.AddInteractiveServerRenderMode();
// add this line
app.MapControllers();
app.Run();
}
}
}
HomeController
using AspNetCore.Reporting;
using Microsoft.AspNetCore.Components.RenderTree;
using Microsoft.AspNetCore.Mvc;
namespace RDLC_BlazorWebApp.Controllers
{
[ApiController]
[Route("[controller]")]
public class HomeController : Controller
{
private readonly ILogger<HomeController> _logger;
private readonly IWebHostEnvironment _webHostEnvironment;
public HomeController(ILogger<HomeController> logger, IWebHostEnvironment webHostEnvironment)
{
_logger = logger;
this._webHostEnvironment = webHostEnvironment;
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
}
[HttpGet("print")]
public IActionResult Print() {
string mimetype = "";
int extension = 1;
var path = $"{this._webHostEnvironment.WebRootPath}\\Reports\\Report1.rdlc";
Dictionary<string,string> parameters = new Dictionary<string,string>();
parameters.Add("ReportParameter1", "RDLC in Blazor Web Application.");
LocalReport localReport = new LocalReport(path);
var result = localReport.Execute(RenderType.Pdf, extension,parameters,mimetype);
return File(result.MainStream,"application/pdf");
}
}
}
**
Step 5 Required**
My Packages
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<Content Remove="wwwroot\Reports\Report1.rdlc" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="wwwroot\Reports\Report1.rdlc">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<PackageReference Include="AspNetCore.Reporting" Version="2.1.0" />
<PackageReference Include="System.CodeDom" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.0" />
<PackageReference Include="System.Security.Permissions" Version="8.0.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="8.0.0" />
</ItemGroup>
</Project>
Step 6 Others
<div class="top-row ps-3 navbar navbar-dark">
<div class="container-fluid">
<a class="navbar-brand" href="">RDLC_BlazorWebApp</a>
</div>
</div>
<input type="checkbox" title="Navigation menu" class="navbar-toggler" />
<div class="nav-scrollable" onclick="document.querySelector('.navbar-toggler').click()">
<nav class="flex-column">
<div class="nav-item px-3">
<NavLink class="nav-link" href="" Match="NavLinkMatch.All">
<span class="bi bi-house-door-fill-nav-menu" aria-hidden="true"></span> Home
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="counter">
<span class="bi bi-plus-square-fill-nav-menu" aria-hidden="true"></span> Counter
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="weather">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> Weather
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="home/print">
<span class="bi bi-list-nested-nav-menu" aria-hidden="true"></span> RDLC
</NavLink>
</div>
</nav>
</div>
Step 7 Test Result
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Best regards,
Jason