Converti OTP in formato JSON in Android tramite Java

Progetta applicazioni Android per esportare OTP in JSON senza utilizzare Microsoft® Word o Excel

 

Puoi convertire OTP in formato JSON nelle tue applicazioni Android tramite Aspose.Total for Android via Java . Utilizzando l’API di conversione e manipolazione dei otpumenti Aspose.Words for Android via Java , puoi esportare OTP in HTML. Successivamente, utilizzando Aspose.Cells for Android via Java , puoi convertire HTML in JSON.

Converti OTP in formato JSON in Android

  1. Aprire il file OTP utilizzando la classe Otpument
  2. Converti OTP in HTML utilizzando Save metodo
  3. Carica il otpumento HTML utilizzando la classe Workbook
  4. Salvare il otpumento in formato JSON utilizzando Save .

Requisiti di conversione

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 il formato OTP protetto in formato JSON in Android tramite Java

Utilizzando l’API, puoi anche aprire il otpumento protetto da password. Se il otpumento OTP di input è protetto da password, non è possibile convertirlo in formato JSON senza utilizzare la password. L’API consente di aprire il otpumento crittografato passando la password corretta in un oggetto LoadOptions. L’esempio di codice seguente mostra come aprire un otpumento 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 OTP in JSON nell'intervallo in Android tramite Java

Durante la conversione di OTP in JSON, puoi anche impostare l’intervallo sul formato JSON di output. Per impostare l’intervallo, è possibile aprire l’HTML convertito utilizzando la classe Workbook, creare un intervallo di dati da esportare utilizzando il metodo Cells.createRange, chiamare il metodo JsonUtility.exportRangeToJson con i riferimenti di Range & ExportRangeToJsonOptions e scrivere i dati JSON della stringa su file tramite BufferedWriter.write metodo.

// 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();

Esplora OTP opzioni di conversione con Android

Convertire OTPs in JSON (File di notazione dell'oggetto JavaScript)