Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Stephens' Visual Basic Programming 24-Hour Trainer
This is the forum to discuss the Wrox book Stephens' Visual Basic Programming 24-Hour Trainer by Rod Stephens; ISBN: 978-0-470-94335-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Stephens' Visual Basic Programming 24-Hour Trainer section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 14th, 2014, 11:49 AM
Authorized User
Points: 82, Level: 1
Points: 82, Level: 1 Points: 82, Level: 1 Points: 82, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2014
Posts: 19
Thanks: 4
Thanked 0 Times in 0 Posts
Default Export from entity context to excel

Hi, Is there a simple way to export a table from my entity framework to excel?

Appreciate it.
 
Old May 14th, 2014, 04:17 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,166, Level: 23
Points: 3,166, Level: 23 Points: 3,166, Level: 23 Points: 3,166, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

If you want to copy data selected by EF into an Excel workbook, look at this example: Entity Model to Excel using LINQ in C#.

If you want to copy the table's field names and data types into a worksheet, you could probably use reflection to get that information from the table's class.

Or you could just open up the automatically-generated file that defines the class and look at its properties. For example, suppose you create a model named StudentModel and it has an entity named Student. Then in Solution Explorer, you would open StudentModel.edmx > StudentModel.tt > Student.vb. It might look something like this:

Code:
Partial Public Class Student
    Public Property StudentId As Integer
    Public Property FirstName As String
    Public Property LastName As String
    Public Property NumUnits As Nullable(Of Integer)

End Class
Let me know if none of those options does what you want.
__________________
Rod

Rod Stephens, Microsoft MVP

Essential Algorithms: A Practical Approach to Computer Algorithms

(Please post reviews at Amazon or wherever you shop!)
The Following User Says Thank You to Rod Stephens For This Useful Post:
shabnamzangeneh (May 20th, 2014)
 
Old May 14th, 2014, 11:29 PM
Authorized User
Points: 82, Level: 1
Points: 82, Level: 1 Points: 82, Level: 1 Points: 82, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2014
Posts: 19
Thanks: 4
Thanked 0 Times in 0 Posts
Default

I tried the first method and it works great. Thanks a lot, Rod.




Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to Excel ramuis78 ASP.NET 2.0 Basics 2 May 30th, 2007 05:51 AM
Export to excel moonbreeze Reporting Services 1 November 20th, 2006 08:42 PM
Export to Excel using C# lily611 Crystal Reports 2 July 23rd, 2006 10:23 AM
Export to Excel rweide Classic ASP Basics 5 February 23rd, 2005 09:13 AM
excel export msrnivas .NET Web Services 1 March 29th, 2004 03:21 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.