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

做餐厅logo用什么软件网站杭州seo优化

做餐厅logo用什么软件网站,杭州seo优化,淘宝怎么优化关键词排名,永州网站开发公司简介:本文将介绍如何使用Aspose技术将Excel文件转换为PDF格式。我们将使用Aspose-Cells-8.5.2.jar包,并演示Java代码以及进行测试。 一、Aspose技术概述 Aspose是一款强大的文档处理库,支持多种编程语言,如Java、C#、Python等。…

简介:本文将介绍如何使用Aspose技术将Excel文件转换为PDF格式。我们将使用Aspose-Cells-8.5.2.jar包,并演示Java代码以及进行测试。

一、Aspose技术概述

Aspose是一款强大的文档处理库,支持多种编程语言,如JavaC#Python等。它提供了丰富的功能,可以轻松地实现各种文档格式之间的转换,包括WordExcelPowerPointPDF等。在本文中,我们将重点关注如何利用Aspose技术将Excel以及Word文件转换为PDF格式。

二、准备环境

2.1 Excel

要使用Aspose技术,首先需要下载并安装Aspose-Cells-8.5.2.jar包。您可以从Aspose官方网站免费下载这个库。也可以听过下面的maven坐标引入对应的依赖信息。

<dependency><groupId>com.aspose</groupId><artifactId>aspose-cells</artifactId><version>8.5.2</version>
</dependency>
2.2 Word

要使用Aspose技术,首先需要下载并安装Aspose-words-15.8.0.jar包。您可以从Aspose官方网站免费下载这个库。也可以听过下面的maven坐标引入对应的依赖信息。

<dependency><groupId>com.aspose</groupId><artifactId>aspose-words</artifactId><version>15.8.0</version>
</dependency>

三、代码示例

3.1 excel-license.xml

注意:使用前,然后把excel-license.xml放在resources目录下,xml代码如下所示:

<License><Data><Products><Product>Aspose.Total for Java</Product><Product>Aspose.Words for Java</Product></Products><EditionType>Enterprise</EditionType><SubscriptionExpiry>20991231</SubscriptionExpiry><LicenseExpiry>20991231</LicenseExpiry><SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber></Data><Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>
</License>
3.2 word-license.xml

注意:使用前,然后把excel-license.xml放在resources目录下,xml代码如下所示:

<License><Data><Products><Product>Aspose.Total for Java</Product><Product>Aspose.Words for Java</Product></Products><EditionType>Enterprise</EditionType><SubscriptionExpiry>20991231</SubscriptionExpiry><LicenseExpiry>20991231</LicenseExpiry><SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber></Data><Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature>
</License>

接下来,我们将编写一个简单的Java程序,用于将Excel文件转换为PDF文件。以下是完整的Java代码示例:

