合并Excel范围
from ironxl import *

# Load existing spreadsheet
workbook = WorkBook.Load("sample.xls")
worksheet = workbook.WorkSheets[0]

# Get a range from an Excel worksheet
selected_range = worksheet["A2:A8"]

# Combine two ranges
combined_range = selected_range + worksheet["A9:A10"]

# Iterate over the combined range
for cell in combined_range:
    print(cell.Value)
pip install ironxl
合并Excel范围

合并Excel范围

IronXL for Python 提供了一种高效的方法来操作Excel文件,包括使用+操作符合并Range对象的能力。

使用+操作符合并Range对象是一种将多个不连续单元格组作为单个实体处理的多功能方法。 这在从工作表的不同部分汇总数据时特别有用——例如,在一组区域的联合上应用单一的格式规则或计算,而无需编写重复的选择逻辑。

探讨如何使用IronXL for Python写入Excel

准备开始了吗?

版本:2026.11刚刚发布