本文主要介紹如何在FastReport.NET中用一個插件來連接XLSX 文件作為數據源。
FastReport .Net官方最新版免費下載試用,曆史版本下載,在線文檔和幫助文件下載-慧都網
若要使用它,必須首先生成項目:
С:\Program Files (x86)\FastReports\FastReport.Net\Extras\Core\FastReport.Data\FastReport.Data.Excel
構建項目後,您需要通過以下兩種方式之一将插件添加到應用程序中。
FastReport.NET
如果訪問文件沒有問題,則在單擊“下一步”按鈕後将顯示表列表。連接表時,必須選中表名稱左側的框。之後,您可以完成連接。
FastReport.NET
數據源連接完成後,需要将波段連接到該波段。
最終報表将使用從創建的 Excel 連接到的數據。
從代碼連接到 Excel 的示例:
// Create ExcelDataConnection instance var connection = new ExcelDataConnection();
// Set connection string connection.ConnectionString = @"C:\Matrix With Rows Only.xlsx"; // Initialize all table connection.CreateAllTables();
// Set name connection connection.Name = "NewConnection";
// Create Report instance var report = new Report();
// Add connection to report report.Dictionary.Connections.Add(connection);
// Set connection show connection.Enabled = true;
// Choose all tables and connect it to the report foreach (TableDataSource table in connection.Tables) { table.Enabled = true; }
執行此代碼,我們可以在設計器中看到與表的新連接。這将顯示在可用連接列表中。值得注意的是,“工作表”的名稱用作表名稱,列的名稱用作字段名稱。
本次FastReport.NET使用教程就介紹到這裡了, 更多産品授權信息點擊查看FastReport.NET價格,或者咨詢慧都在線客服。
FastReport .Net正版購買,FastReport .Net授權價格咨詢,FastReport .Net官方授權經銷商-慧都網
,更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!