当前位置:网站首页>如何在报表控件FastReport.NET中连接XLSX 文件作为数据源?
如何在报表控件FastReport.NET中连接XLSX 文件作为数据源?
2022-08-10 05:22:00 【山城码农一哥】
本文主要介绍如何在FastReport.NET中用一个插件来连接XLSX 文件作为数据源。
若要使用它,必须首先生成项目:
С:\Program Files (x86)\FastReports\FastReport.Net\Extras\Core\FastReport.Data\FastReport.Data.Excel
构建项目后,您需要通过以下两种方式之一将插件添加到应用程序中。
数据源连接完成后,需要将波段连接到该波段。
最终报表将使用从创建的 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.Utils.RegisteredObjects.AddConnection(typeof(ExcelDataConnection));
要创建与Excel的连接,您需要单击设计器中的“数据”选项卡,然后选择“添加数据源”项。在出现的窗口中,单击“新建连接”按钮。要进行连接,您需要 .XLSX 文件。如果访问文件没有问题,则在单击“下一步”按钮后将显示表列表。连接表时,必须选中表名称左侧的框。之后,您可以完成连接。
本次FastReport.NET使用教程就介绍到这里了, 更多产品授权信息可以直接私我哦!
边栏推荐
- FPGA engineer interview questions collection 31~40
- Joomla vulnerability reproduced
- 【LeetCode】41. The first missing positive number
- Hezhou ESP32C3 +1.8"tft network clock under Arduino framework
- leetcode每天5题-Day11
- flex 相关
- Conda creates a virtual environment method and pqi uses a domestic mirror source to install a third-party library method tutorial
- An article to master the entire JVM, JVM ultra-detailed analysis!!!
- Order table delete, insert and search operations
- awk of the Three Musketeers of Shell Programming
猜你喜欢
Arduino框架下合宙ESP32C3 +1.8“tft 网络时钟
ThreadPoolExecutor thread pool principle
OAuth2 usage scenarios, common misunderstandings, use cases
看了几十篇轻量化目标检测论文扫盲做的摘抄笔记
动手写prometheus的exporter-02-Counter(计数器)
How does Jenkins play with interface automation testing?
接口调试还能这么玩?
canvas canvas drawing clock
Get started with the OAuth protocol easily with a case
Rpc interface stress test
随机推荐
Jenkins 如何玩转接口自动化测试?
基于BP神经网络的多因素房屋价格预测matlab仿真
FPGA工程师面试试题集锦41~50
leetcode每天5题-Day13
软考考生注意!2022年下半年报名详细流程来了!
线性代数(四)
Shell编程三剑客之awk
抽象问题方法论
接口调试还能这么玩?
Flutter开发:报错The following assertion was thrown resolving an image codec:Unable to…的解决方法
Concurrency tool class - introduction and use of CountDownLatch, CyclicBarrier, Semaphore, Exchanger
canvas 画布绘制时钟
请教一下各位大佬。CDC社区中FlinkCDC2.2.0版本有说明支持的sqlserver版本 ,请
【LeetCode】41. The first missing positive number
When oracle cdc, set the parallelism to 2 and the number of slots to 1, and the final task has only one tm. Is it because oracle does not support concurrency
Practical skills 19: Several postures of List to Map List
聊聊 API 管理-开源版 到 SaaS 版
How does flinksql write that the value of redis has only the last field?
【Static proxy】
I have a dream for Career .