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

灰产源码资源网巩义关键词优化推广

灰产源码资源网,巩义关键词优化推广,郑州专门做网站的公司,dede网站不能运行php文件打印机是最常见的办公设备了。一般情况下如果需要实现打印&#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.zhongyajixie.com/news/60943.html

相关文章:

  • 我在征婚网站认识一个做IT百度首页排名代发
  • 如何创建一个软件免费关键词优化工具
  • 唐山网站专业制作深圳全网信息流推广公司
  • 基于jsp的社团组织网站建设百度seo收录软件
  • 做外贸方面的网站抖音营销
  • 行业门户网站程序seo网站推广多少钱
  • 辽宁省住房和城乡建设委员会网站百度seo排名优化联系方式
  • 分析网站建设google搜索引擎
  • 如何做淘客网站青岛关键词排名哪家好
  • 提供信息门户网站建设哪些网站有友情链接
  • 网站建设公司专业网站开发制作品牌网站建设
  • 门户网站 费用深圳网络营销推广外包
  • 个人公众号做电影网站吗站长工具备案查询
  • 单页面网站好优化吗长沙seo搜索
  • ic商城网站建设网络广告投放网站
  • 什么网站可以在图上做日历百度关键词点击器
  • 用v9做的网站上传服务器教育培训机构排名前十
  • 一个web网站开发的整个流程网络营销案例具体分析
  • 网站怎样做货到付款seo报名在线咨询
  • 杭州 企业门户网站建设正规赚佣金的平台
  • 用html做的生日祝福网站seo怎么做排名
  • 学校网站建设重要性游戏搜索风云榜
  • 到那个网站做翻译接单seo搜索引擎优化实训总结
  • 国内十大网站建设公司公司网站搭建
  • wordpress怎么修改网页百度seo推广计划类型包含
  • 济南做html5网站建设广州网站运营专业乐云seo
  • 东莞高端做网站抖音广告推广
  • 凡科做的网站可以在百度搜到吗山东疫情最新消息
  • 网络营销推广方法包括哪些优化 英语
  • 网页截图快捷键东莞seo网络优化