Why to Convert
The DOTM format is a Microsoft Office Word template file used to create documents with a consistent look and feel. It is a great way to ensure that all documents created with the same template have the same formatting, layout, and design. However, the DOTM format is not compatible with many other applications, making it difficult to share documents with other users. Converting DOTM to JSON format can make it easier to share documents with other users, as JSON is a widely used format that is supported by many applications.
How Aspose.Total Helps for DOTM to JSON Conversion
Aspose.Total for Android via Java is a comprehensive suite of document manipulation and conversion APIs that can be used to convert DOTM to JSON format. It includes the Aspose.Words for Android via Java API, which can be used to export DOTM to HTML. The Aspose.Cells for Android via Java API can then be used to convert the HTML to JSON. This makes it easy to convert DOTM to JSON format in your Android applications. Aspose.Total for Android via Java also includes other APIs that can be used to manipulate and convert other document formats, making it a powerful and versatile tool for document manipulation and conversion.
Convert DOTM to JSON Format in Android
Get Started with Android via Java APIs
You can easily use Aspose.Total for Android via Java directly from Maven and install libraries in your app.
Alternatively, you can get a ZIP file from downloads .
// supports DOC, DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, MOBI, ODT, and OTT input file formats | |
// load DOCX with an instance of Document | |
Document document = new Document("template.docx"); | |
// call Save method while passing SaveFormat.HTML | |
document.save("html_output.html",SaveFormat.HTML); | |
// load the HTML file in an instance of Workbook | |
Workbook book = new Workbook("html_output.html"); | |
// save HTML as JSON | |
book.save("output.json", SaveFormat.JSON); |
Convert Protected DOTM to JSON Format in Android Apps
Using the API, you can also open the password-protected document. If your input DOTM document is password protected, you cannot convert it to JSON format without using the password. The API allows you to open the encrypted document by passing the correct password in a LoadOptions object. The following code example shows how open an encrypted document with a password.
// supports DOC, DOT, DOCX, DOCM, DOTX, and DOTM file formats | |
// load DOCX with an instance of Document | |
Document document = new Document("template.docx", new LoadOptions("MyPassword")); | |
// call Save method while passing SaveFormat.HTML | |
document.save("html_output.html",SaveFormat.HTML); | |
// load the HTML file in an instance of Workbook | |
Workbook book = new Workbook("html_output.html"); | |
// save HTML as JSON | |
book.save("output.json", SaveFormat.JSON); |
Convert DOTM to JSON in Range in Android Apps
While you are converting DOTM to JSON, you can also set range to your output JSON format. In order to set the range, you can open the converted HTML using Workbook class, create a Range of data to be exported using Cells.createRange method, call JsonUtility.exportRangeToJson method with references of Range & ExportRangeToJsonOptions and write string JSON data to file via BufferedWriter.write method.
// supports DOC, DOT, DOCX, DOCM, DOTX, DOTM, RTF, WordML, MOBI, ODT, and OTT input file formats | |
// load DOCX with an instance of Document | |
Document document = new Document("template.docx"); | |
// call Save method while passing SaveFormat.HTML | |
document.save("html_output.html",SaveFormat.HTML); | |
// load the HTML file in an instance of Workbook | |
Workbook book = new Workbook("html_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(); |