แปลง WORD เป็นรูปแบบ JSON ใน Android ผ่าน Java

ออกแบบแอปพลิเคชัน Android เพื่อส่งออก WORD ไปยัง JSON โดยไม่ต้องใช้ Microsoft® Word หรือ Excel

 

คุณสามารถแปลง WORD เป็นรูปแบบ JSON ในแอปพลิเคชัน Android ของคุณผ่าน Aspose.Total for Android via Java ด้วยการใช้การจัดการเอกสารและการแปลง API Aspose.Words for Android via Java คุณสามารถส่งออก WORD เป็น HTML ได้ หลังจากนั้น ด้วยการใช้ Aspose.Cells for Android via Java คุณจะสามารถแปลง HTML เป็น JSON ได้

แปลง WORD เป็นรูปแบบ JSON ใน Android

  1. เปิดไฟล์ WORD โดยใช้คลาส Wordument
  2. แปลง WORD เป็น HTML โดยใช้ Save กระบวนการ
  3. โหลดเอกสาร HTML โดยใช้คลาส Workbook
  4. บันทึกเอกสารในรูปแบบ JSON โดยใช้ Save วิธีการ

ข้อกำหนดการแปลง

คุณสามารถใช้ Aspose.Total for Android via Java ได้โดยตรงจาก Maven และ ติดตั้งไลบรารีในแอปของคุณ

หรือคุณสามารถรับไฟล์ ZIP จาก ดาวน์โหลด

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

แปลง WORD ที่ได้รับการป้องกันเป็นรูปแบบ JSON ใน Android ผ่าน Java

คุณยังสามารถเปิดเอกสารที่ป้องกันด้วยรหัสผ่านโดยใช้ API ได้อีกด้วย หากเอกสาร WORD ที่คุณป้อนมีการป้องกันด้วยรหัสผ่าน คุณจะไม่สามารถแปลงเป็นรูปแบบ JSON ได้โดยไม่ต้องใช้รหัสผ่าน API อนุญาตให้คุณเปิดเอกสารที่เข้ารหัสโดยส่งรหัสผ่านที่ถูกต้องในออบเจกต์ LoadOptions ตัวอย่างโค้ดต่อไปนี้แสดงวิธีการเปิดเอกสารที่เข้ารหัสด้วยรหัสผ่าน

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

แปลง WORD เป็น JSON ในช่วงใน Android ผ่าน Java

ขณะที่คุณกำลังแปลง WORD เป็น JSON คุณยังสามารถตั้งค่าช่วงเป็นรูปแบบ JSON เอาต์พุตของคุณได้ ในการตั้งค่าช่วง คุณสามารถเปิด HTML ที่แปลงแล้วโดยใช้คลาสเวิร์กบุ๊ก สร้างช่วงของข้อมูลที่จะส่งออกโดยใช้เมธอด Cells.createRange เรียกเมธอด JsonUtility.exportRangeToJson พร้อมการอ้างอิงของ Range & ExportRangeToJsonOptions และเขียนสตริงข้อมูล JSON ไปยังไฟล์ผ่าน วิธีการ BufferedWriter.write

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

สำรวจ WORD ตัวเลือกการแปลงด้วย Android

แปลง WORD S TO CSV (ค่าที่คั่นด้วยเครื่องหมายจุลภาค)
แปลง WORD S TO DIF (รูปแบบการแลกเปลี่ยนข้อมูล)
แปลง WORD S TO EXCEL (รูปแบบไฟล์สเปรดชีต)
แปลง WORD S TO FODS (สเปรดชีต OpenDocument Flat XML)
แปลง WORD S TO ODS (OpenDocument สเปรดชีต)
แปลง WORD S TO SXC (สเปรดชีตคำนวณ StarOffice)
แปลง WORD S TO TSV (ค่าที่คั่นด้วยแท็บ)
แปลง WORD S TO XLAM (Add-in ที่เปิดใช้งานแมโครของ Excel)
แปลง WORD S TO XLS (รูปแบบไบนารีของ Microsoft Excel)
แปลง WORD S TO XLSB (สมุดงานไบนารีของ Excel)
แปลง WORD S TO XLSM (สเปรดชีตที่เปิดใช้งานมาโคร)
แปลง WORD S TO XLSX (เปิดสมุดงาน XML)
แปลง WORD S TO XLT (เทมเพลต Excel 97 - 2003)
แปลง WORD S TO XLTM (เทมเพลตที่เปิดใช้งานแมโครของ Excel)
แปลง WORD S TO XLTX (เทมเพลต Excel)