Java 中如何给POI生成的Excel文件添加 Border?
Java 中如何给POI生成的Excel文件添加 Border,
如下图所示:
回答:
补充一下上面AI中的Main方法:
/*https://demo.grapecity.com.cn/documents-api-excel-java/demos/
addingborderstorange?devLang=java
*/
// Create a new workbook
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
IRange rangeB2_E6 = worksheet.getRange("B2:E6");
//set left, top, right, bottom borders together.
rangeB2_E6.getBorders().setLineStyle(BorderLineStyle.DashDot);
rangeB2_E6.getBorders().setColor(Color.GetGreen());
//set inside horizontal border.
rangeB2_E6.getBorders().get(BordersIndex.InsideHorizontal).setLineStyle(BorderLineStyle.Dashed);
rangeB2_E6.getBorders().get(BordersIndex.InsideHorizontal).setColor(Color.GetTomato());
//set inside vertical border.
rangeB2_E6.getBorders().get(BordersIndex.InsideVertical).setLineStyle(BorderLineStyle.Double);
rangeB2_E6.getBorders().get(BordersIndex.InsideVertical).setColor(Color.GetBlue());
//set top border individually.
rangeB2_E6.getBorders().get(BordersIndex.EdgeTop).setLineStyle(BorderLineStyle.Medium);
rangeB2_E6.getBorders().get(BordersIndex.EdgeTop).setColor(Color.GetRed());
// Save to an excel file
workbook.save("AddingBordersToRange.xlsx");
以上是 Java 中如何给POI生成的Excel文件添加 Border? 的全部内容, 来源链接: utcz.com/p/945381.html