Apache POI中行的自动大小高度 [英] Auto size height for rows in Apache POI

查看:163
本文介绍了Apache POI中行的自动大小高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Apache POI将值输入到电子表格中。这些值具有换行符,我可以成功地使用此代码:

  CellStyle style = cell.getCellStyle()
style.setWrapText(true)
cell.setCellStyle(style)

不幸的是,文本正确包装,行数并不总是足够高以显示内容。如何确保我的行总是正确的高度?

解决方案

  HSSFWorkbook工作簿=新HSSFWorkbook(); 
HSSFSheet sheet = workbook.createSheet(FirstSheet);
HSSFRow rowhead = sheet.createRow((short)0);
HSSFCellStyle style = workbook.createCellStyle();
style.setWrapText(true);
row.setRowStyle(style);
row.getCell(0).setCellStyle(style);

上述代码将生成动态高位行


I am inputting values into a spreadsheet using Apache POI. These values have newlines, and I was able to use this code successfully:

CellStyle style = cell.getCellStyle()
style.setWrapText(true)
cell.setCellStyle(style)

Unfortunately, while the text is wrapping correctly, the rows are not always growing in height enough to show the content. How do I ensure that my rows are always the correct height?

解决方案

            HSSFWorkbook workbook=new HSSFWorkbook();
            HSSFSheet sheet =  workbook.createSheet("FirstSheet");  
            HSSFRow rowhead=   sheet.createRow((short)0);
            HSSFCellStyle style = workbook.createCellStyle();
            style.setWrapText(true);
            row.setRowStyle(style);
            row.getCell(0).setCellStyle(style);

the above code will generate dynamic hight of rows

这篇关于Apache POI中行的自动大小高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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