SQL to Excel工作表从客户端生成数据 [英] SQL to Excel sheet generate the data from client side
本文介绍了SQL to Excel工作表从客户端生成数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
)
从此SQL表中,我必须生成Excel工作表.
From this SQL table I have to generate the Excel sheet.
how to do this?
推荐答案
您可以使用用于数据库交互的普通对象以编程方式创建数据并将数据插入excel电子表格.
您所要做的就是创建一个正确的连接字符串,以使其可以连接到Excel文件.以下是一些可帮助您开始的事情: http://www.connectionstrings.com/excel [
PS:如果excel文件不存在,您实际上可以使用在代码中创建数据库的常规方法,以编程方式创建excel文件.
希望对您有所帮助:)
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 :)
您需要使用Office互操作.从这里开始:
http://msdn.microsoft.com/en-us/library/bb726434%28v = office.12%29.aspx [ ^ ],
http://msdn.microsoft.com/zh-cn/library/microsoft.office.interop.excel%28v = office.14%29.aspx [
—SA
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
这篇关于SQL to Excel工作表从客户端生成数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文