Groovy script example: Use latest POI and fix to run again

Fix path to test-file
Fix changed constants
Add settings.gradle
Adjust Rat exclusions

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1922229 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2024-11-30 09:29:43 +00:00
parent 3e0306d253
commit 33f944f922
4 changed files with 11 additions and 7 deletions

View File

@ -708,7 +708,9 @@ rat {
"osgi/README.md", "osgi/README.md",
"src/resources/ooxml-lite-report.*", "src/resources/ooxml-lite-report.*",
// ignore svn conflict artifacts // ignore svn conflict artifacts
"**/module-info.*" "**/module-info.*",
"poi-examples/src/main/groovy/settings.gradle",
"poi-examples/src/main/groovy/.gradle/**"
] ]
/* /*

View File

@ -36,7 +36,7 @@ WorkbookFactory.create(f,null,true).withCloseable { workbook ->
def sheet = workbook.getSheetAt(sheetNum) def sheet = workbook.getSheetAt(sheetNum)
sheet.each { row -> sheet.each { row ->
def nonEmptyCells = row.grep { c -> c.getCellType() != Cell.CELL_TYPE_BLANK } def nonEmptyCells = row.grep { c -> c.getCellType() != CellType.BLANK }
println " Row ${row.getRowNum()} has ${nonEmptyCells.size()} non-empty cells:" println " Row ${row.getRowNum()} has ${nonEmptyCells.size()} non-empty cells:"
nonEmptyCells.each { c -> nonEmptyCells.each { c ->
def cRef = [c] as CellReference def cRef = [c] as CellReference
@ -52,7 +52,7 @@ WorkbookFactory.create(f,null,true).withCloseable { workbook ->
ns1.createRow(1).createCell(0).setCellValue("TODO - Populate with data") ns1.createRow(1).createCell(0).setCellValue("TODO - Populate with data")
Sheet ns2 = workbook.createSheet("Generated 2") Sheet ns2 = workbook.createSheet("Generated 2")
exportHeader(ns2, headerStyle, "This is a demo sheet", exportHeader(ns2, headerStyle, "This is a demo sheet",
["ID","Title","Date","Author","Num"] as String[]) ["ID","Title","Date","Author","Num"] as String[])
ns2.createRow(2).createCell(0).setCellValue(1) ns2.createRow(2).createCell(0).setCellValue(1)
ns2.createRow(3).createCell(0).setCellValue(4) ns2.createRow(3).createCell(0).setCellValue(4)

View File

@ -21,10 +21,11 @@ apply plugin: 'groovy'
repositories { repositories {
mavenCentral() mavenCentral()
} }
dependencies { dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.21' implementation 'org.codehaus.groovy:groovy-all:2.4.21'
compile 'org.apache.poi:poi:5.2.1' implementation 'org.apache.poi:poi:5.3.0'
compile 'org.apache.poi:poi-ooxml:5.2.1' implementation 'org.apache.poi:poi-ooxml:5.3.0'
} }
// Our files are in the current directory // Our files are in the current directory
@ -38,6 +39,6 @@ tasks.withType(JavaExec) {
} }
task runScript(type: JavaExec) { task runScript(type: JavaExec) {
mainClass = "SpreadSheetDemo" mainClass = "SpreadSheetDemo"
args = ["../../../test-data/spreadsheet/Simple.xls"] args = ["../../../../test-data/spreadsheet/Simple.xls"]
} }
defaultTasks 'runScript' defaultTasks 'runScript'

View File

@ -0,0 +1 @@
// empty file required to have a standalone build