Click here to Skip to main content
12,759,067 members (34,076 online)
Click here to Skip to main content
Add your own
alternative version

Stats

13.7K views
10 bookmarked
Posted 24 Jan 2012

Utility to generate Word documents from templates using Visual Studio 2010 and Open Xml 2.0 SDK - Part 4

, 24 Jan 2012 CPOL
Rate this:
Please Sign up or sign in to vote.
This is the fourth part of this series. The code is available for download at http://worddocgenerator.codeplex.com/.

This is the fourth part of this series. The code is available for download at http://worddocgenerator.codeplex.com/.

In Part 1 I discussed about

  • Document generation using Content Controls and Open XML 2.0 SDK
  • Creating Word templates
  • Implementation and Samples

In Part 2 I discussed about

  • List of functionalities that can be achieved using the utility/source code
  • Description regarding Samples provided with utility
  • New samples added in this update

In Part 3 I discussed about

  • Document-level customizations for Word 2007 and Word 2010
  • One of the ways to “Refresh the document from within the Word(e.g. right click on document and click Refresh) using document-level customizations for Word 2007 and Word 2010“

This post will focus on Charts. I’ve added the samples to generate/refresh charts using OpenXML. The screenshot below displays the template having Scatter chart and Line chart and the document generated out of this template using this utility.

Word 2010 Template having Charts –> Generated documents with Charts refreshed:

image

image


Code Changes:

Class diagram for Chart specific classes is displayed below

image

SampleDocumentWithTableAndChartsGenerator” is the sample that shows how to refresh template having Scatter and Line charts. The code snippets are displayed below

  • RefreshCharts” method is added to DocumentGenerator class
/// <span class="code-SummaryComment"><summary>
</span>
  • SampleDocumentWithTableAndChartsGenerator” class overrides “RefreshCharts” method
/// <span class="code-SummaryComment"><summary>
</span>
  • Refresh method is defined in ChartEx<T>
/// <span class="code-SummaryComment"><summary>
</span>

For complete code download the source code.

Summary

Please provide feedback/comments and I’ll try to incorporate most of them in new releases.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

atverma
Software Developer (Senior)
India India
Atul works at Microsoft as a .NET consultant. As a consultant his job is to design, develop and deploy enterprise level secure and scalable solutions using Microsoft Technologies.

His technical expertise include .NET Framework(4.0, 3.5, 3.0), WPF, WCF, SharePoint 2010, ASP.net, AJAX, Web Services, Enterprise Applications, SQL Server 2008, Open Xml, MS Word Automation.

Follow him on twitter @verma_atul

He blogs at
http://www.atulverma.com
http://blogs.msdn.com/b/atverma

You may also be interested in...

Comments and Discussions

 
GeneralModify and update an embedded chart in a word 2010 document Pin
Benone IONESCU8-Jul-12 23:08
memberBenone IONESCU8-Jul-12 23:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 24 Jan 2012
Article Copyright 2012 by atverma
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid