This solution provides a complete integration between .NET Core API and React frontend for viewing and exporting RDLC reports from SurveyJS forms.
dotnet new webapi -n FormReportAPI
cd FormReportAPI# Syncfusion packages
dotnet add package Syncfusion.ReportWriter.Net.Core --version 24.1.41
dotnet add package Syncfusion.Compression.Net.Core --version 24.1.41
dotnet add package Syncfusion.DocIO.Net.Core --version 24.1.41
dotnet add package Syncfusion.XlsIO.Net.Core --version 24.1.41
dotnet add package Syncfusion.Pdf.Net.Core --version 24.1.41
# Other dependencies
dotnet add package Newtonsoft.Json
dotnet add package Microsoft.AspNetCore.CorsFormReportAPI/
├── Controllers/
│ └── FormReportController.cs
├── Services/
│ ├── IFormReportService.cs
│ └── FormReportService.cs
├── Models/
│ └── FormDataTransformer.cs
├── Reports/
│ └── DynamicFormReport.rdlc
├── Program.cs
└── appsettings.jsonIn Program.cs, add your Syncfusion license key:
Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("YOUR_LICENSE_KEY_HERE");Create Reports/DynamicFormReport.rdlc using Visual Studio Report Designer or Syncfusion Report Designer.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"CorsSettings": {
"AllowedOrigins": ["http://localhost:3000", "https://localhost:3000"]
}
}npx create-react-app form-report-viewer --template typescript
cd form-report-viewernpm install lucide-react
npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -pUpdate tailwind.config.js:
module.exports = {
content: [
"./src/**/*.{js,jsx,ts,tsx}",
],
theme: {
extend: {},
},
plugins: [],
}Add to src/index.css:
@tailwind base;
@tailwind components;
@tailwind utilities;In the React component, update the API URL:
static baseUrl = 'https://localhost:5001/api/FormReport'; // Your API URLimport FormReportViewer from './components/FormReportViewer';
function App() {
const formStructure = `{
"Entity": {
"FormStructure": {
"title": "Sample Form",
"pages": [...]
}
}
}`;
const formData = `{
"Entity": {
"Location": "Test Location",
"Status": "Completed"
}
}`;
return (
<div className="App">
<FormReportViewer
formStructureJson={formStructure}
formDataJson={formData}
/>
</div>
);
}import { ReportService } from './services/ReportService';
const handleExport = async () => {
try {
const blob = await ReportService.exportReport(
formStructureJson,
formDataJson,
'pdf'
);
// Download file
const url = URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = 'report.pdf';
link.click();
URL.revokeObjectURL(url);
} catch (error) {
console.error('Export failed:', error);
}
};// In your React component
const [reports, setReports] = useState([]);
useEffect(() => {
const fetchReports = async () => {
try {
const response = await fetch('/api/forms');
const forms = await response.json();
setReports(forms);
} catch (error) {
console.error('Failed to fetch forms:', error);
}
};
fetchReports();
}, []);Preview report data
{
"formStructureJson": "...",
"formDataJson": "..."
}Export report as file download
{
"formStructureJson": "...",
"formDataJson": "...",
"exportFormat": "pdf|excel|word|csv"
}Export report as base64 string
{
"formStructureJson": "...",
"formDataJson": "...",
"exportFormat": "pdf"
}Get supported export formats
cd FormReportAPI
dotnet runAPI will be available at https://localhost:5001
cd form-report-viewer
npm startReact app will be available at http://localhost:3000
Edit the RDLC file using Visual Studio or Syncfusion Report Designer to customize the report layout.
Extend the FormDataTransformer class to handle additional form fields:
public class CustomFormDataTransformer : FormDataTransformer
{
public override RdlcReportData TransformFormData(string formJson, string dataJson)
{
var result = base.TransformFormData(formJson, dataJson);
// Add custom transformations
return result;
}
}Add new export formats by extending the FormReportService:
public async Task<byte[]> ExportToCustomFormat(string formStructure, string formData)
{
// Custom export logic
}Program.csappsettings.json:{
"Logging": {
"LogLevel": {
"Default": "Debug",
"Microsoft": "Information"
}
}
}dotnet publish -c Releasenpm run build