Click here to Skip to main content
16,016,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
CREATE TABLE [dbo].[tblClientPersonalInfo](
	[PersonalInfoId] [bigint] NOT NULL,
	[FolioGroupNo] [bigint] NULL,
	[ClientId] [bigint] NOT NULL,
	[IndentityStatus] [varchar](50) NULL,
	[RelationshipId] [bigint] NOT NULL,
	[Title] [varchar](30) NULL,
	[FirstName] [varchar](100) NULL,
	[MiddleName] [varchar](100) NULL,
	[LastName] [varchar](100) NULL,
	[Gender] [varchar](10) NULL,
	[DateOfBirth] [datetime] NULL,
	[HealthStatus] [varchar](50) NULL,
	[IssueDetails] [varchar](max) NULL,
	[Occupation] [varchar](50) NULL,
	[MobileNo] [bigint] NULL,
	[EmailId] [varchar](200) NULL,
	[Address] [varchar](500) NULL,
	[City] [varchar](50) NULL,
	[State] [varchar](50) NULL,
	[Country] [varchar](50) NULL,
	[PinCode] [bigint] NULL,
	[PANNo] [varchar](50) NULL,
	[MaritalStatus] [varchar](50) NULL,
	[MarriageAnniversary] [datetime] NULL,
	[ResidentialStatus] [varchar](100) NULL,
	[FinanciallyDependent] [bit] NULL,
	[PhotoPath] [varchar](200) NULL,
	[HeaderCoverPage] [varchar](200) NULL,
	[IsImported] [bit] NULL,
	[UserIdCreated] [bigint] NULL,
	[UserIdMaintain] [bigint] NULL,
	[CreatedDate] [datetime] NULL,
	[ModifiedDate] [datetime] NULL,
	CONSTRAINT [PK_tblCustomerPersonalInfo] PRIMARY KEY CLUSTERED 
)

From this SQL table I have to generate the Excel sheet.

how to do this?
Posted
Updated 3-Mar-12 2:39am
v3
Comments
André Kraak 3-Mar-12 8:39am    
Edited question:
Added pre tags
Formatted text/code

Hi,

You can programmatically create and insert data into an excel spreadsheet using the normal objects you use for database interaction.

All you have to do is create a proper connection string to allow it to connect to an Excel file. Here is something to get you started for that: http://www.connectionstrings.com/excel[^].

Once you can connect through to the "database" (in this case the excel file), you can do a create table for the data you want to import and then run normal insert statements like you would normally do when you connect to a normal database like MSSQL.

PS: If the excel file does not exist, you can actually programatically create the excel file using the normal way you create a database in code.

Hope that helps :)
 
Share this answer
 
You need to use Office interop. Start here:
http://msdn.microsoft.com/en-us/library/bb726434%28v=office.12%29.aspx[^],
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.excel%28v=office.14%29.aspx[^].

Basically, you start development with "Add Reference". Add a reference from the tab ".NET" of the "Add Reference" window; select "Microsoft.Office.Interop.Except" of appropriate version.

—SA
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900