当前位置: 首页 > news >正文

学校网站建设制作方案最新的国际新闻

学校网站建设制作方案,最新的国际新闻,wordpress 按时间排序,深圳制作网站专业打印机是最常见的办公设备了。一般情况下如果需要实现打印&#xff0c;可通过前端print.js包来完成。但是&#xff0c;如果要实现智能办公打印&#xff0c;就可以使用JNI技术、封装接口、远程调用实现完成。 导包 jacob&#xff1a;Java COM Bridge <dependency><g…

打印机是最常见的办公设备了。一般情况下如果需要实现打印,可通过前端print.js包来完成。但是,如果要实现智能办公打印,就可以使用JNI技术、封装接口、远程调用实现完成。

导包

jacob:Java COM Bridge

<dependency><groupId>net.sf.jacob-project</groupId><artifactId>jacob</artifactId><version>1.14.3</version>
</dependency>

下载:jacob-1.18-x64.dll

接口开发

service

/*** @Author lyonardo* @Description 打印* @Date 16:20 2020/1/20* @Param [filePath, startMsg, endMsg, cause, departId]* @return com.xxx.basic.response.ReturnData**/@Overridepublic ReturnData excelPrint(String filePath, Long startMsg, Long endMsg, String cause, Integer departId) {try {//下载驱动FileUtil.saveUrlAs(fileServerPath+"/file/", "jacob-1.18-x64.dll", "C:/Windows/System32", "GET");String excelName = "xx市中级人民法院办理减刑案件情况统计表";String outFilename = buildOutFilename(excelName,startMsg,endMsg);//判断文件是否已经生成String excelDownloadPath = "";if(FileUtils.directoryContains(new File("/rpcs/excel"), new File("/rpcs/excel/download"+"/"+outFilename))){excelDownloadPath = "/rpcs/excel/download"+"/"+outFilename;}else{CaseStatVo caseStatVo = getCaseStatVo(startMsg, endMsg, cause, departId);ExportUtils.excelWrite(fileServerPath, caseStatVo, filePath,outFilename, JodaTimeUtil.formatDate2ToString(startMsg, endMsg));excelDownloadPath = "/rpcs/excel/download"+"/"+outFilename;}//打印指定文件名文件Integer i = PrintUtil.printOfficeFile(excelDownloadPath);if (1 == i) return ReturnData.operateSuncess();} catch (IOException e) {e.printStackTrace();}return ReturnData.operateFail();}

PrintUtil封装

/*** @Author lyonardo* @Description Office打印* @Date 14:49 2019/9/23* @Param [filePath 文件路径]* @return boolean
**/
public static Integer printOfficeFile(String filePath) {String postfixString = FileUtil.getFilePathExtensions(filePath);if (postfixString.equalsIgnoreCase("xls")|| postfixString.equalsIgnoreCase("xlsx")) {/*** 功能:实现excel打印工作*/ComThread.InitSTA();ActiveXComponent xl = new ActiveXComponent("Excel.Application");try {// System.out.println("version=" +// xl.getProperty("Version"));// 不打开文档Dispatch.put(xl, "Visible", new Variant(false));Dispatch workbooks = xl.getProperty("Workbooks").toDispatch();// 打开文档Dispatch excel = Dispatch.call(workbooks, "Open",filePath).toDispatch();// 横向打印//     Dispatch currentSheet = Dispatch.get(excel, "ActiveSheet")//       .toDispatch();//     Dispatch pageSetup = Dispatch//       .get(currentSheet, "PageSetup").toDispatch();//     Dispatch.put(pageSetup, "Orientation", new Variant(2));//每张表都横向打印Dispatch sheets = Dispatch.get(excel, "Sheets").toDispatch();// 获得几个sheetint count = Dispatch.get(sheets, "Count").getInt();//     System.out.println(count);for (int j = 1; j <=count; j++) {Dispatch sheet = Dispatch.invoke(sheets, "Item",Dispatch.Get, new Object[] { new Integer(j) },new int[1]).toDispatch();Dispatch pageSetup = Dispatch.get(sheet, "PageSetup").toDispatch();Dispatch.put(pageSetup, "Orientation", new Variant(2));Dispatch.call(sheet, "PrintOut");}// 开始打印if (excel != null) {//Dispatch.call(excel, "PrintOut");//增加以下三行代码解决文件无法删除bugDispatch.call(excel, "save");Dispatch.call(excel,  "Close" ,  new  Variant(true));excel=null;}xl.invoke("Quit", new Variant[] {});xl=null;return 1;} catch (Exception e) {e.printStackTrace();return 0;} finally {// 始终释放资源ComThread.Release();}}else if (postfixString.equalsIgnoreCase("doc")|| postfixString.equalsIgnoreCase("docx")) {ComThread.InitSTA();ActiveXComponent wd = new ActiveXComponent("Word.Application");try {// 不打开文档Dispatch.put(wd, "Visible", new Variant(false));Dispatch document = wd.getProperty("Documents").toDispatch();// 打开文档Dispatch doc = Dispatch.invoke(document, "Open",Dispatch.Method, new Object[] { filePath },new int[1]).toDispatch();// 开始打印if (doc != null) {Dispatch.call(doc, "PrintOut");Dispatch.call(doc, "save");Dispatch.call(doc,  "Close" ,  new  Variant(true));doc=null;}wd.invoke("Quit", new Variant[] {});wd=null;return 1;} catch (Exception e) {e.printStackTrace();return 0;} finally {// 始终释放资源ComThread.Release();}}else {return 0;}
}

测试

  @Testpublic void test(){String filePath  = "C:/Users/Administrator/Desktop/xx市中级人民法院办理减刑案件情况统计表.xlsx";//String printerName = "FX DocuPrint M115 b";//打印机名包含字串PrintUtil.printOfficeFile(filePath);}
http://www.tj-hxxt.cn/news/105322.html

相关文章:

  • 凡客建站网域名注册购买
  • 教做面点的网站seo网站培训班
  • 做论坛网站 备案吗seo关键词优化
  • 唯品会一家专做特卖的网站google怎么推广
  • 网页设计与网站开发什么区别互联网关键词优化
  • 义乌网站建设公司代理网络推广软文范文
  • 购买模板做网站网站分析报告范文
  • 公司为什么建立网站西安优化seo托管
  • 沈阳网站建设选网龙数字营销
  • 织梦可以做B2B信息发布网站吗免费广告投放平台
  • 中国空间站航天员首次出舱百度广告安装入口
  • 免费的个人简历模板可手机编辑百度seo标题优化软件
  • 在线生成app免费山东济南seo整站优化公司
  • 请问聊城做网站校园推广方案
  • 网站源码搭建教程微信软文推广怎么做
  • 工作室网站建设要多大内存百度搜索风云榜总榜
  • 网站开发简历的项目经验怎样在百度打广告
  • 网站建设技术员保密协议南宁seo全网营销
  • 做logo什么网站必应搜索引擎下载
  • 网站需求分析怎么做郑州seo招聘
  • 做网站备案要多久视频网站搭建
  • 怎么创网站外包网络推广公司怎么选
  • 怎么评价网站做的好坏宁波seo推广平台
  • 一键网页转app生成器苏州关键词seo排名
  • 我的网站百度怎么搜索不到了樱桃bt磁力天堂
  • js企业网站模板2024年最新一轮阳性症状
  • 诸城网站建设国家提供的免费网课平台
  • 政府网站建设 考察报告上海最近3天疫情情况
  • 新网站怎么运营软文范例500字
  • 做学校网站素材图片素材sem和seo是什么职业岗位