This is a common task for ASP.NET developers. You have a Web application where you expose data from a database, Web service, or third-party API and you need an "Export to Excel" button. I have used different approaches to export to Excel from a Web application. Here's some options and guidance of when to use each one.
Note: I can't stop to mention the big no-no… using the Excel PIA to generate a spreadsheet server-side. This is not a good practice and it's not recommended or supported, so let's forget about this one.
Now, for those of you who are working with any of the first three approaches, you may have seen the prompt of file format differ each time you export to Excel.
You get this message because you are opening a file in Microsoft Office Excel 2007 that contains content that does not match the files extension.
I am not very annoyed about this, but I know some people are. By default, a user can decide whether to open the file when the warning message is displayed, but you can control user-notification either:
Here's a KB article that provides detailed steps for both options: When you open a file in Excel 2007, you receive a warning that the file format differs from the format that the file name extension specifies.
Here's a quick code sample in C# for approach 3 (Export from GridView) that you can use to export to Excel. I changed my registry following the steps explained in the previous article and it worked like a charm. No prompt!
I came across some interesting blog posts this week and here's a few links that I'd like to share with you.
Learning about Office 14 is one of the most exciting things I've been doing since I came back. I am dying to talk about so many of the great new features for developers in Office 14. Can't say much now (hopefully soon I will), but I came across a public announcement from PDC: Office 14 on the Web. In case you missed it (like me), Microsoft announced at PDC that the new release of Office will deliver Office Web applications - lightweight versions of Word, Excel, PowerPoint and OneNote - through a browser. With these new applications, people can use a browser to create, edit, and collaborate on Office documents. What's great is that this provides a consistent Office experience when and where our customers want it, regardless of whether they are accessing their Office documents through the PC, phone, or browser.
Want to see how it works? Here's a cool Channel 9 demo where you can watch it in action.
Angela Chu-Hatoun has written most of the Outlook dev documentation you see on MSDN, so she is a super Outlook expert. Some years ago we used to share an office. Now we have our own offices, but sometimes we hang out and chat. As good geeks we are, we talk about technology and Outlook stuff and this week we were talking about the latest release of the Outlook MAPI. The MAPI for Outlook 2007 provides a set of classes, interfaces, functions, and other data types to facilitate the development of Outlook 2007 messaging applications. Angela worked for the last few months on an update and she blogged this week about the latest release.
I've spent the last few days pulling 2008 metrics for Office & SharePoint developer content. It's quite interesting to see what flavor of chocolates devs pick at the candy store.
The Office System is an umbrella of products and technologies. Popular picks from the Office dev community include SharePoint, Open XML, WSS, the Fluent UI, Excel, Access, and Word technical documentation.
Here's to the very best of Office & SharePoint developer content and kudos to all the authors who contribute to our publishing queue! Now the list of the very best candies…
I'll end my Office candies blog post with a great dessert. Have you seen Soma's latest blog post? Office client developer enhancements with VS 2010.
As an Office dev I have to say that the three key improvements that Soma announced will definitely make Office.NET development even easier.
Hopefully we'll have some dev content in the future that shows how to get the best out of these features.
We've published today a new set of Open XML implementation notes. The ECMA-376 Implementation Notes helps developers to understand low-level details of the Open XML implementation. The notes also include information that will help ISO update the standard over time, and some other general information to cover some scenarios that are not covered in detail by the SPEC.
The notes are definitely a great resource for all us who work with the Open XML SDK 1.0 and 2.0 and are looking for detailed documentation and guidance. I know lots of devs out there are creating document assembly solutions and the notes help you understand fine details of the implementation. Say you are working with WordprocessingML and want to learn about paragraphs, tables, footers, document parts, or mail merge. If you don't know the SPEC by heart (like most of us J), and want to learn more about the implementation details, you can always check out the implementation notes.
Great blogs posts you should not miss:
You can also subscribe to the Microsoft Interoperability RSS feed, where you can find 3rd party and Microsoft bloggers sharing the latest news about interoperability.
Here is a list on links that I want to share with you.
Some Office solutions require that you work with XML. Open XML documents, SharePoint, and InfoPath are great samples. LINQ to XML is an in-memory XML programming interface that enables you to modify XML documents efficiently and easily. One of the great advantages of using LINQ to XML is that it greatly simplifies the task of processing XML documents. Making Office development even easier.
If you are new to LINQ to XML, you can explore the .NET Language-Integrated Query for XML Data MSDN article by Michael Champion. You can also find tons of resources at the LINQ Project resource center on MSDN.
Definitely the best of blogs for Office + LINQ is Eric White's blog. Eric has posted multiple blog entries about Office and LINQ. My favorite post is: Using LINQ to Query Excel Tables. Eric is working on a new series of posts about SharePoint and LINQ. His two latest posts include:
While I was out of office, the Office Developer Documentation Group published an online version of the latest versions of the posters:
While reviewing traffic to some of our MSDN content, I noticed that the Office Visual How-tos we've published on the MSDN Library are getting lots of page views!
Developers seem to like this content type since it provides a short article, code sample, and video. This content type provides quick demos that show you how to work with specific features provided by different Office products and technologies.
We've covered a broad set of topics, such as Open XML, SharePoint, WSS, Word, Outlook, Access, InfoPath, and VSTO.
Here's a list of the most recently published Office Visual How-tos:
Visual How To: Creating SharePoint Sequential Workflows with Visual Studio 2008
Visual How To: Creating Workflows to Transfer Records Upon Expiration in SharePoint Server 2007
Visual How To: Preventing Document Modification in Windows SharePoint Services 3.0
Visual How To: Preventing Record Modification but Allowing Metadata Modification by Overriding the Upload Page in Windows SharePoint Services 3.0
Visual How To: Building State Machine Document Approval Workflows for SharePoint Server 2007 Using Visual Studio 2008
Visual How To: Creating a Custom Approval Workflow for SharePoint Server 2007 Using SharePoint Designer 2007
Visual How To: Configuring and Deploying Workflows to SharePoint Server 2007 Using Solution Packages
Visual How To: Creating Custom Workflow Activities for SharePoint Server 2007 Using Visual Studio 2008
Visual How To: Building an Expense Report Approval Workflow for SharePoint Server 2007 Using Visual Studio 2008
Visual How To: Updating Document Information Panels for Content Type Changes in SharePoint Server 2007
Here's a list of some of the most popular topics:
You can visit the Office Developer How To Center for a complete list of Office Visual How-tos.
Here's the how-to video RSS feed: http://www.microsoft.com/feeds/msdn/en-us/office/video.xml
We have identified some Office 2007 content gaps and missing code samples and we will start building a new set of Office Visual How-tos. One of the things we've been asked is to provide the code of these articles as code sample downloads. We plan to start publishing the code sample downloads to the MSDN Code Gallery. Also, we are exploring the option of publishing the most popular videos in Zune format.
Please leave a comment with your suggestion of any Office, SharePoint, and VSTO topics/code samples that we should provide in the future. I'll keep an eye on this blog entry.
Sofia came five months ago and I can honestly say that so far she has been the best part of my life.
Spend a few months with a kid and you'll get to know a new side of you that you never imagined you had. It's like starting to live all over again. Even the simplest smile or sound coming out of your little one can make you go wild. Anyway, as many other lucky working moms, I get to enjoy the beauty of motherhood and the fun of a happy job to get back to.
One of the things I missed the most was blogging. I am quite eager to share with you some stats about Office developer content, Office 14 news, Open XML code samples, best of Office 2008 blog posts, and more.
Today is my first day at work after a long break and I am trying to catch-up with lots of stuff. I've spent a couple hours reviewing stats from our publishing system. While I was gone, the Office Developer Documentation Group published an astonishing amount of 199 content items. That is, a mix of technical articles, downloads, SDKs, book excerpts, and code samples. Kelly Bowen-McCombs, our MSDN Office Developer Center managing editor, blogged about some of the content published in the last few months. In case you missed her entries, you can find them here:
I am quite grateful that Kelly posted about Office Developer documentation news while I was out. I hope you enjoyed her blog posts.
In case you want to catch-up (like me) with all the Office developer content we published in the last few months, I recommend that you check back often our MSDN - Office Developer Center. I also recommend you to subscribe to our Office Developer RSS feeds. We have a few that you may find interesting:
RSS feeds we publish:
Other Office developer related RSS feeds:
I'd also like to use this blog post to thank everyone who has contacted me through my blog and sent me questions related to Office development. I will be answering as many questions as I can in the next couple of weeks. Thanks all for keeping up with my blog and expect to hear a lot from me this year J.
Happy 2009 to everyone!