How can I generate a Word document using a stream of bytes

I have a byte stream that actually (if correctly) forms a valid Word file, I need to convert this stream to a Word file without writing it to disk, I take the original stream from the SQL Server database table:

ID Name FileData ---------------------------------------- 1 Word1 292jf2jf2ofm29fj29fj29fj29f2jf29efj29fj2f9 (actual file data) 

the FileData field contains data.

 Microsoft.Office.Interop.Word.Application word = new Microsoft.Office.Interop.Word.Application(); Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document(); doc = word.Documents.Open(@"C:\SampleText.doc"); doc.Activate(); 

The above code opens and fills the Word file from the file system, I do not want this, I want to define a new Microsoft.Office.Interop.Word.Document , but I want to manually fill in its contents from the byte stream.

After getting the Word document in memory, I want to parse the keywords.

Any ideas?

+3
source share
3 answers
  • Create a memmory file system, there are drivers for this.
  • Give a word to the path to the ftp server path (or something else) that you then use to push the data.

It is important to note: storing files in a database is usually not a good design.

0
source

There is probably no direct way to do this. I found a couple of search solutions:

I don't know if this does this for you, but the API does not seem to provide what you need (unfortunately).

0
source

You can see how Sharepoint solves this. They created a web interface for documents stored in their database.

It's not so difficult to create or embed a web server in an application that can serve pages in Word. You do not even need to use standard ports.

0
source

All Articles