gpt4 book ai didi

c# - 如何读取一系列单元格(例如 A1 :G30) from Excel file to GridView

转载 作者:太空宇宙 更新时间:2023-11-03 10:22:11 25 4
gpt4 key购买 nike

过去几天我一直在寻找解决方案,我发现这个库 EPPlus 允许同时检索除实际数据之外的格式,如果需要,还可以从 Excel 文件中检索图表,这正是我的目标此刻。

能否请您逐步向我解释如何通过 ASP.NET/C# 从位于特定路径的 Excel(如 A1:P34)文件中读取一系列单元格?

PATH would be something like //ServerName/Folder1/Folder2/Folder3/ExcelFileName.xlsx

我查看了网络,但没有针对我的 C# 专业水平的明确文档。我尝试了几个示例,但没有一个示例将 Excel 范围显示到网页中。 (例如 this one 。)

Note: the three examples I have tried all included an File Upload Control, I do not need such. I want to read the Excel file from a specified location over the local network.

EPPlus 库可用 here .

如果你能推荐我任何更简单的资源来理解 EPPlus:
- 从 Excel 读取
-从 Excel 中写入
-从Excel读取图表

这个 EPPlus 的功能看起来确实很棒。

最佳答案

要从服务器读取文件,请看这个:

Open ExcelPackage Object with Excel application without saving it on local file path

只需要为您的文件设置var path部分。

要真正把excel数据放到网页上,可不是那么容易的。看这个:

Generating a HTML table from an Excel file using EPPlus?

对评论的回应:

在网页中托管一个实际的 Excel 工作表充其量是喜怒无常的,但有很多方法可以做到(我没有亲自尝试过)。如果可用,SharePoint 可能是您的最佳选择。如果没有,您将不得不使用 iFrame 或某种办公网络组件。检查一下:

how to display excel sheet in html page

关于c# - 如何读取一系列单元格(例如 A1 :G30) from Excel file to GridView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33040094/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com