GcExcel v6.0支持 Range 中的 GetUsedRange 方法
背景:
GcExcel 在工作表中提供了UsedRange 属性和GetUsedRange 方法来获取所有使用范围,但客户有时需要获取所选范围内的使用范围。
所以我们在Range上提供一些类似于工作表UsedRange的方法给客户。 API: - /// <summary>
- /// Represents the IRange object.
- /// </summary>
- public interface IRange
- {
- /// <summary>
- /// Returns an <see cref="IRange"/> representing the used range in the current range.
- /// </summary>
- IRange UsedRange { get; }
-
- /// <summary>
- /// Gets an <see cref="IRange"/> representing the used range in the current range.
- /// </summary>
- /// <param name="type">The feature type.</param>
- /// <returns></returns>
- IRange GetUsedRange(UsedRangeType type = UsedRangeType.All);
- }
复制代码示例代码:
- Workbook workbook = new Workbook();
- IWorksheet worksheet = workbook.Worksheets[0];
- worksheet.Range["B5"].Value = "grapecity";
- worksheet.Range["D9"].Value = "grapecity";
- worksheet.Range["F7"].Value = "grapecity";
-
- // The range1 is B5:D9
- IRange range1 = workbook.Worksheets[0].Range["B3:E10"].GetUsedRange(UsedRangeType.Data);
-
- // The range2 is F7
- IRange range2 = workbook.Worksheets[0].Range["E1:F8"].UsedRange;
复制代码演示demo链接
|