Deutsch Indonesia Tiếng Việt فارسی English Italiano Türkçe ไทย Español Polski Русский 日本語 Français Português العربية

การสร้างเอกสารจากแม่แบบใน C#

Wordize for .NET เป็นโซลูชันระดับมืออาชีพสำหรับการทำรายงานอัตโนมัติและการสร้างเอกสารแบบโปรแกรม คลาส ReportBuilder ให้ความสามารถแก่นักพัฒนา C# ในการสร้างรายงานโดยใช้แม่แบบและไวยากรณ์ LINQ ซึ่งช่วยเร่งกระบวนการ Business Intelligence นำเนื้อหาแบบไดนามิกไปใช้ในระบบเอกสารอัตโนมัติ

ความสามารถหลัก:
  • การสร้างรายงานแบบโปรแกรม - คลาส ReportBuilder มีเมธอด BuildReport() สำหรับสร้างเอกสารจากแม่แบบ
  • การรวมเข้ากับแหล่งข้อมูลอย่างยืดหยุ่น - รองรับ JSON, XML, CSV และอ็อบเจกต์โปรแกรม (คลาสที่กำหนดเอง, คอลเลกชันของอ็อบเจกต์)
  • การใช้นิพจน์ LINQ สำหรับการกรอง เรียงลำดับ และจัดกลุ่มข้อมูลเมื่อสร้างเอกสาร
  • การกำหนดค่าพารามิเตอร์การสร้าง - คลาส ReportBuilderOptions จัดการประเภทข้อมูลที่มี การจัดการฟิลด์ที่หายไป การลบย่อหน้าว่าง และพารามิเตอร์อื่นๆ ของการสร้างรายงาน
  • การส่งออกเป็นรูปแบบกราฟิก - เมธอด BuildReportToImages() ส่งคืนหน้ารายงานเป็นอาร์เรย์ของภาพ
  • รองรับ Fluent API สำหรับเรียกใช้การสร้างรายงานผ่าน ReportBuilderContext และการเชื่อมโยงเมธอด เพิ่มความชัดเจนให้กับโค้ด C#

ทดสอบความสามารถการสร้างรายงานแบบโปรแกรมในการสาธิตแบบโต้ตอบออนไลน์ที่แสดงในหน้านี้ อัปโหลดแม่แบบเอกสาร ไฟล์ข้อมูล (JSON, XML หรือ CSV) เรียกใช้การดำเนินการและดาวน์โหลดเอกสารที่สร้างขึ้นเพื่อตรวจสอบ โค้ด C# ที่ให้มาพร้อมใช้งานในโปรเจ็กต์ .NET ของคุณ

C#
รันโค้ด
อัปโหลดแม่แบบเอกสาร
อัปโหลดไฟล์ข้อมูล
เลือกรูปแบบเอาต์พุตจากรายการ
using Wordize.Reporting;

var dataSource = new JsonDataSource("data.json");
ReportBuilder.BuildReport("Input.docx", "Output.pdf", dataSource, "");
using Wordize.Reporting; var dataSource = new JsonDataSource("data.json"); ReportBuilder.BuildReport("Input.docx", "Output.pdf", dataSource, ""); using Wordize.Reporting; using Wordize.Saving; var dataSource = new JsonDataSource("data.json"); var imageStreams = ReportBuilder.BuildReportToImages("Input.docx", 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.docx", "Output.pdf", dataSource, "");
using Wordize.Reporting; var dataSource = new XmlDataSource("data.xml"); ReportBuilder.BuildReport("Input.docx", "Output.pdf", dataSource, ""); using Wordize.Reporting; using Wordize.Saving; var dataSource = new XmlDataSource("data.xml"); var imageStreams = ReportBuilder.BuildReportToImages("Input.docx", 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.docx", "Output.pdf", dataSource, "");
using Wordize.Reporting; var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true }); ReportBuilder.BuildReport("Input.docx", "Output.pdf", dataSource, ""); using Wordize.Reporting; using Wordize.Saving; var dataSource = new CsvDataSource("data.csv", new CsvDataLoadOptions() { HasHeaders = true }); var imageStreams = ReportBuilder.BuildReportToImages("Input.docx", 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); }
รันโค้ด

วิธีสร้างรายงานใน C#

  1. เชื่อมต่อ Wordize SDK กับโปรเจ็กต์ .NET ของคุณ
  2. สร้างแหล่งข้อมูลและเรียกเมธอด ReportBuilder.BuildReport() ระบุในพารามิเตอร์แม่แบบเอกสาร ไฟล์ผลลัพธ์ และแหล่งข้อมูล
  3. รับเอกสารที่สร้างขึ้น
5%