简体   繁体   English

将SQL Server 2008表导出到C#中的Excel

[英]Export SQL Server 2008 tables to Excel in C#

We currently have a good deal of usage information being tracked in a SQL Server 2008 database. 当前,我们在SQL Server 2008数据库中跟踪了大量使用情况信息。 However, it has been decided to not spend the time to develop any sort of UI to interface with this data in our current admin system, and rather just provide a link to an Excel document with the information from these tables. 但是,已经决定不花时间开发任何类型的UI来与我们当前的管理系统中的该数据进行交互,而是仅提供具有来自这些表的信息的Excel文档的链接。

The link would be displayed on an ASP.NET page. 该链接将显示在ASP.NET页上。

I have googled around for a quick and easy way to do this -- this seems like the kind of thing that would already be taken care of. 我在Google周围搜寻了一种快速简便的方法来完成此操作-似乎已经可以解决这种事情了。 I find a million different articles on ten thousand different technologies related to this. 我发现有上百万篇有关一万种与之相关的技术的文章。

Given that I want to do this from code rather than by using SQL Server Management Studio or some other tool, what is the simplest/fastest way to offer up-to-date Excel spreadsheets to users generated from our SQL Server 2008 database? 鉴于我想通过代码而不是通过使用SQL Server Management Studio或其他工具来执行此操作,向从我们的SQL Server 2008数据库生成的用户提供最新的Excel电子表格的最简单/最快的方法是什么?

You can do this in SQL Server Management Studio. 您可以在SQL Server Management Studio中执行此操作。 No C# required. 无需C#。 Right-click on the database, ORIGIN: SQL Server database, DESTINATION: Excel and supply file path, write your query (or specify tables/views), and save as a SSIS package. 右键单击数据库,来源:SQL Server数据库,目的地:Excel和提供文件路径,编写查询(或指定表/视图),然后另存为SSIS包。 You can then schedule the SSIS package to run on whatever schedule is needed. 然后,您可以安排SSIS包以所需的任何时间表运行。 You can then expose the file or directory via a IIS vdir. 然后,您可以通过IIS vdir公开文件或目录。 Is there a reason that you need to do this from code given that you can set it up as a scheduled job? 鉴于您可以将其设置为计划作业,因此是否有理由从代码中执行此操作?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM