• North American Sales: 1-800-231-8588
  • Global Contacts
  • My Account
Infragistics Infragistics
Menu
  • North American Sales: 1-800-321-8588
  • My Account
    • Sign In/Register
  • Design & DevelopmentDesign & Develop
    • Best Value
      Infragistics Ultimate The complete toolkit for building high performing web, mobile and desktop apps.
      Indigo.Design Use a unified platform for visual design, UX prototyping, code generation and application development.
    • Web
      Ignite UI for Angular Ignite UI for JavaScript Ignite UI for React Ultimate UI for ASP.NET Indigo.Design
    • Desktop
      Ultimate UI for Windows Forms Ultimate UI for WPF
      Prototyping
      Indigo.Design
    • Mobile
      Ultimate UI for Xamarin Ultimate UI for iOS Ultimate UI for Android
    • Automated Testing Tools
      Test Automation for Micro Focus UFT: Windows Forms Test Automation for Micro Focus UFT: WPF Test Automation for IBM RFT: Windows Forms
  • UX
    • Indigo.Design Desktop Collaborative prototyping and remote usability testing for UX & usability professionals
    • Indigo.Design A Unified Platform for Visual Design, UX Prototyping, Code Generation, and App Development
  • Business Intelligence
    • Reveal Embedded Accelerate your time to market with powerful, beautiful dashboards into your apps
    • Reveal App Empower everyone in your organization to use data to make smarter business decisions
  • Team Productivity
  • Learn & Support Support
    • Help & Support Documents
    • Blogs
    • Forums
    • Product Ideas
    • Reference Applications
    • Customer Stories
    • Webinars
    • eBook & Whitepapers
    • Events
  • Free Trials
  • Pricing
    • Product Pricing / Buy Online
    • Renew Existing License
    • Contact Us
WPF
  • Product Platforms
  • More
WPF
WPF Exporting the XamDataGrid to Excel
  • Blog
  • Files
  • Wiki
  • Mentions
  • Tags
  • More
  • Cancel
  • New
WPF requires membership for participation - click to join
  • WPF
  • Configuring the XamTab Control
  • Creating a Custom Summary for the XamDataGrid
  • Defining a Custom Path in the XamCarousel
  • Enabling Row Summaries in the XamDataGrid
  • Exporting the XamDataGrid to Excel
  • Hosting a WPF Control in a Windows Forms Application
  • Printing the XamDataGrid with Infragistics.Reports
  • Spell Checking in the XamDataGrid
  • Tangerine -- A WPF Reference Application
  • Using the Infragistics WinGrid in a WPF Application
  • Validation in the XamDataGrid
  • XamDataGrid :: Copying to Excel via the Clipboard
  • XML Databinding with the XamDataGrid

Exporting the XamDataGrid to Excel

Infragistics.Excel is an extremely powerful, yet little known API. It has the capability to build an entire Excel Workbook (and multiple worksheets). You can add formulas and interact with an Excel document in C# code in many different fashions. On the roadmap for Infragistics WPF is to add support for a single method call to export the XamDataGrid to Excel; in the meantime, this code library gives you the basic functionality in a single class that you can easily re-use to achieve the exporting work.

Basically, the class loops through RecordsCollection (also checks for records in the GroupByRecordsCollection) and creates a Infragistics.Excel.WorkSheetRow for each record.

To consume this class, simply new up the exporter class and call the export method:

xamDataGridExcelExporter.xamDataGridExcelExporter xamDataGridExcelExporter1 =    
   new xamDataGridExcelExporter.xamDataGridExcelExporter();
xamDataGridExcelExporter1.Export(this.xamDataGrid1,
   @"C:\Excel\ExportFile.xls");

You can find the sample code here.

 

  • WPF
  • XamDataGrid
  • Excel
  • Share
  • History
  • More
  • Cancel
Related
Recommended