我正在尝试编写一个Groovy脚本,该脚本将在excel xls表上写入某些数据。到目前为止,我已设法创建它,以便我可以编写文本并定义文本的字体和大小,但我还要定义文本和单元格颜色以及对齐格式。
我正在使用这个脚本:
WritableWorkbook workbook1 = Workbook.createWorkbook(new File("PathToFile.xls"))
WritableSheet sheet1 = workbook1.createSheet("Worksheet Number 1", 0)
WritableCellFormat formatRight = new WritableCellFormat()
formatRight.setAlignment(Alignment.RIGHT)
WritableFont cellFont = new WritableFont(WritableFont.ARIAL, 11)
cellFont.setBoldStyle(WritableFont.BOLD)
WritableCellFormat setBold = new WritableCellFormat(cellFont);
log.info(sheet1.isHidden())
Label label_0 = new Label(0, 0, "CutomText", setBold)
sheet1.addCell(label_0)
workbook1.write()
workbook1.close()
您可以帮我定义这些属性吗?