Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2010 > BOOK: Stephens' Visual Basic Programming 24-Hour Trainer
Password Reminder
Register
Register | FAQ | Members List | Calendar | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old May 14th, 2014, 12:49 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 Export from entity context to excel

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

Appreciate it.
Reply With Quote
  #2 (permalink)  
Old May 14th, 2014, 05:17 PM
Rod Stephens's Avatar
Wrox Author
Points: 3,145, Level: 23
Points: 3,145, Level: 23 Points: 3,145, Level: 23 Points: 3,145, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2006
Location: , , .
Posts: 641
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!)
Reply With Quote
The Following User Says Thank You to Rod Stephens For This Useful Post:
shabnamzangeneh (May 20th, 2014)
  #3 (permalink)  
Old May 15th, 2014, 12:29 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

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


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Export to Excel ramuis78 ASP.NET 2.0 Basics 2 May 30th, 2007 06: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 11: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



All times are GMT -4. The time now is 09:26 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.