ASP.NET MVC3 Integration with Microsoft Office (Word) - asp.net

I have an ASP.NET MVC3 Application, And I have a form where it generates an output form. Currently I generate the output form in an html file, but I want to switch it to generate it as a Microsoft Word Document, or essentially populate a word template. What would be the best way to accomplish this?

There are several components that allow you to generate a word document programmatically. The one I've had the most success with is Syncfusion DocIO It's a paid utility but worth the price if you need to manipulate word documents programmatically. If cost is an issue, there are tutorials on how to build a server-side document generation utility using Open XML

Related

MS Word template with loops, tables and charts

For our SaaS (LAMP) product reporting we are currently using JasperReports. We find it too cumbersome to develop reports with and the output in Word unworkable. Moreover, a couple of customers request to be able to develop simple reports themselves (to be used as mail merge). We would therefore like to develop templates right in Word. The idea is to have an application/webservice that would receive the Word template and JSON data from the LAMP application and return the filled-in report. The report has to support:
Loops inside content (repeating a document section several times while filling in array data)
Filling in tables (populating rows from array)
Filling in chart data in pre-created charts (from array)
This is the functionality we are using in JasperReports right now. Are there existing solutions to this? I've found quite a lot that can substitute simple variables, but no info about the the above three points. Will it be a lot of effort to write one from scratch? I would prefer a Windows OpenXML-based solution rather than a Linux PHPOffice-based one as I presume the former would handle the text split by spell-checker and language tags (though I'm not sure).
Windward and Docmosis are both commercial products that support the features you've listed and they are intended to be added to your application to provide reporting capabilities. Neither is are not OpenXML based. They can use Word documents as templates and perform the data merge into different output formats. Please note I work for Docmosis.
Aspose Words is another tool and it can populate a template but most of the power is through code rather than controls/directives in the template. Given your OpenXML thoughts, perhaps this is more what you are looking for.
More tools are recommended here in StackExchange.
I hope that helps.
ReportBox is a Web based reporting solution that can be used by any software application to generate documents and reports in Microsoft Word/ Excel/ PowerPoint/ HTML(DocX/Xlsx/PPTx/HTML) using OpenXML.
The process starts by building a Microsoft Word/ Excel/ PowerPoint/ HTML document as a template and uploading to ReportBox portal. Your application either sends data to ReportBox or ReportBox can pull data from your application database, which is then merged with the template to produce the finished report. Please note that I work for GreenThoughts.

Mailmerge in asp.net

How to do a mail merge in asp.net without installing word on the server?
any dlls or any components available?
Edits
The template document is already available. im not trying to create a word document. Just want to link the word document with the data.
Thanks
Personally, I would just look at using the System.Net.Mail class and its templating abilities. There is a nice library here: https://github.com/lukencode/FluentEmail which you can pass templates into and send emails that way with the data you require inserted into it.
EDIT: noticed you didn't actually specify whether it was print mailmerge or email, apologies if it is a print mailmerge you are trying to create, but for mass emailing with customized data in it, templating is definitely the way to go.
To accomplish the Word doc creation part of the question there is a previous thread about this: How can a Word document be created in C#?
To send the completed doc check out the System.Net.Mail namespace: http://msdn.microsoft.com/en-us/library/system.net.mail.aspx or if you can afford it I have had great experience with http://www.aspnetemail.com/.
We use Aspose.Words to perform mail merges from .net code. It's not cheap but once you get to grips with it it's very powerful.
Edit: I'm assuming you are looking to merge data from some sort of data store into a template word document which can be printed and distributed.
Another option is Docentric Toolkit. It is pure .NET and based on OpenXML without any dependency on MS Word, so it is a good fit for server side report generation.
Merging with data is done through placeholders, which get filled up with data at run time. Data can come from database or XML.
Templates are created in MS Word which needs Docentric Toolkit add-in installed (license is needed).
It is really easy to create templates and to merge them with data from .NET code.

MS Word mailmerge like functionality to allow export to Word document from ASP.Net Web application

