In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article will explain in detail how Java converts Excel to PDF based on Spire.Cloud.Excel. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.
Spire.Cloud.Excel.Sdk provides GeneralApi interface and WorkbookApi interface to support the conversion of local Excel and cloud Excel documents to ODS, PDF, XPS, PCL, PS and other formats. Taking the conversion from Excel table to PDF as an example, this paper introduces the steps and methods of format conversion.
Necessary steps:
Step 1:jar file download and import. You can download the jar; through the "download Center" or install and import it through the maven warehouse. Refer to the installation method.
Step 2:ID and Key acquisition. You need to create an account in the cloud and an application in the "my applications" section to get App ID and App Key.
Step 3: when converting a cloud Excel document to PDF, you need to upload the Excel document in the "document Management" section first.
Note: accounts created in the cloud can be tried out for 10,000 calls and 2GB of document memory for free.
[example 1] convert a local Excel document to PDF
Import spire.cloud.excel.sdk.ApiException; import spire.cloud.excel.sdk.api.GeneralApi; import spire.cloud.excel.sdk.model.ExportFormat; import java.io.File; public class ExcelToPDF {private static String appId = "App ID"; private static String appKey = "App Key"; public static void main (String [] args) throws ApiException {/ / create GeneralApi instance and configure account information GeneralApi generalApi = new GeneralApi (appId, appKey) / / configure related parameters String format = ExportFormat.PDF.toString (); String inputFilePath = "test.xlsx"; File data = new File (inputFilePath); String outputFilePath = "ToPDF.pdf"; String password = null; / / call the putWorkbookConvert API to save the document as PDF generalApi.putWorkbookConvert (format,outputFilePath,data, password);}}
[example 2] convert cloud Excel documents to PDF
Import spire.cloud.excel.sdk.ApiException; import spire.cloud.excel.sdk.api.WorkbookApi; import spire.cloud.excel.sdk.model.ExportFormat; import spire.cloud.excel.sdk.model.ExportOptions; public class ExcelToPDF2 {private static String appId = "App ID"; private static String appKey = "App Key"; public static void main (String [] args) throws ApiException {/ / create WorkbookApi instance and configure account information WorkbookApi workbookApi = new WorkbookApi (appId, appKey) / / configure related parameters String name= "test.xlsx"; String outputFilePath = "ToPDF2.pdf"; String format = ExportFormat.PDF.toString (); ExportOptions options = null; String storage = null; String inputFolder = "input"; String password = null / / call putWorkbookSaveAs API to save the document as PDF workbookApi.putWorkbookSaveAs (name, outputFilePath, format, options, password, storage, inputFolder);}}
The document conversion results can be viewed in the document Management section, as follows:
This is the end of the article on "how Java converts Excel into PDF based on Spire.Cloud.Excel". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.