How do I insert an entire blank row at the top of my test1.xls in Groovy/POI? I am so close to finishing my project and this is the last piece of the puzzle. Your help is greatly appreciated.
@Grab( 'org.apache.poi:poi:3.9' )
import static org.apache.poi.ss.usermodel.CellStyle.*
import static org.apache.poi.ss.usermodel.IndexedColors.*
import org.apache.poi.hssf.usermodel.HSSFWorkbook
import org.apache.poi.hssf.usermodel.*
import org.apache.poi.ss.usermodel.Cell
import org.apache.poi.ss.util.CellRangeAddress
// Open the spreadsheet
new File( 'C:\\test1.xls' ).withInputStream { ins ->
new HSSFWorkbook( ins ).with { workbook ->
getSheetAt( 0 ).with { sheet ->
getRow( 0 ).getCell( 0 ).setCellValue( 'ID' )
getRow( 0 ).getCell( 1 ).setCellValue( 'Start Date' )
getRow( 0 ).getCell( 2 ).setCellValue( 'End Date' )
getRow( 0 ).getCell( 3 ).setCellValue( 'Status' )
getRow( 0 ).getCell( 4 ).setCellValue( 'Instrusive' )
getRow( 0 ).getCell( 5 ).setCellValue( 'State(s) Impacted' )
getRow( 0 ).getCell( 6 ).setCellValue( 'Impacted' )
}
new File( 'C:\\test2.xls' ).withOutputStream { os ->
write( os )
}
}
}