翻譯|行業資訊|編輯:李顯亮|2019-12-10 11:16:50.003|閱讀 612 次
概述:Aspose.Words API提供了將Microsoft Word文檔從DOC或DOCX格式序列化為字節數組的最簡單方法。將文檔存儲到數據庫中和/或從數據庫中檢索時,將Word文檔轉換為字節數組很有幫助。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
Aspose.Words for .Net是一種高級Word文檔處理API,用于執行各種文檔管理和操作任務。API支持生成,修改,轉換,呈現和打印文檔,而無需在跨平臺應用程序中直接使用Microsoft Word。
下載Aspose.Words for .NET v19.12
Aspose.Words API提供了將Microsoft Word文檔從DOC或DOCX格式序列化為字節數組的最簡單方法。將文檔存儲到數據庫中和/或從數據庫中檢索時,將Word文檔轉換為字節數組很有幫助。
.NET的Aspose.Words可用于轉換Document對象,以獲取表示任何.NET應用程序中Document的字節數組。以下代碼段演示了DOC文件到字節數組的轉換。
// Load the document from disk. Document doc = new Document("Sample.doc"); // Create a new memory stream. MemoryStream outStream = new MemoryStream(); // Save the document to stream. doc.Save(outStream, SaveFormat.Docx); // Convert the document to byte form. byte[] docBytes = outStream.ToArray(); // The bytes are now ready to be stored/transmitted. // Now reverse the steps to load the bytes back into a document object. MemoryStream inStream = new MemoryStream(docBytes); // Load the stream into a new document object. Document loadDoc = new Document(inStream); // Save the document. loadDoc.Save("loadDoc.docx",SaveFormat.Docx);
還想要更多嗎?您可以點擊閱讀【2019 · Aspose最新資源整合】,查找需要的教程資源。讓人興奮的是Aspose.Total限時直降10000元!java版另送IDE開發工具一套!立馬1分鐘了解全部咨詢!
以下代碼段演示了如何使用Aspose.Words for Java API 將DOC文件轉換為字節數組。
// Load the document. Document doc = new Document("Sample.doc"); // Create a new memory stream. ByteArrayOutputStream outStream = new ByteArrayOutputStream(); // Save the document to stream. doc.save(outStream, SaveFormat.DOCX); // Convert the document to byte form. byte[] docBytes = outStream.toByteArray(); // The bytes are now ready to be stored/transmitted. // Now reverse the steps to load the bytes back into a document object. ByteArrayInputStream inStream = new ByteArrayInputStream(docBytes); // Load the stream into a new document object. Document loadDoc = new Document(inStream); // Save the document. loadDoc.Save("loadDoc.docx",SaveFormat.Docx);
如果您有任何疑問或需求,請隨時加入Aspose技術交流群(642018183),我們很高興為您提供查詢和咨詢。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn