合併 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
。