Jak przeprowadzić migrację z SSRS do IronPDF w języku C#
Migrating from SQL Server Reporting Services (SSRS) toIronPDFtransforms your PDF generation workflow from a heavyweight server-based infrastructure to a lightweight, in-process library that can be embedded directly into any .NET application. This guide provides a complete, step-by-step migration path that eliminates SQL Server dependencies, report server overhead, and Microsoft ecosystem lock-in.
Why Migrate fromSSRSto IronPDF
Understanding SSRS
SQL Server Reporting Services (SSRS) is Microsoft's enterprise reporting platform that requires significant infrastructure investment.SSRSis a comprehensive reporting platform from Microsoft that provides a complete suite for creating, deploying, and managing reports, offering both feature-rich and interactive report features. Developed as part of the SQL Server ecosystem,SSRSis tightly integrated with Microsoft's database solutions.
However, for many PDF generation scenarios,SSRSinfrastructure is excessive. Key reasons to migrate include:
- Heavy Infrastructure: Requires SQL Server, Report Server, and IIS configuration
- Microsoft Ecosystem Lock-in: Tied to SQL Server licensing and Windows Server
- Complex Deployment: Report deployment, security configuration, and subscription management
- Expensive Licensing: SQL Server licenses, especially for enterprise features
- Limited Web Support: Difficult to integrate with modern SPA frameworks
- Maintenance Overhead: Server patching, database maintenance, report management
- No Cloud-Native Option: Designed for on-premises, cloud support is awkward
KiedySSRSto przesada
| Twoje potrzeby | SSRS narzut |
|---|---|
| Generowanie faktur | Pełny serwer raportów |
| Eksport tabel danych | Licencja SQL Server |
| Tworzenie plików PDF na podstawie danych | Windows Server |
| Proste generowanie dokumentów | Subskrypcje raportów |
IronPDF umożliwia generowanie plików PDF w trakcie przetwarzania bez konieczności posiadania infrastruktury serwerowej.
SSRSvsIronPDFComparison
| Funkcja | SSRS | IronPDF |
|---|---|---|
| Zależności | Wymaga SQL Server | Brak konkretnej zależności od bazy danych |
| Wdrożenie | Oparte na serwerze | Biblioteka (wbudowana w aplikacje) |
| Integracja | Ścisła integracja z Microsoftem | Działa z dowolnym źródłem danych |
| Wizualizacja danych | Szeroki wybór opcji językowych | Wizualizacje skupione na plikach PDF |
| Złożoność | Wysoki (wymagana konfiguracja serwera) | Umiarkowana do niskiej (konfiguracja biblioteki) |
| Koszt | Koszty licencji SQL Server | Koszt licencji dla programisty |
| HTML do PDF | Nie | Pełny Chromium |
| URL do pliku PDF | Nie | Tak |
| Obsługa CSS | Ograniczone | Pełny CSS3 |
| JavaScript | Nie | Pełna wersja ES2024 |
IronPDF, unlike SSRS, is not tied to any specific database or server ecosystem. It provides developers with a flexible library to dynamically create, edit, and manipulate PDF documents directly in C#. This decoupling from a server-based infrastructure offers a noticeable advantage—it is straightforward and adaptable, suitable for a wide array of applications beyond reporting.
For teams planning .NET 10 and C# 14 adoption through 2025 and 2026,IronPDFprovides a modern Chromium rendering engine that eliminates the infrastructure complexity of SSRS.
Zanim zaczniesz
Wymagania wstępne
- Środowisko .NET: .NET Framework 4.6.2+ lub .NET Core 3.1+ / .NET 5/6/7/8/9+
- Dostęp do NuGet: Możliwość instalowania pakietów NuGet
- Licencja IronPDF: Uzyskaj klucz licencyjny na stronie ironpdf.com
Zmiany w pakiecie NuGet
#SSRShas no direct NuGet - it's server-based
# Remove any ReportViewer controls
dotnet remove package Microsoft.ReportingServices.ReportViewerControl.WebForms
dotnet remove package Microsoft.ReportingServices.ReportViewerControl.WinForms
# Install IronPDF
dotnet add package IronPdf
#SSRShas no direct NuGet - it's server-based
# Remove any ReportViewer controls
dotnet remove package Microsoft.ReportingServices.ReportViewerControl.WebForms
dotnet remove package Microsoft.ReportingServices.ReportViewerControl.WinForms
# Install IronPDF
dotnet add package IronPdf
Konfiguracja licencji
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
// Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY";
' Add at application startup
IronPdf.License.LicenseKey = "YOUR-LICENSE-KEY"
Kompletna dokumentacija API
Zmiany w przestrzeni nazw
// Before: SSRS
using Microsoft.Reporting.WebForms;
using Microsoft.Reporting.WinForms;
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
// Before: SSRS
using Microsoft.Reporting.WebForms;
using Microsoft.Reporting.WinForms;
// After: IronPDF
using IronPdf;
using IronPdf.Rendering;
Imports Microsoft.Reporting.WebForms
Imports Microsoft.Reporting.WinForms
' After: IronPDF
Imports IronPdf
Imports IronPdf.Rendering
Mapowania podstawowych interfejsów API
| KoncepcjaSSRS | OdpowiednikIronPDF | Uwagi |
|---|---|---|
LocalReport |
ChromePdfRenderer |
Renderowanie rdzenia |
ServerReport |
RenderUrlAsPdf() |
URL-based rendering |
.rdlc files |
Szablony HTML/CSS | Format szablonu |
ReportParameter |
Interpolacja ciągów znaków | Parametry |
ReportDataSource |
Dane C# + HTML | Powiązanie danych |
LocalReport.Render("PDF") |
RenderHtmlAsPdf() |
Wynik w formacie PDF |
SubReport |
Połączone pliki PDF | Nested reports |
Report Server URL |
Nie jest potrzebne | Nie server required |
ReportViewer control |
Nie jest potrzebne | Direct PDF generation |
| Formaty eksportu | PDF jest formatem natywnym | Focused output |
Przykłady migracji kodu
Przykład 1: Konwersja HTML do PDF
Before (SSRS):
//SSRS- SQL Server Reporting Services
using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
using System.IO;
class SSRSHtmlToPdf
{
static void Main()
{
// Create a ReportViewer instance
var reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
// Load RDLC report definition
reportViewer.LocalReport.ReportPath = "Report.rdlc";
// Add HTML content as a parameter or dataset
var htmlContent = "<h1>Hello World</h1><p>This is HTML content.</p>";
var param = new ReportParameter("HtmlContent", htmlContent);
reportViewer.LocalReport.SetParameters(param);
// Render the report to PDF
string mimeType, encoding, fileNameExtension;
string[] streams;
Warning[] warnings;
byte[] bytes = reportViewer.LocalReport.Render(
"PDF",
null,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
File.WriteAllBytes("output.pdf", bytes);
}
}
//SSRS- SQL Server Reporting Services
using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
using System.IO;
class SSRSHtmlToPdf
{
static void Main()
{
// Create a ReportViewer instance
var reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
// Load RDLC report definition
reportViewer.LocalReport.ReportPath = "Report.rdlc";
// Add HTML content as a parameter or dataset
var htmlContent = "<h1>Hello World</h1><p>This is HTML content.</p>";
var param = new ReportParameter("HtmlContent", htmlContent);
reportViewer.LocalReport.SetParameters(param);
// Render the report to PDF
string mimeType, encoding, fileNameExtension;
string[] streams;
Warning[] warnings;
byte[] bytes = reportViewer.LocalReport.Render(
"PDF",
null,
out mimeType,
out encoding,
out fileNameExtension,
out streams,
out warnings);
File.WriteAllBytes("output.pdf", bytes);
}
}
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebForms
Imports System.IO
Class SSRSHtmlToPdf
Shared Sub Main()
' Create a ReportViewer instance
Dim reportViewer As New ReportViewer()
reportViewer.ProcessingMode = ProcessingMode.Local
' Load RDLC report definition
reportViewer.LocalReport.ReportPath = "Report.rdlc"
' Add HTML content as a parameter or dataset
Dim htmlContent As String = "<h1>Hello World</h1><p>This is HTML content.</p>"
Dim param As New ReportParameter("HtmlContent", htmlContent)
reportViewer.LocalReport.SetParameters(param)
' Render the report to PDF
Dim mimeType As String, encoding As String, fileNameExtension As String
Dim streams As String()
Dim warnings As Warning()
Dim bytes As Byte() = reportViewer.LocalReport.Render( _
"PDF", _
Nothing, _
mimeType, _
encoding, _
fileNameExtension, _
streams, _
warnings)
File.WriteAllBytes("output.pdf", bytes)
End Sub
End Class
Po (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class IronPdfHtmlToPdf
{
static void Main()
{
// Create a ChromePdfRenderer instance
var renderer = new ChromePdfRenderer();
// Convert HTML string to PDF
var htmlContent = "<h1>Hello World</h1><p>This is HTML content.</p>";
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF file
pdf.SaveAs("output.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
class IronPdfHtmlToPdf
{
static void Main()
{
// Create a ChromePdfRenderer instance
var renderer = new ChromePdfRenderer();
// Convert HTML string to PDF
var htmlContent = "<h1>Hello World</h1><p>This is HTML content.</p>";
var pdf = renderer.RenderHtmlAsPdf(htmlContent);
// Save the PDF file
pdf.SaveAs("output.pdf");
}
}
Imports IronPdf
Imports System
Class IronPdfHtmlToPdf
Shared Sub Main()
' Create a ChromePdfRenderer instance
Dim renderer = New ChromePdfRenderer()
' Convert HTML string to PDF
Dim htmlContent = "<h1>Hello World</h1><p>This is HTML content.</p>"
Dim pdf = renderer.RenderHtmlAsPdf(htmlContent)
' Save the PDF file
pdf.SaveAs("output.pdf")
End Sub
End Class
Ten przykład ilustruje podstawową różnicę architektoniczną.SSRSrequires creating a ReportViewer instance, loading an .rdlc report definition file, setting parameters, and then calling LocalReport.Render("PDF") with multiple out parameters for metadata.
IronPDF uses a ChromePdfRenderer with RenderHtmlAsPdf() in just three lines of code. Nie report definition files, no parameter objects, no metadata handling required. Kompleksowe przykłady można znaleźć w dokumentacji dotyczącej konwersji HTML do PDF.
Example 2: URL do pliku PDF with Headers and Footers
Before (SSRS):
//SSRS- SQL Server Reporting Services
using System;
using System.IO;
using System.Net;
using Microsoft.Reporting.WebForms;
class SSRSUrlToPdf
{
static void Main()
{
// Download HTML content from URL
string url = "https://example.com";
string htmlContent;
using (var client = new WebClient())
{
htmlContent = client.DownloadString(url);
}
// Create RDLC report with header/footer configuration
var reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = "WebReport.rdlc";
// Set parameters for header and footer
var parameters = new ReportParameter[]
{
new ReportParameter("HeaderText", "Company Report"),
new ReportParameter("FooterText", "Page " + DateTime.Now.ToString()),
new ReportParameter("HtmlContent", htmlContent)
};
reportViewer.LocalReport.SetParameters(parameters);
// Render to PDF
string mimeType, encoding, fileNameExtension;
string[] streams;
Warning[] warnings;
byte[] bytes = reportViewer.LocalReport.Render(
"PDF", null, out mimeType, out encoding,
out fileNameExtension, out streams, out warnings);
File.WriteAllBytes("webpage.pdf", bytes);
}
}
//SSRS- SQL Server Reporting Services
using System;
using System.IO;
using System.Net;
using Microsoft.Reporting.WebForms;
class SSRSUrlToPdf
{
static void Main()
{
// Download HTML content from URL
string url = "https://example.com";
string htmlContent;
using (var client = new WebClient())
{
htmlContent = client.DownloadString(url);
}
// Create RDLC report with header/footer configuration
var reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = "WebReport.rdlc";
// Set parameters for header and footer
var parameters = new ReportParameter[]
{
new ReportParameter("HeaderText", "Company Report"),
new ReportParameter("FooterText", "Page " + DateTime.Now.ToString()),
new ReportParameter("HtmlContent", htmlContent)
};
reportViewer.LocalReport.SetParameters(parameters);
// Render to PDF
string mimeType, encoding, fileNameExtension;
string[] streams;
Warning[] warnings;
byte[] bytes = reportViewer.LocalReport.Render(
"PDF", null, out mimeType, out encoding,
out fileNameExtension, out streams, out warnings);
File.WriteAllBytes("webpage.pdf", bytes);
}
}
Imports System
Imports System.IO
Imports System.Net
Imports Microsoft.Reporting.WebForms
Class SSRSUrlToPdf
Shared Sub Main()
' Download HTML content from URL
Dim url As String = "https://example.com"
Dim htmlContent As String
Using client As New WebClient()
htmlContent = client.DownloadString(url)
End Using
' Create RDLC report with header/footer configuration
Dim reportViewer As New ReportViewer()
reportViewer.ProcessingMode = ProcessingMode.Local
reportViewer.LocalReport.ReportPath = "WebReport.rdlc"
' Set parameters for header and footer
Dim parameters As ReportParameter() = {
New ReportParameter("HeaderText", "Company Report"),
New ReportParameter("FooterText", "Page " & DateTime.Now.ToString()),
New ReportParameter("HtmlContent", htmlContent)
}
reportViewer.LocalReport.SetParameters(parameters)
' Render to PDF
Dim mimeType As String, encoding As String, fileNameExtension As String
Dim streams As String()
Dim warnings As Warning()
Dim bytes As Byte() = reportViewer.LocalReport.Render(
"PDF", Nothing, mimeType, encoding,
fileNameExtension, streams, warnings)
File.WriteAllBytes("webpage.pdf", bytes)
End Sub
End Class
Po (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;
class IronPdfUrlToPdf
{
static void Main()
{
// Create a ChromePdfRenderer instance
var renderer = new ChromePdfRenderer();
// Configure rendering options with header and footer
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Company Report</div>"
};
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages} - " + DateTime.Now.ToString("MM/dd/yyyy") + "</div>"
};
// Convert URL to PDF
string url = "https://example.com";
var pdf = renderer.RenderUrlAsPdf(url);
// Save the PDF file
pdf.SaveAs("webpage.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using IronPdf.Rendering;
using System;
class IronPdfUrlToPdf
{
static void Main()
{
// Create a ChromePdfRenderer instance
var renderer = new ChromePdfRenderer();
// Configure rendering options with header and footer
renderer.RenderingOptions.HtmlHeader = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Company Report</div>"
};
renderer.RenderingOptions.HtmlFooter = new HtmlHeaderFooter()
{
HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages} - " + DateTime.Now.ToString("MM/dd/yyyy") + "</div>"
};
// Convert URL to PDF
string url = "https://example.com";
var pdf = renderer.RenderUrlAsPdf(url);
// Save the PDF file
pdf.SaveAs("webpage.pdf");
}
}
Imports IronPdf
Imports IronPdf.Rendering
Imports System
Class IronPdfUrlToPdf
Shared Sub Main()
' Create a ChromePdfRenderer instance
Dim renderer As New ChromePdfRenderer()
' Configure rendering options with header and footer
renderer.RenderingOptions.HtmlHeader = New HtmlHeaderFooter() With {
.HtmlFragment = "<div style='text-align:center'>Company Report</div>"
}
renderer.RenderingOptions.HtmlFooter = New HtmlHeaderFooter() With {
.HtmlFragment = "<div style='text-align:center'>Page {page} of {total-pages} - " & DateTime.Now.ToString("MM/dd/yyyy") & "</div>"
}
' Convert URL to PDF
Dim url As String = "https://example.com"
Dim pdf = renderer.RenderUrlAsPdf(url)
' Save the PDF file
pdf.SaveAs("webpage.pdf")
End Sub
End Class
SSRS cannot directly convert URLs to PDF. You must manually download HTML content with WebClient.DownloadString(), create a separate .rdlc report file, pass the HTML and header/footer text as ReportParameter arrays, then render with the complex Render() method signature.
IronPDF's RenderUrlAsPdf() handles the entire process in a single call. Headers and footers are configured with HtmlHeaderFooter objects that support full HTML/CSS and placeholders like {page} and {total-pages}. Dowiedz się więcej z naszych samouczków.
Example 3: Database-Driven Report
Before (SSRS):
//SSRS- SQL Server Reporting Services
using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
using System.IO;
class SSRSDatabaseReport
{
static void Main()
{
// Create a ReportViewer instance
var reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = "SalesReport.rdlc";
// Create database connection and fetch data
string connString = "Server=localhost;Database=SalesDB;Integrated Security=true;";
using (var connection = new SqlConnection(connString))
{
var adapter = new SqlDataAdapter("SELECT * FROM Sales", connection);
var dataSet = new DataSet();
adapter.Fill(dataSet, "Sales");
// Bind data to report
var dataSource = new ReportDataSource("SalesDataSet", dataSet.Tables[0]);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(dataSource);
}
// Render to PDF
string mimeType, encoding, fileNameExtension;
string[] streams;
Warning[] warnings;
byte[] bytes = reportViewer.LocalReport.Render(
"PDF", null, out mimeType, out encoding,
out fileNameExtension, out streams, out warnings);
File.WriteAllBytes("sales-report.pdf", bytes);
}
}
//SSRS- SQL Server Reporting Services
using System;
using System.Data;
using System.Data.SqlClient;
using Microsoft.Reporting.WebForms;
using System.IO;
class SSRSDatabaseReport
{
static void Main()
{
// Create a ReportViewer instance
var reportViewer = new ReportViewer();
reportViewer.ProcessingMode = ProcessingMode.Local;
reportViewer.LocalReport.ReportPath = "SalesReport.rdlc";
// Create database connection and fetch data
string connString = "Server=localhost;Database=SalesDB;Integrated Security=true;";
using (var connection = new SqlConnection(connString))
{
var adapter = new SqlDataAdapter("SELECT * FROM Sales", connection);
var dataSet = new DataSet();
adapter.Fill(dataSet, "Sales");
// Bind data to report
var dataSource = new ReportDataSource("SalesDataSet", dataSet.Tables[0]);
reportViewer.LocalReport.DataSources.Clear();
reportViewer.LocalReport.DataSources.Add(dataSource);
}
// Render to PDF
string mimeType, encoding, fileNameExtension;
string[] streams;
Warning[] warnings;
byte[] bytes = reportViewer.LocalReport.Render(
"PDF", null, out mimeType, out encoding,
out fileNameExtension, out streams, out warnings);
File.WriteAllBytes("sales-report.pdf", bytes);
}
}
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports Microsoft.Reporting.WebForms
Imports System.IO
Class SSRSDatabaseReport
Shared Sub Main()
' Create a ReportViewer instance
Dim reportViewer As New ReportViewer()
reportViewer.ProcessingMode = ProcessingMode.Local
reportViewer.LocalReport.ReportPath = "SalesReport.rdlc"
' Create database connection and fetch data
Dim connString As String = "Server=localhost;Database=SalesDB;Integrated Security=true;"
Using connection As New SqlConnection(connString)
Dim adapter As New SqlDataAdapter("SELECT * FROM Sales", connection)
Dim dataSet As New DataSet()
adapter.Fill(dataSet, "Sales")
' Bind data to report
Dim dataSource As New ReportDataSource("SalesDataSet", dataSet.Tables(0))
reportViewer.LocalReport.DataSources.Clear()
reportViewer.LocalReport.DataSources.Add(dataSource)
End Using
' Render to PDF
Dim mimeType As String
Dim encoding As String
Dim fileNameExtension As String
Dim streams As String()
Dim warnings As Warning()
Dim bytes As Byte() = reportViewer.LocalReport.Render("PDF", Nothing, mimeType, encoding, fileNameExtension, streams, warnings)
File.WriteAllBytes("sales-report.pdf", bytes)
End Sub
End Class
Po (IronPDF):
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
class IronPdfDatabaseReport
{
static void Main()
{
// Create database connection and fetch data
string connString = "Server=localhost;Database=SalesDB;Integrated Security=true;";
var dataTable = new DataTable();
using (var connection = new SqlConnection(connString))
{
var adapter = new SqlDataAdapter("SELECT * FROM Sales", connection);
adapter.Fill(dataTable);
}
// Build HTML table from data
var htmlBuilder = new StringBuilder();
htmlBuilder.Append("<h1>Sales Report</h1><table border='1'><tr>");
foreach (DataColumn column in dataTable.Columns)
htmlBuilder.Append($"<th>{column.ColumnName}</th>");
htmlBuilder.Append("</tr>");
foreach (DataRow row in dataTable.Rows)
{
htmlBuilder.Append("<tr>");
foreach (var item in row.ItemArray)
htmlBuilder.Append($"<td>{item}</td>");
htmlBuilder.Append("</tr>");
}
htmlBuilder.Append("</table>");
// Convert to PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(htmlBuilder.ToString());
pdf.SaveAs("sales-report.pdf");
}
}
// NuGet: Install-Package IronPdf
using IronPdf;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Text;
class IronPdfDatabaseReport
{
static void Main()
{
// Create database connection and fetch data
string connString = "Server=localhost;Database=SalesDB;Integrated Security=true;";
var dataTable = new DataTable();
using (var connection = new SqlConnection(connString))
{
var adapter = new SqlDataAdapter("SELECT * FROM Sales", connection);
adapter.Fill(dataTable);
}
// Build HTML table from data
var htmlBuilder = new StringBuilder();
htmlBuilder.Append("<h1>Sales Report</h1><table border='1'><tr>");
foreach (DataColumn column in dataTable.Columns)
htmlBuilder.Append($"<th>{column.ColumnName}</th>");
htmlBuilder.Append("</tr>");
foreach (DataRow row in dataTable.Rows)
{
htmlBuilder.Append("<tr>");
foreach (var item in row.ItemArray)
htmlBuilder.Append($"<td>{item}</td>");
htmlBuilder.Append("</tr>");
}
htmlBuilder.Append("</table>");
// Convert to PDF
var renderer = new ChromePdfRenderer();
var pdf = renderer.RenderHtmlAsPdf(htmlBuilder.ToString());
pdf.SaveAs("sales-report.pdf");
}
}
Imports IronPdf
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Class IronPdfDatabaseReport
Shared Sub Main()
' Create database connection and fetch data
Dim connString As String = "Server=localhost;Database=SalesDB;Integrated Security=true;"
Dim dataTable As New DataTable()
Using connection As New SqlConnection(connString)
Dim adapter As New SqlDataAdapter("SELECT * FROM Sales", connection)
adapter.Fill(dataTable)
End Using
' Build HTML table from data
Dim htmlBuilder As New StringBuilder()
htmlBuilder.Append("<h1>Sales Report</h1><table border='1'><tr>")
For Each column As DataColumn In dataTable.Columns
htmlBuilder.Append($"<th>{column.ColumnName}</th>")
Next
htmlBuilder.Append("</tr>")
For Each row As DataRow In dataTable.Rows
htmlBuilder.Append("<tr>")
For Each item In row.ItemArray
htmlBuilder.Append($"<td>{item}</td>")
Next
htmlBuilder.Append("</tr>")
Next
htmlBuilder.Append("</table>")
' Convert to PDF
Dim renderer As New ChromePdfRenderer()
Dim pdf = renderer.RenderHtmlAsPdf(htmlBuilder.ToString())
pdf.SaveAs("sales-report.pdf")
End Sub
End Class
SSRS requires a pre-designed .rdlc report file ("SalesReport.rdlc"), filling a DataSet, creating a ReportDataSource with a specific name ("SalesDataSet") that must match the report definition, clearing existing data sources, adding the new data source, then rendering.
IronPDF uses your existing data access code (same SqlDataAdapter pattern), then builds HTML dynamically with StringBuilder. You have full control over the layout using standard HTML/CSS—no proprietary report definition files required.
Porównanie funkcji
| Funkcja | SSRS | IronPDF | |||
|---|---|---|---|---|---|
| :Infrastructure: | Wymagany serwer | Tak (Serwer raportów) | Nie | ||
| Licencja SQL Server | Wymagane | Nie jest potrzebne | |||
| Windows Server | Wymagane | Dowolna platforma | |||
| Wymagana baza danych | Tak (baza danych ReportServer) | Nie | |||
| :Development: | Projektant wizualny | Tak (.rdlc) | Edytory HTML | ||
| Format szablonu | RDLC/RDL | HTML/CSS/Razor | |||
| Źródła danych | Wbudowany DSN | Wszelkie dane w języku C# | |||
| :Rendering: | HTML do PDF | Nie | Pełny Chromium | ||
| URL do pliku PDF | Nie | Tak | |||
| Obsługa CSS | Ograniczone | Pełny CSS3 | |||
| JavaScript | Nie | Pełna wersja ES2024 | |||
| Wykresy | Wbudowane | Za pośrednictwem bibliotek JS | |||
| :Deployment: | Wdrożenie raportu | Do serwera | Z aplikacją | ||
| Konfiguracja | Złożone | Proste | |||
| Konserwacja | High | Low |
Typowe problemy związane z migracją
Issue 1: RDLC Report Definitions
SSRS: Uses proprietary .rdlc XML format.
Solution: Convert to HTML templates:
- Open .rdlc in Visual Studio
- Document the layout structure
- Recreate in HTML/CSS
- Use Razor for data binding
Issue 2: Shared Data Sources
SSRS: Connection strings in Report Server.
Solution: Use your application's data access layer:
var data = await _dbContext.Sales.ToListAsync();
// Then bind to HTML template
var data = await _dbContext.Sales.ToListAsync();
// Then bind to HTML template
Dim data = Await _dbContext.Sales.ToListAsync()
' Then bind to HTML template
Issue 3: Report Parametry UI
SSRS: Wbudowane parameter prompts.
Solution: Build parameter UI in your application:
// Your own parameter form, then:
var pdf = GenerateReport(startDate, endDate, region);
// Your own parameter form, then:
var pdf = GenerateReport(startDate, endDate, region);
' Your own parameter form, then:
Dim pdf = GenerateReport(startDate, endDate, region)
Issue 4: Subscriptions/Scheduled Reports
SSRS: Wbudowane subscription engine.
Solution: Use background job framework:
// Using Hangfire or similar
RecurringJob.AddOrUpdate("weekly-report",
() => GenerateAndEmailReport(), Cron.Weekly);
// Using Hangfire or similar
RecurringJob.AddOrUpdate("weekly-report",
() => GenerateAndEmailReport(), Cron.Weekly);
Lista kontrolna migracji
Przed migracją
- Inventory allSSRSreports (
.rdlcfiles) - Document data sources and connections
- Screenshot report layouts for visual reference
- List report parameters for each report
- Note subscription schedules
- Uzyskaj klucz licencyjnyIronPDFze strony ironpdf.com
Aktualizacje kodu
- Remove ReportViewer packages
- Install
IronPdfNuGet package - Convert
.rdlcfiles to HTML templates - Replace
LocalReportwithChromePdfRenderer - Replace
ReportDataSourcewith Dane C# + HTML templates - Replace
ReportParameterwith string interpolation - Replace
LocalReport.Render("PDF")withRenderHtmlAsPdf() - Implement headers/footers with
HtmlHeaderFooter - Dodaj inicjalizację licencji podczas uruchamiania aplikacji
Infrastructure
- Plan Report Server decommission
- Migrate subscriptions to job scheduler (Hangfire, etc.)
- Aktualizacja skryptów wdrażania
Testowanie
- Compare Wynik w formacie PDF visually
- Verify data accuracy
- Test pagination
- Check all parameters
- Testy wydajności

