为 POI 生成的 Excel 文件中的单元格添加边框 [英] Add borders to cells in POI generated Excel File

查看:22
本文介绍了为 POI 生成的 Excel 文件中的单元格添加边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 POI 生成 Excel 文件.我需要为工作表中的特定单元格添加边框.

I am using POI to generate an Excel File. I need to add borders to specific cells in the worksheet.

我怎样才能做到这一点?

How can I accomplish this?

推荐答案

在单元格中使用的样式中设置边框将实现此目的.示例:

Setting up borders in the style used in the cells will accomplish this. Example:

style.setBorderBottom(HSSFCellStyle.BORDER_MEDIUM);
style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM);
style.setBorderRight(HSSFCellStyle.BORDER_MEDIUM);
style.setBorderLeft(HSSFCellStyle.BORDER_MEDIUM);

这篇关于为 POI 生成的 Excel 文件中的单元格添加边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