Wordize Reporting cho .NET — một giải pháp sáng tạo để tạo tài liệu PDF theo chương trình giúp các lập trình viên C# tự động hóa việc tạo báo cáo với mọi độ phức tạp. Tích hợp việc tạo báo cáo vào dự án C# của bạn và chuyển đổi các file JSON, XML thành tài liệu PDF chuyên nghiệp.
Lợi ích chính của việc Tạo Báo Cáo PDF bằng C#:
Để hiểu cách tạo các file PDF bằng C# sử dụng API Tạo Báo Cáo, hãy tải lên tài liệu mẫu và file dữ liệu (XML, JSON, CSV) thông qua biểu mẫu. Xác định tên đối tượng nguồn dữ liệu được sử dụng trong mẫu và bắt đầu tạo file PDF theo chương trình. Sau khi chạy bản demo, tải xuống tài liệu PDF đã tạo và xác minh việc thay thế dữ liệu chính xác từ file nguồn được chỉ định.
using Wordize.Reporting;
var dataSource = new JsonDataSource("data.json");
ReportBuilder.BuildReport("Input.pdf", "Output.pdf", dataSource, "");
using Wordize.Reporting;
var dataSource = new JsonDataSource("data.json");
ReportBuilder.BuildReport("Input.pdf", "Output.pdf", dataSource, "");
using Wordize.Reporting;
using Wordize.Saving;
var dataSource = new JsonDataSource("data.json");
var imageStreams = ReportBuilder.BuildReportToImages("Input.pdf",
new ImageSaveOptions(SaveFormat.Pdf), new[] { dataSource }, new[] { "" });
foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i)))
{
using var _ = stream;
stream.Position = 0;
using var file = File.Create($"Output_{page + 1}.pdf");
stream.CopyTo(file);
}
using Wordize.Reporting;
var dataSource = new XmlDataSource("data.xml");
ReportBuilder.BuildReport("Input.pdf", "Output.pdf", dataSource, "");
using Wordize.Reporting;
var dataSource = new XmlDataSource("data.xml");
ReportBuilder.BuildReport("Input.pdf", "Output.pdf", dataSource, "");
using Wordize.Reporting;
using Wordize.Saving;
var dataSource = new XmlDataSource("data.xml");
var imageStreams = ReportBuilder.BuildReportToImages("Input.pdf",
new ImageSaveOptions(SaveFormat.Pdf), new[] { dataSource }, new[] { "" });
foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i)))
{
using var _ = stream;
stream.Position = 0;
using var file = File.Create($"Output_{page + 1}.pdf");
stream.CopyTo(file);
}
using Wordize.Reporting;
var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true });
ReportBuilder.BuildReport("Input.pdf", "Output.pdf", dataSource, "");
using Wordize.Reporting;
var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true });
ReportBuilder.BuildReport("Input.pdf", "Output.pdf", dataSource, "");
using Wordize.Reporting;
using Wordize.Saving;
var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true });
var imageStreams = ReportBuilder.BuildReportToImages("Input.pdf",
new ImageSaveOptions(SaveFormat.Pdf), new[] { dataSource }, new[] { "" });
foreach (var (stream, page) in imageStreams.Select((s, i) => (s, i)))
{
using var _ = stream;
stream.Position = 0;
using var file = File.Create($"Output_{page + 1}.pdf");
stream.CopyTo(file);
}