先导入NPOI动态库,前面的文章中有,自取。
using System.Collections.Generic;
using System.IO;
using NPOI.XWPF.UserModel;
using UnityEngine;
public class SeeWordContent : MonoBehaviour {
void Start ()
{
FileStream file = new FileStream("C:\\Users\\Admin\\Desktop\\test.docx", FileMode.OpenOrCreate, FileAccess.ReadWrite);
XWPFDocument word = new XWPFDocument(file);
foreach (XWPFParagraph paragraph in word.Paragraphs)
{
string message = paragraph.ParagraphText;//获取段落内容
Debug.Log(message);
}
file.Close();
}
}