Skip to content

Commit

Permalink
Groovy script example: Use latest POI and fix to run again
Browse files Browse the repository at this point in the history
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
  • Loading branch information
centic9 committed Nov 30, 2024
1 parent 3e0306d commit 33f944f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,9 @@ rat {
"osgi/README.md",
"src/resources/ooxml-lite-report.*",
// ignore svn conflict artifacts
"**/module-info.*"
"**/module-info.*",
"poi-examples/src/main/groovy/settings.gradle",
"poi-examples/src/main/groovy/.gradle/**"
]

/*
Expand Down
4 changes: 2 additions & 2 deletions poi-examples/src/main/groovy/SpreadSheetDemo.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ WorkbookFactory.create(f,null,true).withCloseable { workbook ->

def sheet = workbook.getSheetAt(sheetNum)
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:"
nonEmptyCells.each { c ->
def cRef = [c] as CellReference
Expand All @@ -52,7 +52,7 @@ WorkbookFactory.create(f,null,true).withCloseable { workbook ->
ns1.createRow(1).createCell(0).setCellValue("TODO - Populate with data")

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[])
ns2.createRow(2).createCell(0).setCellValue(1)
ns2.createRow(3).createCell(0).setCellValue(4)
Expand Down
9 changes: 5 additions & 4 deletions poi-examples/src/main/groovy/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ apply plugin: 'groovy'
repositories {
mavenCentral()
}

dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.21'
compile 'org.apache.poi:poi:5.2.1'
compile 'org.apache.poi:poi-ooxml:5.2.1'
implementation 'org.codehaus.groovy:groovy-all:2.4.21'
implementation 'org.apache.poi:poi:5.3.0'
implementation 'org.apache.poi:poi-ooxml:5.3.0'
}

// Our files are in the current directory
Expand All @@ -38,6 +39,6 @@ tasks.withType(JavaExec) {
}
task runScript(type: JavaExec) {
mainClass = "SpreadSheetDemo"
args = ["../../../test-data/spreadsheet/Simple.xls"]
args = ["../../../../test-data/spreadsheet/Simple.xls"]
}
defaultTasks 'runScript'
1 change: 1 addition & 0 deletions poi-examples/src/main/groovy/settings.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// empty file required to have a standalone build

0 comments on commit 33f944f

Please sign in to comment.