本文概述
- Apache POI工作簿表示例
- 名称不得超过31个字符。
- 不得包含以下任何字符(0x0000、0x0003,冒号(:),反斜杠(\),星号(*),问号(?),正斜杠(/),方括号([),右方括号(])。
Apache POI工作簿表示例
package poiexample;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
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 NewSheet {
public static void main(String[] args) throws FileNotFoundException, IOException {
Workbook wb = new HSSFWorkbook();
try(OutputStream fileOut = new FileOutputStream("srcmini.xls")) {
Sheet sheet1 = wb.createSheet("First Sheet");
Sheet sheet2 = wb.createSheet("Second Sheet");
wb.write(fileOut);
}catch(Exception e) {
System.out.println(e.getMessage());
}
}
}
输出:
See at bottom of the file, two sheets are created First Sheet, Second Sheet.
文章图片