IronXL C# .NET 的 Excel 試算表程式庫

如何在C#中從Excel中讀取資料

  1. 讀取資料或Excel 教程
  2. C#開發者的C# Excel 讀取器
  3. 值得信賴的C# Excel 程式庫

或者直接下載DLL 這裡

無需 Interop 即可讀取 Excel 檔案
查看所有 程式碼範例
using IronXL;
using System;
using System.Linq;

// Supported for XLSX, XLS, XLSM, XLTX, CSV and TSV
WorkBook workBook = WorkBook.Load("sample.xlsx");

// Select worksheet at index 0
WorkSheet workSheet = workBook.WorkSheets[0];

// Get any existing worksheet
WorkSheet firstSheet = workBook.DefaultWorkSheet;

// Select a cell and return the converted value
int cellValue = workSheet["A2"].IntValue;

// Read from ranges of cells elegantly.
foreach (var cell in workSheet["A2:A10"])
{
    Console.WriteLine("Cell {0} has value '{1}'", cell.AddressString, cell.Text);
}

// Calculate aggregate values such as Min, Max and Sum
decimal sum = workSheet["A2:A10"].Sum();

// Linq compatible
decimal max = workSheet["A2:A10"].Max(c => c.DecimalValue);
NuGet Downloads Badge
PM >Install-Package IronXL.Excel
探索程式碼並運行它以查看範例PDF