【GcExcel v6.0 新特性预览】支持在区域内使用 GetUsedRange 方法
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;
worksheet.Range["B5"].Value = "grapecity";
worksheet.Range["D9"].Value = "grapecity";
worksheet.Range["F7"].Value = "grapecity";
// The range1 is B5:D9
IRange range1 = workbook.Worksheets.Range["B3:E10"].GetUsedRange(UsedRangeType.Data);
// The range2 is F7
IRange range2 = workbook.Worksheets.Range["E1:F8"].UsedRange;
演示demo链接
[*]https://en.onboarding.grapecitydev.com/documents-api-excel/demos/getrangeusedrange
[*]https://en.onboarding.grapecitydev.com/documents-api-excel-java/demos/getrangeusedrange
[*]https://en.onboarding.grapecitydev.com/documents-api-excel/demos/getfeatureforusedrange
[*]https://en.onboarding.grapecitydev.com/documents-api-excel-java/demos/getfeatureforusedrange
页:
[1]