gpt4 book ai didi

model-view-controller - 使用 EPPlus 读取 Excel 电子表格

转载 作者:行者123 更新时间:2023-12-03 14:49:19 27 4
gpt4 key购买 nike

有人可以为我指出如何阅读 Excel 电子表格、遍历所有行和列以使用 EPPlus 和 MVC 检索值的正确方向吗?到目前为止,我看到了创建电子表格的示例,但在打开 excel 文件并从中读取值时没有找到任何示例。任何帮助,将不胜感激。

TIA
起诉..

最佳答案

简单的例子

// Get the file we are going to process
var existingFile = new FileInfo(filePath);
// Open and read the XlSX file.
using (var package = new ExcelPackage(existingFile))
{
// Get the work book in the file
var workBook = package.Workbook;
if (workBook != null)
{
if (workBook.Worksheets.Count > 0)
{
// Get the first worksheet
var currentWorksheet = workBook.Worksheets.First();

// read some data
object col1Header = currentWorksheet.Cells[1, 1].Value;

关于model-view-controller - 使用 EPPlus 读取 Excel 电子表格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11685204/

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