0

I'm planning to develop an web application wherein there's an WYSIWYG text editor which you can save to database and export the output into DOCX/MS WORD. I could only find word automation/export on c#, but I need the text editor to be real time so that number of clients can edit at the same time.

I'm thinking of using asp.net core with angular typescript and ms sql to build this app. And unfortunately I'm struggling on how I can generate the Word Document on c# when the page is rendered in Angular Typescript.

using Word = Microsoft.Office.Interop.Word;
using System.Reflection;

private void Generate()
{
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */ 

//Start Word and create a new document.
Word._Application oWord;
Word._Document oDoc;
oWord = new Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing,
ref oMissing, ref oMissing);}

//so on and so forth

home.component.html

 <button type="button" class="btn btn-primary btn-md" (click)="Generate()">
   Show Message
 </button>

I'm new to angular, but if there's a better a approach rather than asp.net core and angular typescript or different language / library I could use feel free to comment.

Also if I can get this working I would be much easier for me.

Heretic Monkey
  • 11,687
  • 7
  • 53
  • 122
Yzak
  • 81
  • 2
  • 13
  • 1
    Note that the Interop libraries were not written with automation like you are doing in mind; using it this way generally leads to memory leaks and other problems on the server. You should look into libraries like [DocumentFormat.OpenXml](https://www.nuget.org/packages/DocumentFormat.OpenXml/) or [ClosedXML](https://github.com/ClosedXML/ClosedXML) for those purposes. – Heretic Monkey May 22 '19 at 22:18
  • can it work with angular? – Yzak May 23 '19 at 15:11
  • 1
    No. Those are server-side libraries. If you actually click on the links I put in there, or did some research, that should be obvious they are .NET libraries. If you want a JavaScript solution, you'll need to look elsewhere. Perhaps [Generate a Word document in JavaScript with Docx.js?](https://stackoverflow.com/q/15899883/215552) would be of help. However, this question is obviously becoming a fishing expedition. Please do your own research. I found the Docx.js question simply by searching for "create word documents in javascript". – Heretic Monkey May 23 '19 at 16:27
  • These are very helpful! – Yzak May 27 '19 at 17:40

0 Answers0