简体   繁体   中英

Reading data from sql server into excel sheet via Web Service

consider you have an existing excel worksheet, which needs to load data from sqlserver. The data is normalized, so reading from a table is not an option. Btw, it's Excel 2010.

I tried to provide the data via , but since I have to do some , SPs are not an option. 来提供数据,但是由于我必须进行一些 ,因此SP不是一种选择。

The next idea is to provide the data via . 提供数据。 I read this article but I don't like the result, because the content of the worksheet is written in the .Net code. The solution I'd prefer would be some kind of , which can be used directly in the excel sheet, similar to reading data directly from a table. ,可以直接在excel工作表中使用,类似于直接从表中读取数据。

Is there a way to achieve that?


Because of the first comments and answers. Consider as data transformation eg a conversion from ticks ( long ) to DateTime . I've to do it in .net, because the result depends on the target time zone.

There are several ways to do this if i read your question correctly:

Create a new excel sheet document, use the 'From other sources' selection under the 'Data' tab in the new excel sheet, provide your SQL details and connect to the data you need to display in the excel sheet.

You can also use the 'Import and Export Data' tool that is installed with SQL Server. It is a fairly simple process, and the tool walks you through the necessary steps to export the data to an excel sheet.

If you need to do this in application code, you can use a custom database view which returns your processed data and custom columns, invoke this DB view from code, retrive the data rows and write to an excel sheet file. The following link shows how to do this in C#: http://csharp.net-informations.com/excel/csharp-excel-export.htm

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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