合并Excel范围
IronXL 允许我们使用 "+"运算符组合多个 `IronXL.Ranges.Range'。
using IronXL; using System; using System.Linq; WorkBook workBook = WorkBook.Load("sample.xls"); WorkSheet workSheet = workBook.WorkSheets.First(); // Get a range from an Excel worksheet var range = workSheet["A2:A8"]; // Combine two ranges var combinedRange = range + workSheet["A9:A10"]; // Iterate over combined range foreach (var cell in combinedRange) { Console.WriteLine(cell.Value); }
Imports IronXL Imports System Imports System.Linq Private workBook As WorkBook = WorkBook.Load("sample.xls") Private workSheet As WorkSheet = workBook.WorkSheets.First() ' Get a range from an Excel worksheet Private range = workSheet("A2:A8") ' Combine two ranges Private combinedRange = range + workSheet("A9:A10") ' Iterate over combined range For Each cell In combinedRange Console.WriteLine(cell.Value) Next cell
Install-Package IronXL.Excel
IronXL 允许我们使用 "+"运算符组合多个 `IronXL.Ranges.Range'。