建立文件并创建sheet页:
private void createWorkbook() {
this.workbook = new HSSFWorkbook();
this.workbook.createSheet();
this.workbook.setSheetName(0, this.getSheetName(), (short) 1);
}
在sheet页中写入标题:
private void writeHead() {
HSSFSheet sheet = this.workbook.getSheetAt(0);
HSSFRow row = null;
HSSFCell cell = null;
HSSFCellStyle style = this.workbook.createCellStyle();
style.setAlignment(HSSFCellStyle.ALIGN_CENTER);// 水平居中
//表头始终是第一行
row = sheet.createRow(0);
List head = this.getWorkbookHead();
for (short col = 0; col < head.size(); col++) {
cell = row.createCell(col);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);// 这里是设置编码保证中文正常显示
cell.setCel
最后
以上就是腼腆大地最近收集整理的关于用JAVA创建excel文件并写入数据的全部内容,更多相关用JAVA创建excel文件并写入数据内容请搜索靠谱客的其他文章。
发表评论 取消回复