有没有可用的包或工具可以在Groovy中读取Excel文件。我正在寻找类似于Groovy SQL的rows函数的东西,就像下面的spock测试示例中所示。我的意图是在Spock测试框架中使用它进行使用Excel进行数据驱动的测试。[链接]
import groovy.sql.Sql
import spock.lang.*
class DatabaseDriven extends Specification {
@Shared sql = Sql.newInstance("jdbc:h2:mem:", "org.h2.Driver")
// normally an external database would be used,
// and the test data wouldn't have to be inserted here
def setupSpec() {
sql.execute("create table maxdata (id int primary key, a int, b int, c int)")
sql.execute("insert into maxdata values (1, 3, 7, 7), (2, 5, 4, 5), (3, 9, 9, 9)")
}
def "maximum of two numbers"() {
expect:
Math.max(a, b) == c
where:
[a, b, c] << sql.rows("select a, b, c from maxdata")
}
}