本文概述
大纲非常适合将信息部分分组在一起。使用POI API的方法可以轻松地将其添加到列和行中。
让我们看一个应用大纲的例子。
Apache POI概述示例
package poiexample;
import java.io.FileOutputStream;
import java.io.OutputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
public class OutlineExample {
public static void main(String[] args) {
try (OutputStream fileOut = new FileOutputStream("srcmini.xls")) {
Workbook wb = new HSSFWorkbook();
Sheet sheet1 = wb.createSheet("Sheet");
sheet1.groupRow( 4, 10 );
sheet1.groupColumn( 2, 8 );
wb.write(fileOut);
}catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
输出:
评论前必须登录!
注册