0
我正在嘗試在C#中讀取.doc和.docx文件,但它不會像我們在文檔文件中看到的那樣顯示。它只是閱讀的文本,我想解決方案,我可以看到表,設計,圖片我們就可以在文檔文件中看到,請幫助在C#窗體中讀取.doc文件
Word.Application word = new Word.Application();
Word.Document doc = new Word.Document();
object fileName = @"C:\wordFile.docx";
// Define an object to pass to the API for missing parameters
object missing = System.Type.Missing;
doc = word.Documents.Open(ref fileName,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);
string ReadValue = string.Empty;
// Activate the document
doc.Activate();
foreach (Word.Range tmpRange in doc.StoryRanges)
{
ReadValue += tmpRange.Text;
}
在上述解決方案,我們可以讀取文檔文件只有文字。
我看到上面寫着Word文檔一些應用程序一樣的原始文檔,我會做一些研究,並找到一些解決方案,可以幫助其他 –
我會爲此推薦Aspose.Words – Pondidum