Reading Excel spreasheet using EPPlus

前端 未结 2 1091
小鲜肉
小鲜肉 2020-12-09 16:54

Could someone point me in the right direction on how to read a Excel spreasheet, loop through all the rows and columns to retreive value using EPPlus and MVC? So fare I see

2条回答
  •  执笔经年
    2020-12-09 17:21

    Simple example

    // 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;
    

提交回复
热议问题