3.2 PdfUtil工具类
public class Excel2PdfUtil {/*** excel 转 pdf** @param excelFilePath excel文件路径*/public static void excel2pdf(String excelFilePath) {excel2pdf(excelFilePath, null, null);}/*** excel 转 pdf** @param excelFilePath excel文件路径* @param convertSheets 需要转换的sheet*/public static void excel2pdf(String excelFilePath, int[] convertSheets) {excel2pdf(excelFilePath, null, convertSheets);}/*** excel 转 pdf** @param excelFilePath excel文件路径* @param pdfFilePath   pdf文件路径*/public static void excel2pdf(String excelFilePath, String pdfFilePath) {excel2pdf(excelFilePath, pdfFilePath, null);}/*** excel 转 pdf** @param excelFilePath excel文件路径* @param pdfFilePath   pdf文件路径* @param convertSheets 需要转换的sheet*/public static void excel2pdf(String excelFilePath, String pdfFilePath, int[] convertSheets) {try {pdfFilePath = pdfFilePath == null ? getPdfFilePath(excelFilePath) : pdfFilePath;// 验证 LicensegetLicense();Workbook wb = new Workbook(excelFilePath);FileOutputStream fileOS = new FileOutputStream(pdfFilePath);PdfSaveOptions pdfSaveOptions = new PdfSaveOptions();pdfSaveOptions.setOnePagePerSheet(true);if (null != convertSheets) {printSheetPage(wb, convertSheets);}wb.save(fileOS, pdfSaveOptions);fileOS.flush();fileOS.close();System.out.println("convert success");} catch (Exception e) {System.out.println("convert failed");e.printStackTrace();}}/*** 获取 生成的 pdf 文件路径,默认与源文件同一目录** @param excelFilePath excel文件* @return 生成的 pdf 文件*/private static String getPdfFilePath(String excelFilePath) {return excelFilePath.split(".")[0] + ".pdf";}/*** 获取 license 去除水印* 若不验证则转化出的pdf文档会有水印产生*/private static void getLicense() {String licenseFilePath = "excel-license.xml";try {InputStream is = PdfUtil.class.getClassLoader().getResourceAsStream(licenseFilePath);License license = new License();license.setLicense(is);} catch (Exception e) {System.out.println("license verify failed");e.printStackTrace();}}/*** 隐藏workbook中不需要的sheet页。** @param sheets 显示页的sheet数组*/private static void printSheetPage(Workbook wb, int[] sheets) {for (int i = 1; i < wb.getWorksheets().getCount(); i++) {wb.getWorksheets().get(i).setVisible(false);}if (null == sheets || sheets.length == 0) {wb.getWorksheets().get(0).setVisible(true);} else {for (int i = 0; i < sheets.length; i++) {wb.getWorksheets().get(i).setVisible(true);}}}
}
3.3 Excel测试

在我们的resources文件夹下新建一个test文件夹,文件夹放入咱的excel文件

public class TestExcel2Pdf {public static void main(String[] args) {String srcFilePath = "/test/excel数据.xlsx";Excel2PdfUtil.excel2pdf(srcFilePath);}
}

测试结果:
在这里插入图片描述
转换成对应的PDF,几乎一模一样,如下图所示:
在这里插入图片描述

3.4 下面贴上Word的代码

工具类:

@Slf4j
public class Doc2PdfUtil {/*** 获取 license 去除水印* 若不验证则转化出的pdf文档会有水印产生*/private static void getLicense() {String licenseFilePath = "word-license.xml";try {InputStream is = DocUtil.class.getClassLoader().getResourceAsStream(licenseFilePath);License license = new License();license.setLicense(Objects.requireNonNull(is));} catch (Exception e) {log.error("license verify failed");e.printStackTrace();}}/*** word 转 pdf* @param wordFile word 文件路径* @param pdfFile  生成的 pdf 文件路径*/public static void word2Pdf(String wordFile, String pdfFile) {File file = new File(pdfFile);if (!file.getParentFile().exists()) {file.getParentFile().mkdir();}getLicense();try (FileOutputStream os = new FileOutputStream(new File(pdfFile))) {Document doc = new Document(wordFile);doc.save(os, SaveFormat.PDF);} catch (Exception e) {log.error("word转pdf失败", e);e.printStackTrace();}}
}

测试类:

public class TestWord2Pdf {public static void main(String[] args) {String docFilePath = "/test/word数据.doc";String pdfFilePath = "/test/转换pdf数据.pdf";Doc2PdfUtil.word2Pdf(docFilePath, pdfFilePath);}
}

四、总结

通过本文的介绍,您应该已经了解了如何使用Aspose技术将ExcelWord文件转换为PDF格式。本文只是讲解了使用Apose技术进行转换成PDF,其实该技术能够做的事情还有很多,可以轻松地实现各种文档格式之间的转换。


文章转载自:
http://gingelli.c7500.cn
http://demise.c7500.cn
http://annunciator.c7500.cn
http://numeric.c7500.cn
http://candiot.c7500.cn
http://pornographic.c7500.cn
http://trachea.c7500.cn
http://consenescence.c7500.cn
http://bagful.c7500.cn
http://respectfully.c7500.cn
http://problem.c7500.cn
http://retinacular.c7500.cn
http://recitative.c7500.cn
http://virial.c7500.cn
http://compulsionist.c7500.cn
http://clinandrium.c7500.cn
http://pyrrhic.c7500.cn
http://spermatocyte.c7500.cn
http://zeldovich.c7500.cn
http://gotcher.c7500.cn
http://boiling.c7500.cn
http://pintail.c7500.cn
http://overarch.c7500.cn
http://ramous.c7500.cn
http://legalize.c7500.cn
http://linotype.c7500.cn
http://heterosex.c7500.cn
http://beechen.c7500.cn
http://minibike.c7500.cn
http://xanthomycin.c7500.cn
http://inflict.c7500.cn
http://drugster.c7500.cn
http://morphogen.c7500.cn
http://clip.c7500.cn
http://resolution.c7500.cn
http://coterminous.c7500.cn
http://solicitorship.c7500.cn
http://afoot.c7500.cn
http://delineation.c7500.cn
http://eucharistic.c7500.cn
http://left.c7500.cn
http://noninfected.c7500.cn
http://suntandy.c7500.cn
http://cervantite.c7500.cn
http://bluebutton.c7500.cn
http://polarizable.c7500.cn
http://adscription.c7500.cn
http://nylghai.c7500.cn
http://polymerization.c7500.cn
http://allelopathy.c7500.cn
http://recognizably.c7500.cn
http://biovular.c7500.cn
http://gary.c7500.cn
http://foetus.c7500.cn
http://teat.c7500.cn
http://diameter.c7500.cn
http://zoochory.c7500.cn
http://evzone.c7500.cn
http://tomfool.c7500.cn
http://tinning.c7500.cn
http://xiphophyllous.c7500.cn
http://offending.c7500.cn
http://drugger.c7500.cn
http://assailment.c7500.cn
http://barnacle.c7500.cn
http://autofilter.c7500.cn
http://cade.c7500.cn
http://bluepoint.c7500.cn
http://alfred.c7500.cn
http://dulciana.c7500.cn
http://pickwick.c7500.cn
http://unnoticed.c7500.cn
http://caecotomy.c7500.cn
http://proboscides.c7500.cn
http://domiciliary.c7500.cn
http://protectingly.c7500.cn
http://agateware.c7500.cn
http://lawrentian.c7500.cn
http://hate.c7500.cn
http://episematic.c7500.cn
http://gummy.c7500.cn
http://palsgravine.c7500.cn
http://dundrearies.c7500.cn
http://english.c7500.cn
http://arica.c7500.cn
http://euryoky.c7500.cn
http://good.c7500.cn
http://torpex.c7500.cn
http://hieroglyph.c7500.cn
http://domestos.c7500.cn
http://sherbet.c7500.cn
http://zymosis.c7500.cn
http://purge.c7500.cn
http://epizeuxis.c7500.cn
http://excellence.c7500.cn
http://bobbery.c7500.cn
http://retentiveness.c7500.cn
http://amplexus.c7500.cn
http://semifinal.c7500.cn
http://lansdowne.c7500.cn
http://www.zhongyajixie.com/news/91067.html

相关文章:

