0

感谢http://www.technipelago.se/content/technipelago/blog/44 可以通过行迭代器和列名访问 excel 单元格。但似乎无法通过名称包含空格的列名进行访问。请给我一些关于如何在 ExcelBulider 上下文中通过带有空格的偶数名称访问单元格的指示。以下是用于说明的示例:

new ExcelBuilder("customers.xls").eachLine([labels:true]) {
    print firsname // this already possible
    print <a column name with space> // I wish to have
}

firstname列名在哪里。我希望可以使用空格访问另一列名称。

我可以使用字典来封装从列名到列 inedx 的映射,以在 ExcelBuilder 之外实现按列访问的逻辑,但我希望它更多地封装在 ExcelBuilder 中的一个地方/逻辑中。

也许,我对 POI 和 Groovy 的 builder 技术还没有足够的了解。

请帮忙!

谢谢,

4

1 回答 1

2

这应该有效:

new ExcelBuilder("customers.xls").eachLine([labels:true]) {
    print firsname
    print delegate.'a column name with space'
}
于 2012-12-04T09:36:19.427 回答