Hi, a have a big problem, I have to read docx but on the server is not office 2007 installed. I tryed to resolve...
using Ionic.Zip;
using (ZipFile zip = ZipFile.Read("C:\\Documents and Settings\\" + FileUpload1.FileName))
{
MemoryStream stream = new MemoryStream();
//zip.Extract(@"word/document.xml", stream);
zip.Extract(@"content.xml", stream);
stream.Seek(0, SeekOrigin.Begin);
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(stream);
string PlainTextContent = xmldoc.DocumentElement.InnerText;
}
This works good, but it gives me just plaint text.. and i need to know, where is bold, where starts new line.. so i have to know formatting.
Does anybody have an idea? Thanx
P.S. Sorry for my english.
Loading
John GlennPosted Mar 12, 2012, 5:42 AM
if you have relatively small files, you can try this C# Word library to easily read DOCX files without dependency on Word application.
Here is a sample code how to read a C# DOCX file:
DocumentModel document = DocumentModel.Load("Document.docx", DocxLoadOptions.DocxDefault);
// Iterate over all paragraphs in the document.
foreach (Paragraph paragraph in document.GetChildElements(true, ElementType.Paragraph))
{
// Iterate over all runs in the paragraph and write their text to console.
foreach (Run run in paragraph.GetChildElements(true, ElementType.Run))
Console.Write(run.Text);
Console.WriteLine();
}
Rodick WuPosted May 25, 2009, 3:58 AM
Rodick WuPosted May 25, 2009, 3:55 AM