Generate MS Word(.docx) in Asp.net MVC by using DocX library.
What is DocX?
Generated Document.
Steps for generating DocX
Controller (GenerateDocumentController) Should look like this
Add Empty view to GenerateDocument action method. The view should look like this.
What is DocX?
DocX is a .NET library that allows developers to manipulate Word 2007/2010/2013 files, in an easy and intuitive manner. DocX is fast, lightweight and best of all it does not require Microsoft Word or Office to be installed.
Generated Document.
Steps for generating DocX
- Create new MVC project in visual studio
- Download DocX.dll from HERE and add reference of this (.dll) to your project
- Add controller (GenerateDocumentController) to your project
- Add action method(GenerateDocument) to the controller
- Add view to (GenerateDocument) action method
Controller (GenerateDocumentController) Should look like this
1 | using System; |
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>GenerateDocument</title>
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/bootstrap")
@Styles.Render("~/content/css")
</head>
<body>
<div class="container">
<div class="jumbotron">
@using (Html.BeginForm())
{
<div class="form-horizontal">
<button type="submit" class="btn btn-success btn-lg">
<i class="fa fa-list-alt"></i> Generate document</button>
</div>
}
</div>
</div>
</body>
</html>
6 Comments
do i need to purchase this or its free ?
ReplyDeleteIts free
DeleteThis comment has been removed by the author.
ReplyDeleteHow can i password protect word doc using this dll? I.e i need the doc to promt the user to input password when tryin to open the file.
ReplyDeleteGreat post thanks for sharing for more update at
ReplyDeleteDot Net Online Course
Try to zetword.com- this an advance word document processing API for .NET application
ReplyDeletePost a Comment