您可以通过 Aspose.Total for Java 分两步将 POT 文件转换为 XLTX。在第一步中,您可以使用 Aspose.Slides for Java 将 POT 导出为 HTML。其次,通过使用 Aspose.Cells for Java ,您可以将 HTML 转换为 XLTX。
如何通过 Java 将 POT 转换为 XLTX 或在线
- 使用 Presentation 类打开 POT 文件
- 使用 save 将 POT 转换为 HTML。 ISaveOptions-) 方法
- 使用 Workbook 类加载 HTML 文档
- 使用 save 将文档保存为 XLTX 格式方法
// supports PPT, POT, PPS, PPTX, POTX, PPSX, PPTM, PPSM, and POTM input file formats | |
// instantiate a Presentation object that represents a PPT file | |
Presentation presentation = new Presentation("template.ppt"); | |
// save the presentation as HTML | |
presentation.save("output.html", SaveFormat.Html); | |
// load the HTML file in an instance of Workbook | |
Workbook book = new Workbook("output.html"); | |
// Supports XLS, XLSX, XLSB, XLSM, XLT, XLTX, XLTM, XLAM, CSV, TSV, TXT, MHTML, ODS, DIF, MARKDOWN, SXC, and FODS output file formats | |
// save HTML as XLS | |
book.save("output.xls", SaveFormat.Xls); |
免费的 POT 到 XLTX 在线转换器
通过 Java 将受保护的 POT 转换为 XLTX
使用 API,您还可以打开受密码保护的文档。如果您输入的 POT 文档受密码保护,则您无法在不使用密码的情况下将其转换为 XLTX。 API 允许您通过在 LoadOptions 对象中传递正确的密码来打开加密的文档。
// initialize load options | |
LoadOptions loadOptions = new LoadOptions(); | |
// set password | |
loadOptions.setPassword("123123"); | |
// supports PPT, POT, PPS, POTX, PPSX, PPTM, PPSM, POTM, ODP, and OTP input file formats | |
Presentation presentation = new Presentation("template.ppt", loadOptions); | |
// save the presentation as HTML | |
presentation.save("output.html", SaveFormat.Html); | |
// load the HTML file in an instance of Workbook | |
Workbook book = new Workbook("output.html"); | |
// Supports XLS, XLSX, XLSB, XLSM, XLT, XLTX, XLTM, XLAM, CSV, TSV, TXT, MHTML, ODS, DIF, MARKDOWN, SXC, and FODS output file formats | |
// save HTML as XLS | |
book.save("output.xls", SaveFormat.Xls); |
通过 Java 将 POT 文件转换为带水印的 XLTX
在将 POT 文件转换为 XLTX 时,您还可以在输出的 XLTX 文件格式中添加水印。为了添加水印,创建一个新的工作簿来打开转换后的 HTML 文件。通过其索引选择 Worksheet,创建一个 Shape 并使用其 addTextEffect 函数,设置颜色、透明度等。之后,您可以将 HTML 文档保存为带水印的 XLTX。
// supports PPT, POT, PPS, PPTX, POTX, PPSX, PPTM, PPSM, and POTM input file formats | |
// instantiate a Presentation object that represents a PPT file | |
Presentation presentation = new Presentation("template.ppt"); | |
// save the presentation as HTML | |
presentation.save("output.html", SaveFormat.Html); | |
// load the HTML file in an instance of Workbook | |
Workbook book = new Workbook("XlsxOutput.xlsx"); | |
// get the first default sheet | |
Worksheet sheet = book.getWorksheets().get(0); | |
// add Watermark | |
Shape wordart = sheet.getShapes().addTextEffect(MsoPresetTextEffect.TEXT_EFFECT_1, "CONFIDENTIAL", | |
"Arial Black", 50, false, true, 18, 8, 1, 1, 130, 800); | |
// get the fill format of the word art | |
FillFormat wordArtFormat = wordart.getFill(); | |
// set the color | |
wordArtFormat.setOneColorGradient(Color.getRed(), 0.2, GradientStyleType.HORIZONTAL, 2); | |
// set the transparency | |
wordArtFormat.setTransparency(0.9); | |
// make the line invisible | |
LineFormat lineFormat = wordart.getLine(); | |
lineFormat.setWeight(0.0); | |
// supports CSV, XLSB, XLSM, XLT, XLTX, XLTM, XLAM, TSV, TXT, ODS, DIF, MD, SXC, and FODS file format | |
// save HTML as XLS | |
book.save("output.xls", SaveFormat.AUTO); |