乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > poi如何通过模板导出excel-excel模板导出,java导出excel模板

poi如何通过模板导出excel-excel模板导出,java导出excel模板

作者:乔山办公网日期:

返回目录:excel表格制作


因为你电脑的office不是全部安装zd的,缺少access功能所以不能导出到本地, 你可以重新卸载现有版本,重新全安装office就可以导出了,或者你不想麻烦,就选择性粘贴另存到本地excel文件中再保存。

共分为六部完成根据模板导出excel操作:
第一步、设置excel模板路径(setSrcPath)
第二步、设置要生成excel文件路径(setDesPath)
第三步、设置模板中哪个Sheet列(setSheetName)
第四步、获取所读取excel模板的对象(getSheet)
第五步、设置数据(分为6种类型数据:setCellStrValue、setCellDateValue、 setCellDoubleValue、setCellBoolValue、setCellCalendarValue、setCellRichTextStrValue)
第六步、完成导出 (exportToNewFile)
通过这个例子,演示以下如何用java生成excel文件:e799bee5baa6e79fa5e98193e58685e5aeb9335
import org.apache.poi.hssf.usermodel.*;
import java.io.FileOutputStream;
import java.io.IOException;
publicclass CreateCells
{
publicstaticvoid main(String[] args)
throws IOException
{
HSSFWorkbook wb = new HSSFWorkbook();//建立新HSSFWorkbook对象
HSSFSheet sheet = wb.createSheet("new sheet");//建立新的sheet对象
// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow((short)0);//建立新行
// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short)0);//建立新cell
cell.setCellValue(1);//设置cell的整数类型的值
// Or do it on one line.
row.createCell((short)1).setCellValue(1.2);//设置cell浮点类型的值
row.createCell((short)2).setCellValue("test");//设置cell字符类型的值
row.createCell((short)3).setCellValue(true);//设置cell布尔类型的值
HSSFCellStyle cellStyle = wb.createCellStyle();//建立新的cell样式
cellStyle.setDataFormat(HSSFDataFormat.getFormat("m/d/yy h:mm"));//设置cell样式为定制的日期格式
HSSFCell dCell =row.createCell((short)4);
dCell.setCellValue(new Date());//设置cell为日期类型的值
dCell.setCellStyle(cellStyle); //设置该cell日期的显示格式
HSSFCell csCell =row.createCell((short)5);
csCell.setEncoding(HSSFCell.ENCODING_UTF_16);//设置cell编码解决中文高位字节截断
csCell.setCellValue("中文测试_Chinese Words Test");//设置中西文结合字符串
row.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_ERROR);//建立错误cell
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
}

  • 首先要查看你的浏览器有没有安装自动填表插件,如果没有就要先安装了插件才可以哦

  • 选择文件栏里的“工具”选项

  • 选择“管理功能组件”

  • 打开“管理功能组件”,然后查看有选择“获取更多”

  • 选择“自动填表”,点击安装

  • 安装完成之后我们就可以使用自动填表了,查看360浏览器状态栏,看到一把蓝色的钥匙,那个就是自动填表的快捷方式

  • 填写表单,然后保存当前表单,选择自动填表的 “保存当前表单”,或者快捷方式ALT+1

  • 当再次填表的时候就可以选择填写当前表单,或者按快捷键ALT+Q

  • 9

    如果以后以后还有别的表单,直接保存就可以了~~

相关阅读

关键词不能为空

ppt怎么做_excel表格制作_office365_word文档_365办公网