java给HSSFSheet设置宽度_HSSFWorkbook设置(行高,字体,换行,颜色)

论坛 期权论坛 编程之家     
选择匿名的用户   2021-6-2 21:00   4252   0

private static void ToEXecl(DataTable tblDatas)

{

String strFileName = "F:/excel/BBS.xls";

HSSFWorkbook workbook = new HSSFWorkbook();

HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("new sheet");

// 设置列宽

sheet.SetColumnWidth(0,1500);

sheet.SetColumnWidth(1, 8000);

sheet.SetColumnWidth(2, 4000);

sheet.SetColumnWidth(3, 5000);

sheet.SetColumnWidth(4, 5000);

sheet.SetColumnWidth(5, 16000);

sheet.SetColumnWidth(6, 3000);

sheet.SetColumnWidth(7, 6000);

sheet.SetColumnWidth(8, 12000);

HSSFFont font1 = workbook.CreateFont();

font1.FontName="宋体";

font1.FontHeightInPoints=16;

//表头样式

HSSFCellStyle style1 = workbook.CreateCellStyle();

//颜色要两行

style1.FillForegroundColor = HSSFColor.YELLOW.index;

style1.FillPattern = CellF

分享到 :
0 人收藏
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

积分:3875789
帖子:775174
精华:0
期权论坛 期权论坛
发布
内容

下载期权论坛手机APP