poi-tl 表格控制行高
时间: 2024-07-07 15:00:35 浏览: 219
POI-TL是Apache POI库的一个Java工具类,它提供了一种更方便的方式来处理Microsoft Office(如Excel)文件。在使用POI-TL时,如果你想控制单元格的行高,可以通过`HSSFRow`或`XSSFRow`对象的`setRowHeight()`方法来实现。
例如,如果你已经创建了一个`HSSFRow`对象,你可以这样做:
```java
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
// 假设wb是已经打开的Workbook对象,sheet是对应的Sheet
Row row = sheet.createRow(0); // 创建新行
int newRowHeight = 20; // 想设置的行高值(以磅为单位)
row.setHeight(newRowHeight); // 设置行高
```
对于`XSSFRow`,操作类似:
```java
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
XSSFSheet xssfsheet = (XSSFSheet) workbook.getSheetAt(0);
Row xSSFRow = xssfsheet.createRow(0);
xSSFRow.setHeightInPoints(newRowHeight); // 使用点作为单位
```
阅读全文
相关推荐













