From 33f944f922df09209757ccbf731f609814c4da95 Mon Sep 17 00:00:00 2001 From: Dominik Stadler Date: Sat, 30 Nov 2024 09:29:43 +0000 Subject: 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 --- poi-examples/src/main/groovy/SpreadSheetDemo.groovy | 4 ++-- poi-examples/src/main/groovy/build.gradle | 9 +++++---- poi-examples/src/main/groovy/settings.gradle | 1 + 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100644 poi-examples/src/main/groovy/settings.gradle (limited to 'poi-examples') diff --git a/poi-examples/src/main/groovy/SpreadSheetDemo.groovy b/poi-examples/src/main/groovy/SpreadSheetDemo.groovy index b9f30c0ce6..0789b56a70 100644 --- a/poi-examples/src/main/groovy/SpreadSheetDemo.groovy +++ b/poi-examples/src/main/groovy/SpreadSheetDemo.groovy @@ -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 @@ -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) diff --git a/poi-examples/src/main/groovy/build.gradle b/poi-examples/src/main/groovy/build.gradle index 653471e501..784d5c1378 100644 --- a/poi-examples/src/main/groovy/build.gradle +++ b/poi-examples/src/main/groovy/build.gradle @@ -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 @@ -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' diff --git a/poi-examples/src/main/groovy/settings.gradle b/poi-examples/src/main/groovy/settings.gradle new file mode 100644 index 0000000000..147d00bb9c --- /dev/null +++ b/poi-examples/src/main/groovy/settings.gradle @@ -0,0 +1 @@ +// empty file required to have a standalone build -- cgit v1.2.3