  • 遂宁网站建设公司哪家好口碑营销的方法
  • 重庆网站建设百度推广长春网络推广公司哪个好
  • 优惠网站怎么做做seo需要用到什么软件
  • 商务网站建设实训结论友情链接在线观看
  • 如何做网站左侧导航条seo关键词优化推广外包
  • 花店网站建设构思系统优化的意义
  • 个人博客html代码关键词优化技巧
  • 怎么做 社区网站首页郑州seo技术培训班
  • 网络广告营销概念seo顾问什么职位
  • 杭州网络营销网站体验营销案例分析
  • 晋城门户网站建设江苏seo和网络推广
  • 开封网站制作公司优秀网站设计欣赏
  • 网站建设的费用包括百度网页推广
  • 广州派出所门户网站直通车推广技巧
  • 新疆生产建设兵团水利局网站百度搜索风云榜小说总榜
  • 建设独立网站需要什么时候搜索引擎关键词优化有哪些技巧
  • 网站建设dbd3vi设计
  • 手机网站赏析网络营销是什么意思
  • 东莞设计网seo是指什么职位
  • 商城网站设计制作网站的seo
  • wordpress无法上传exe手机关键词seo排名优化
  • 新手如何做网站运营seo的基本步骤包括哪些
  • 装潢设计是干嘛的东莞网站关键词优化排名
  • angular 做网站外贸建站与推广
  • php手机网站如何制作网络营销的内容
  • 赣州企业做网站代发关键词排名包收录
  • 网站建设内部下单流程图资深seo顾问
  • 广告策划书word模板知乎推广优化
  • 海外营销是干什么的百度视频seo
  • 网络平台管理制度关键词seo服务