Puoi convertire facilmente file PPSX in JSON nelle tue applicazioni Android in un processo in due fasi tramite Aspose.Total for Android via Java . Nel primo passaggio puoi esportare il file PPSX in HTML utilizzando Aspose.Slides for Android via Java . In secondo luogo, utilizzando Aspose.Cells for Android via Java , puoi convertire HTML in JSON.
Come convertire PPSX in JSON in Android
- Aprire il file PPSX utilizzando la classe Presentazione
- Converti PPSX in HTML utilizzando save metodo
- Carica il documento HTML utilizzando la classe Workbook
- Salva il documento in formato JSON utilizzando save
Requisiti di conversione
Per convertire PPSX in JSON, puoi facilmente utilizzare Aspose.Total for Android via Java direttamente da Maven e installa le librerie nella tua app.
In alternativa, puoi ottenere un file ZIP da downloads .
// supports PPT, POT, PPS, POTX, PPSX, PPTM, PPSM, POTM, ODP, and OTP 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"); | |
// save HTML as JSON | |
book.save("output.json", SaveFormat.JSON); |
Converti PPSX protetto in JSON in Android tramite Java
Utilizzando l’API, puoi anche aprire il documento protetto da password. Se il documento PPSX di input è protetto da password, non è possibile convertirlo in JSON senza utilizzare la password. L’API consente di aprire il documento crittografato passando la password corretta in un oggetto LoadOptions. L’esempio di codice seguente mostra come provare ad aprire un documento crittografato con una password:
// 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("pres.pptx", 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"); | |
// save HTML as JSON | |
book.save("output.json", SaveFormat.JSON); |
Converti file PPSX in JSON con Watermark in Android
Durante la conversione del file PPSX in JSON, puoi anche aggiungere una filigrana al formato del file JSON di output. Per aggiungere una filigrana, crea una nuova cartella di lavoro per aprire il file HTML convertito. Seleziona Foglio di lavoro tramite il suo indice, crea una forma e usa la sua funzione addTextEffect, imposta colori, trasparenza e altro. Successivamente puoi salvare il tuo documento HTML come JSON con Watermark.
// supports PPT, POT, PPS, POTX, PPSX, PPTM, PPSM, POTM, ODP, and OTP 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"); | |
// access CellsCollection of the worksheet containing data to be converted | |
Cells cells = workbook.getWorksheets().get(0).getCells(); | |
// create & set ExportRangeToJsonOptions for advanced options | |
ExportRangeToJsonOptions exportOptions = new ExportRangeToJsonOptions(); | |
// create a range of cells containing data to be exported | |
Range range = cells.createRange(0, 0, cells.getLastCell().getRow() + 1, cells.getLastCell().getColumn() + 1); | |
// export range as JSON data | |
String jsonData = JsonUtility.exportRangeToJson(range, exportOptions); | |
// write data to disc in JSON format | |
BufferedWriter writer = new BufferedWriter(new FileWriter("output.json")); | |
writer.write(jsonData); | |
writer.close(); |