แปลง DOTX เป็นรูปแบบ JSON ผ่าน Java

บน Premise Java API เพื่อแปลง DOTX เป็น JSON โดยไม่ต้องใช้ Microsoft® Word หรือ Microsoft® Excel

 

การแปลงรูปแบบ DOTX เป็นรูปแบบ JSON ผ่าน Aspose.Total for Java เป็นกระบวนการสองขั้นตอนง่ายๆ เมื่อใช้ API การจัดการเอกสารและการแปลงที่มีคุณลักษณะหลากหลาย Aspose.Words for Java คุณจะส่งออก DOTX เป็น HTML ได้ หลังจากนั้น เมื่อใช้ Aspose.Cells for Java คุณจะแปลง HTML เป็น JSON ได้

แปลง DOTX เป็นรูปแบบ JSON ผ่าน Java

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

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

คุณสามารถใช้ Aspose.Total สำหรับ Java ได้โดยตรงจากโปรเจ็กต์ที่ใช้ Maven และรวมไลบรารี่ไว้ใน pom.xml ของคุณ

หรือคุณสามารถรับไฟล์ 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);

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

คุณยังสามารถเปิดเอกสารที่มีการป้องกันด้วยรหัสผ่านได้โดยใช้ API หากเอกสาร DOTX ที่คุณป้อนมีการป้องกันด้วยรหัสผ่าน คุณจะไม่สามารถแปลงเป็นรูปแบบ 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);

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

ขณะที่คุณกำลังแปลง DOTX เป็น 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();

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

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