Converter OTP para o formato JSON via Java

API Java no local para exportar OTP para JSON sem usar o Microsoft® Excel ou PowerPoint

 

Converter o formato OTP para JSON via Aspose.Total for Java é um processo simples de duas etapas. Na primeira etapa, você pode exportar OTP para HTML usando Aspose.Slides for Java . Em segundo lugar, usando Aspose.Cells for Java , você pode converter HTML em JSON.

Converter OTP para o formato JSON via Java

  1. Abra o arquivo OTP usando a classe Apresentação
  2. Converta OTP em HTML usando salvar método
  3. Carregue o documento HTML usando a classe Workbook
  4. Salve o documento no formato JSON usando save método

Requisitos de conversão

Você pode facilmente usar o Aspose.Total para Java diretamente de um projeto baseado em Maven e inclua bibliotecas em seu pom.xml.

Como alternativa, você pode obter um arquivo ZIP em 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);

Requisitos de conversão

Usando a API, você também pode abrir o documento protegido por senha. Se o documento OTP de entrada estiver protegido por senha, você não poderá convertê-lo para o formato JSON sem usar a senha. A API permite que você abra o documento criptografado passando a senha correta em um objeto 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("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);

Converter OTP Protegido para o Formato JSON via Java

Ao converter OTP para JSON, você também pode definir o intervalo para o formato JSON de saída. Para definir o intervalo, você pode abrir o HTML convertido usando a classe Workbook, criar um intervalo de dados a ser exportado usando o método Cells.createRange, chamar o método JsonUtility.exportRangeToJson com referências de Range & ExportRangeToJsonOptions e gravar dados JSON de string no arquivo via Método BufferedWriter.write.

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

Explore OTP Opções de conversão com Java

Converter OTPs para JSON (Arquivo de Notação de Objeto JavaScript)