使用Aspose.cells将Excel转成PDF

使用Aspose.cells将Excel转成PDF

源文档地址

https://blog.csdn.net/dxyzhbb/article/details/90408092

下载jar包

链接:https://pan.baidu.com/s/1QbhZ-6qmG1N-n6BoF3yZTQ 
提取码:npdy 

添加到自己的mvn仓库

mvn install:install-file -Dfile="jar包位置" -DgroupId="groupId" -DartifactId="artifactId" -Dversion="版本" -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true

导包


        
            com.aspose
            aspose-cells
            8.5.2
        

代码

@Test
    public void excelToPdf() throws Exception {
        //去除水印
        String licenseXml = "Aspose.Total for JavaAspose.Words for JavaEnterprise20991231209912318bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=";
        ByteArrayInputStream is = new ByteArrayInputStream(licenseXml.getBytes());
        com.aspose.cells.License license = new com.aspose.cel`在这里插入代码片`ls.License();
        license.setLicense(is);
        //创建Workbook对象
        Workbook workbook = new Workbook("C:\\Users\\wucn\\Desktop\\work\\OA\\测试.xls");
        //保存成pdf
        workbook.save("C:\\Users\\wucn\\Desktop\\work\\OA\\测试.xls.pdf", com.aspose.cells.SaveFormat.PDF);

    }

你可能感兴趣的:(excel,java)