Spreadsheet builder provides convenient way how to create MS Excel OfficeOpenXML Documents (XSLX) focus not only on content side but also on easy styling.
See the Full Documentation
Following example creates the basic spreadsheet with two rows and three columns.
@Grab(group='org.modelcatalogue', module='spreadsheet-builder-poi', version='{version}')
// fixes bugs on Groovy 2.4.x
@Grab(group='commons-codec', module='commons-codec', version='1.10')
@GrabExclude('org.codehaus.groovy:groovy-all')
import org.modelcatalogue.builder.spreadsheet.poi.PoiSpreadsheetBuilder
def builder = new PoiSpreadsheetBuilder() // <1>
File file = new File('spreadsheet.xlsx')
file.withOutputStream { out ->
builder.build(out) { // <2>
sheet('Sample') { // <3>
row { // <4>
cell 'A' // <5>
cell 'B'
cell 'C'
}
row {
cell 1
cell 2
cell 3
}
}
}
}
-
Create new spreadsheet builder based on Apache POI (currently the only implementation provided)
-
Build new spreadsheet and write it to the output stream
-
Create new sheet with the name
Sample
-
Create new row
-
Create new cell
This project is inspired by Groovy Document Builder