- package com.potevio.telecom.mobilenet;
- import java.io.FileNotFoundException;
- import java.io.FileOutputStream;
- import java.io.IOException;
- import java.io.OutputStream;
- import org.apache.poi.xssf.usermodel.XSSFCell;
- import org.apache.poi.xssf.usermodel.XSSFRow;
- import org.apache.poi.xssf.usermodel.XSSFSheet;
- import org.apache.poi.xssf.usermodel.XSSFWorkbook;
- public class POIParseExcel2007 {
- /**
- * POI 解析Excel2007版,生成HTML
- * @param fileName 文件(含地址)
- * @return 解析出来的HTML页面String
- */
- public String parseXLS2007ForHtml(String fileName){
- StringBuffer content = new StringBuffer();
- XSSFWorkbook xwb = null;
- try{
- // 构造 XSSFWorkbook 对象,strPath 传入文件路径
- xwb = new XSSFWorkbook(fileName);
- content.append("<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><title>Parse Excel With POI</title></head><body>");
- // 循环工作表Sheet
- for (int numSheet = 0; numSheet < xwb.getNumberOfSheets(); numSheet++) {
- XSSFSheet xSheet = xwb.getSheetAt(numSheet);
- if (xSheet == null) {
- continue;
- }
- content.append("<table border=1 cellspacing=0 cellpadding=1>");
- // 循环行Row
- for (int rowNum = 0; rowNum <= xSheet.getLastRowNum(); rowNum++) {
- XSSFRow xRow = xSheet.getRow(rowNum);
- if (xRow == null) {
- continue;
- }
- content.append("<tr align='middle'>");
- // 循环列Cell
- for (int cellNum = 0; cellNum <= xRow.getLastCellNum(); cellNum++) {
- XSSFCell xCell = xRow.getCell(cellNum);
- if (xCell == null || "".equals(xCell)) {
- content.append("<td>").append(" ").append("</td>");
- }else if (xCell.getCellType() == XSSFCell.CELL_TYPE_BOOLEAN) {
- content.append("<td>").append(" ").append(xCell.getBooleanCellValue()).append("</td>");
- } else if (xCell.getCellType() == XSSFCell.CELL_TYPE_NUMERIC) {
- content.append("<td>").append(" ").append(this.doubleToString(xCell.getNumericCellValue())).append("</td>");
- } else{
- content.append("<td>").append(" ").append(xCell.getStringCellValue()).append("</td>");
- }
- }
- content.append("</tr>");
- }
- content.append("</table>");
- }
- content.append("</body></html>");
- }catch(Exception e){
- e.printStackTrace();
- System.out.println("POI解析Excel2007错误");
- }
- return content.toString();
- }
- /**
- * @description 给手机客户端生成EXCEL的查看地址
- * @param clientExcelURL 生成的文件地址
- * @param file_name_source 需要解析的文件地址
- * @return 解析之后产生的文件地址
- *
- */
- public String clientExcelUrl(String clientExcelURL,String file_name_source){
- OutputStream serverout = null;
- try {
- serverout = new FileOutputStream(clientExcelURL);
- serverout.write(this.parseXLS2007ForHtml(file_name_source).getBytes("UTF-8")); //手机上默认是UTF-8的编码
- serverout.flush();
- serverout.close();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }finally{
- }
- return clientExcelURL;
- }
- /**
- * change double variable into string type
- * @param d
- * @return
- */
- public String doubleToString(double d){
- String str = Double.valueOf(d).toString();
- String temp = str;
- String result = "";
- if(str.indexOf("E")>2)
- result = str.substring(0,1) + temp.substring(2, str.indexOf("E"));
- else{
- if(str.indexOf(".0")>0)
- result = str.substring(0,str.indexOf(".0")) ;
- else
- result = str;
- }
- return result;
- }
- }
poi的包下载:http://poi.apache.org/download.html
测试用的3.5-final-20090928(共8个包)
贴个测试代码:
- package parseExcel2007;
- import java.io.File;
- import java.io.FileWriter;
- import java.io.IOException;
- public class TestC {
- public static void main(String[] args) {
- POIParseExcel2007 parse = new POIParseExcel2007();
- FileWriter fw = null;
- try {
- String content = "";
- String fileName = "F:/excel/测试07表格.xlsx";
- content = parse.parseXLS2007ForHtml(fileName);
- String target = "F:/test_0.html";
- File file = new File(target);
- fw = new FileWriter(file);
- fw.write(content);
- fw.flush();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- if (fw != null)
- try {
- fw.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
- }
补充:
POI需要的8个包截图如下:
相关推荐
chromedriver-win64-136.0.7059.0.zip
python学习一些项目和资源
python学习资源
python学习资源
python学习教程
python学习教程
【毕业设计】java-springboot+vue会议管理系统实现源码(完整前后端+mysql+说明文档+LunW).zip
内有各个系统的版本全了
分数阶模型辨识,分数阶模型辨识
大数据基于python的电影天堂数据可视化(源码+配套文档) 系统功能: 登录 、首页 、电影数据管理 、我的信息 关键技术:Python、Django、Mysql、Hadoop、Scrapy、Vue、B/S 技术支持:已测试可正常运行,调试问题可联系客服有偿解决。 更多项目:3000+优质源码,支持【定制】、修改、部署、讲解和文档。
【毕业设计】java-springboot+vue疾病防控综合系统的设计与实现源码(完整前后端+mysql+说明文档+LunW).zip
【毕业设计】java-springboot-vue家具销售电商平台实现源码(完整前后端+mysql+说明文档+LunW).zip
134dfffffffffffffffffffffffffffffff
代码说明: 设置结束时间:通过new Date().getTime()获取当前时间戳,并加上10分钟的毫秒数(10 * 60 * 1000),得到倒计时的结束时间。 更新倒计时:updateCountdown函数计算当前时间与结束时间的差值,并将其转换为分钟和秒数。 显示倒计时:通过console.log输出剩余时间,格式为“剩余时间:X分Y秒”。 停止倒计时:当剩余时间小于或等于0时,清除定时器并输出“时间到!”。 定时器:使用setInterval每秒调用一次updateCountdown函数,实现倒计时的动态更新。 扩展说明: 应用场景:倒计时功能常用于限时抢购、考试计时、活动倒计时等场景。 优化建议:可以将倒计时显示在网页的某个元素中,而不是控制台。例如,使用document.getElementById获取DOM元素并更新其内容。 兼容性:该代码在现代浏览器中均可运行,如果需要兼容旧版浏览器,可以使用var代替const和let。 扩展功能:可以添加声音提示、动画效果等,提升用户体验。
该项目是一个大学生校园兼职平台。该平台使用Java语言开发后台业务逻辑,运用了SpringMVC+Spring+MyBatis框架进行搭建,前台使用jQuery、layUI框架,数据库服务器采用MySQL5.6+对数据进行持久化。其主要功能有:兼职招聘、论坛交流、在线聊天、个人中心、信箱留言、登录注册等功能。
图解AUTOSAR-CP-CommunicationStackTypes逻辑图打包
解释程序的逻辑和变量等等
python学习一些项目和资源
最近在基于大型语言模型(LLM)的多智能体系统(MAS)方面的发展展示了其在处理复杂决策任务方面的显著潜力。然而,现有的框架不可避免地依赖于串行执行范式,即智能体必须完成顺序的LLM规划后才能采取行动。这一基本限制严重影响了实时响应和适应能力,而在动态环境中这些能力至关重要。本文提出了一种新的并行化规划-行动框架,用于基于LLM的MAS,该框架具有可中断执行的双线程架构,支持并发规划和行动。具体而言,我们的框架包含两个核心线程:(1) 由集中式内存系统驱动的规划线程,保持环境状态同步和智能体通信以支持动态决策;以及 (2) 配备全面技能库的行动线程,通过递归分解实现自动化任务执行。在具有挑战性的《我的世界》实验中证明了所提框架的有效性。
基于layui和thinkphp6.0的快速后台开发框架。快速构建完善的管理后台,内置表单、表格的php生成,以及完善的RBAC权限管理