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

织梦做的网站图片路径在哪关于宠物的网站模板

织梦做的网站图片路径在哪,关于宠物的网站模板,万国商业网,网站备案接入商变更以下代码#xff0c;亲测可以跑通 1、上一篇博客用了Apache POI库3.8的版本的形式对Excel加了水印#xff0c;但是最近主线版本用了4.1.2的形式#xff0c;由于为了保持版本的兼容性#xff0c;下面有开发了Apache POI的4.1.2的版本号的方案。 pom文件为#xff1a; d…以下代码亲测可以跑通 1、上一篇博客用了Apache POI库3.8的版本的形式对Excel加了水印但是最近主线版本用了4.1.2的形式由于为了保持版本的兼容性下面有开发了Apache POI的4.1.2的版本号的方案。 pom文件为 dependenciesdependencygroupIdorg.apache.poi/groupIdartifactIdpoi/artifactIdversion4.1.2/version/dependencydependencygroupIdorg.apache.poi/groupIdartifactIdpoi-ooxml/artifactIdversion4.1.2/version/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdversionRELEASE/versionscopecompile/scope/dependencydependencygroupIdorg.apache.poi/groupIdartifactIdooxml-schemas/artifactIdversion1.4/version/dependency/dependencies测试类及主要 功能代码 package com.msl;import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.*;import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.*;import static java.awt.image.BufferedImage.TYPE_INT_ARGB;public class ExcelWatermark0905 {public static void main(String[] args) {// 输入Excel文件路径// String inputFile /Users/navyliu/Downloads/input/附件2-3企业资产转让业务尽职调查报告申请机构_业务部门填写1.xlsx;// String inputFile /Users/navyliu/Downloads/input/kxkj.xlsx;// String inputFile /Users/navyliu/Downloads/input/test.xlsx;String inputFile /Users/navyliu/Downloads/input/315.xlsx;// 输出Excel文件夹路径String outputFolder /Users/navyliu/Downloads/output;// 水印文字String watermarkText 我是水印文字;try {FileInputStream fis new FileInputStream(inputFile);XSSFWorkbook workbook new XSSFWorkbook(fis);// 设置文本和字体大小Font font new Font(宋体,Font.PLAIN,36); // XXSFont font workbook.createFont(); // font.setFontName(仿宋); // font.setFontHeightInPoints((short) 20);int height 467;int width 987;BufferedImage watermarkImage drawText(watermarkText, font, Color.orange, Color.white, height, width);ByteArrayOutputStream byteArrayOut new ByteArrayOutputStream();ImageIO.write(watermarkImage, png, byteArrayOut);int pictureIdx workbook.addPicture(byteArrayOut.toByteArray(), Workbook.PICTURE_TYPE_PNG);for (int i 0; i workbook.getNumberOfSheets(); i) {XSSFSheet xssfSheet workbook.getSheetAt(i);String rID xssfSheet.addRelation(null, XSSFRelation.IMAGE_PNG, workbook.getAllPictures().get(pictureIdx)).getRelationship().getId();//set background picture to sheetxssfSheet.getCTWorksheet().addNewPicture().setId(rID);}// 保存带水印的Excel到输出文件夹File outputDir new File(outputFolder);if (!outputDir.exists()) {outputDir.mkdirs();}String outputFilePath outputFolder /output2.xlsx;FileOutputStream fos new FileOutputStream(outputFilePath);workbook.write(fos);fos.close();fis.close();} catch (IOException e) {e.printStackTrace();}}private static BufferedImage drawText(String text, Font font, Color textColor, Color backColor, double height, double width) {BufferedImage img new BufferedImage((int) width, (int) height, TYPE_INT_ARGB);Graphics2D loGraphic img.createGraphics();FontMetrics loFontMetrics loGraphic.getFontMetrics(font);int liStrWidth loFontMetrics.stringWidth(text);int liStrHeight loFontMetrics.getHeight();loGraphic.setColor(backColor);loGraphic.fillRect(0, 0, (int) width, (int) height);loGraphic.translate(((int) width - liStrWidth) / 2, ((int) height - liStrHeight) / 2);loGraphic.rotate(Math.toRadians(-45));loGraphic.translate(-((int) width - liStrWidth) / 4, -((int) height - liStrHeight) / 4);loGraphic.setFont(font);loGraphic.setColor(textColor);loGraphic.drawString(text, ((int) width - liStrWidth) / 4, ((int) height - liStrHeight) / 2);loGraphic.drawString(text, ((int) width - liStrWidth) / 2, ((int) height - liStrHeight) / 4);loGraphic.drawString(text, ((int) width - liStrWidth) / 6, ((int) height - liStrHeight) / 20);loGraphic.dispose();return img;} } 执行后的结果截图
http://www.w-s-a.com/news/305260/

相关文章:

  • 关键词那种网站正版网页游戏平台排行榜
  • 网站自助建设平台创建网址快捷方式
  • 坑梓网站建设包括哪些成都网站建设优创
  • 重庆网站seo公司哪家好超级优化大师
  • 成都网站建设推广详情邵阳市住房和城乡建设局网站
  • 淄博网站推广猎头公司有哪些
  • 局域网内建立网站90设计网怎么样
  • 域名备案和网站备案有什么不同工程项目建设网站
  • 做网站难吗?wordpress评论qq
  • 权威网站优化价格电子商务静态网站建设实验报告
  • 公司如何办网站北京网站建设公司内江
  • 六安建设网站企业营业执照查询系统入口
  • a5网站建设如果建设淘宝导购网站
  • html5响应式网站开发教程在国内做跨境电商怎么上外国网站
  • win7配置不能运行wordpress关键词快速优化排名软件
  • 餐饮公司最好的网站建设手机网站 搜索优化 百度
  • 17网站一起做网批做服装团购网站
  • 广州网站制作知名企业网站搭建品牌
  • 如何去除网站外链个人网页制作全过程
  • 保洁公司网站怎么做科技设计网站有哪些内容
  • 建设厅网站查询网页设计好就业吗
  • 惠东县网站建设wordpress 如何回到初始
  • 如何让公司网站网站转备案
  • 获得网站所有关键字北京网站建设116net
  • 铜陵电子商务网站建设做龙之向导网站有用吗
  • 购物网站制作费用沧州新华区
  • 信宜网站设计公司在线购物商城系统
  • 网站维护是什么样如何制作网站教程视频讲解
  • 网站建设网络推广代理公司wordpress图片防盗链
  • 网站备案关站沈阳男科医院哪家好点