19 lines
619 B
C#
19 lines
619 B
C#
using DocumentFormat.OpenXml.Packaging;
|
|
|
|
public class WordFileReader
|
|
{
|
|
public static string ExtractText(string filePath)
|
|
{
|
|
using var wordDoc = WordprocessingDocument.Open(filePath, false);
|
|
var body = wordDoc.MainDocumentPart.Document.Body;
|
|
return body.InnerText; // Returns all the text in the document
|
|
}
|
|
|
|
public static string ExtractText(MemoryStream stream)
|
|
{
|
|
using var wordDoc = WordprocessingDocument.Open(stream, false);
|
|
var body = wordDoc.MainDocumentPart.Document.Body;
|
|
return body.InnerText; // Returns all the text in the document
|
|
}
|
|
}
|