I have requirement where I need to allow users to upload a Word document with place holders for certain fields which can be found in the database. This will be their template. For example the place holders might be prepended with ## or something. For example
Dear ##Title ##Lastname
They then can grab a record and hit export to Word document. This will then let them choose the template. They can select the template and then click continue. I will then get the template and replace the ##Title with the title field in the database for the selected record. I am not sure where to start or what components I need to do this.
From my initial investigation it seems that I can do this with the new open XML standard for Office 2007. So perhaps I should read in the template and save all the contents to a db table somewhere. Then when the use wants to export I get the contents again and then do a search and replace for the ## placeholders and link them properly. Then save the document to the output stream again which will then bring up the save dialog on their browser.
I am using ASP.Net MVC and am in a hosted environment. I was also maybe contemplating dynamically creating a new View type and dynamically creating new views when the user uploads a template. Not sure that this approach will work though.
Is this a good approach?
What tools should I be looking at?
Any other suggestions?
This is similar to an approach we took for inserting data into word documents and then returning them to the user. We opened the .docx file (it's a zip file so easy to extract) extracted the document (in the word folder called document.xml), did the replace and then put the document back into the .docx file and returned it to the user.
An issue we hit were that word inserted tags at strange places, especially things like spell/grammar errors, so we needed to be careful when we did the search/replace.
We decided not to store the fields from the document in a database to allow the documents to be easily updated.
We used dotnetzip component for opening the .docx files
Something we also did was to combine several documents into a single large document to save on the number of downloads. If I remember we used the open xml toolkit to do this merging. The website has also got loads of other information that may be of use.
Check out Scott Guthries blog post about the new view engine code named "Razor" coming out real shortly from Microsoft. In the comments there is talk about it being able to be used in mail merge scenarios like you talk about with ASP.NET MVC views.

User defined reports with SSRS

I have an web application which serves SQL reporting services reports via the reportviewer control. Because of the complexity of some of the reports I use rdlc reports attached to business objects.
Now I would like to expand the system and allow some form of user-defined reports. Ideally I would like the users to connect their reports to the same business objects I use to create the rdlc reports.
Is there a control that allows users
to create/edit their own rdlc files?
Can rdl files be attached to
business objects?
Any hints/tips for writing my own
control to edit rdlc files? (I would
think this is a lot of work
and would only attempt if there is
no suitable answer to 1 or 2).
All my development has been done in VS 2005 with SQL 2005 but I could upgrade if new features in 2008 help with the solution.
This isn't much of an answer, but at my company I have put together our own Report Builder.
We have about 30 or so Reporting Service reports that our users can access through the web or desktop application. What we wanted to do was give our users the ability to take any given section within those reports and create their own.
If there is a report we have built for them but they don't want to see the graph, they can create the same report with out it. If they want to combine parts from 4 different reports to make one summary report they can drag those sections around on our custom builder and save it.
The report builder I had to put together pulls down all the different sub-reports they have chosen and reads through the XML adding them to a Report Builder Template XML file I have created. I then have to aggregate all the parameters so as to not ask for them more than once (parameter names do have to be unique across all reports if you don't want them aggregated). This new report XML is deployed to the server and the users can access them when ever they want.
I've also given them the ability to create their own cover pages, headers, and footers by dragging text boxes, images, global variables (date ran, created, ran by, page number, etc... anywhere on a blank canvas. I then convert all the items they've drug around and resized on this canvas in to another report XML file and deploy it as a sub-report that they can add to their custom reports.
Yes, this has taken quite a bit of work, but our users love it. We're in the process now of allowing them to create a report with special groupings so the report can be ran at different levels.
So it is possible, but there is no easy answer. =) I'd be glad to give advice to anyone who asks, but a direct copy of the code is a violation of my contract, but I'll do what I can outside of that.
I think SQL Reporting Services isn't meant for this kind of customization. You can hide and show controls and subreports, but stuff like interactive grouping etc isn't there.
You might look into a third-party reporting framework like Telerik's.

Generating WordML Reports Using Templates and XPath using ASP.Net

I need to know how we can Generate WordML Reports Using Templates and XPath using ASP.Net.
What are its advantages.
A Simple How To Tutorial is what I require.
I need to know how we can Generate WordML Reports Using Templates and XPath using ASP.Net. ... A Simple How To Tutorial is what I require.
Create (using Word) a document in WordML format which you'll use as a template.
Look at your WordML template: see that it's in XML format. Have Microsoft's WordML reference documentation, so that you understand what it means and how to modify it.
Define XPath expressions which identify the locations in your template which you want to modify (where "modify" probably means "insert data at run time").
At runtime use an API like http://www.google.com/search?hl=en&q=c%23+xpath
What are its advantages.
Its advantages over what alternative?
The benefit is that the output is a Word document, whose content is based on a template plus modifications made at runtime.
I would recommend you to use Content Controls and Custom XML for the purpose of report generation. Here's a sample:
http://blogs.msdn.com/erikaehrli/archive/2006/08/11/word2007DataDocumentGenerationPart1.aspx
You might also want to have a look at Microsoft's OpenXML SDK v2.0

Resources