使用C#.net将Excel中第8行的数据作为标题和剩余行作为数据上传到sql server [英] Upload Data from Excel at 8th row as header and Remaining row as a Data to sql server using C#.net

查看:53
本文介绍了使用C#.net将Excel中第8行的数据作为标题和剩余行作为数据上传到sql server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我正在使用asp.net c#应用程序中的Oledb提供程序从excel文件中将数据写入DataSet。



查询:SELECT * FROM [Sheet1 $]



一切正常但我担心的是从第1行到第7行应该是第二排应该用于数据行的前进和休息。



我需要紧急帮助。



谢谢

Mohan

解决方案





一切正常但我担心的是从第1排到第7排应该滑雪,第8排应该用于数据行的标题和休息。



我需要紧急帮助。



谢谢

Mohan


这不是我之前做过的事情,但读完了这个帖子在这里:



http://stackoverflow.com/questions/4929217/openrowset-for-excel-can-we-skip-several-rows [ ^ ]



虽然这两个响应都没有标记为解决方案,但值得尝试。


Hello Mohan,



您必须仅从数据库中检索这些记录,然后绑定到Excel工作表。例如

  DECLARE   @ From  = < span class =code-digit> 7 ; 
DECLARE @ To = SELECT COUNT(*) FROM MyTable;
WITH NumberedMyTable AS

SELECT
Id,
Value,
ROW_NUMBER() OVER ORDER BY Id) AS RowNumber
FROM
MyTable

SELECT
Id,
价值
FROM
NumberedMyTable
WHERE
RowNumber < span class =code-keyword> BETWEEN @ From AND @至


Hi All,

I'm stroing data into DataSet from excel file using Oledb provider in asp.net c# application.

query: SELECT * FROM [Sheet1$]

everything is working fine but my concern is that from 1st row to 7th row should be skiped and 8th row should be used for heading and rest for datarow.

I need help on urgent basis.

Thanks
Mohan

解决方案



everything is working fine but my concern is that from 1st row to 7th row should be skiped and 8th row should be used for heading and rest for datarow.

I need help on urgent basis.

Thanks
Mohan


It's not something that I have done before, but had a read of this thread here:

http://stackoverflow.com/questions/4929217/openrowset-for-excel-can-we-skip-several-rows[^]

Although neither response is marked as a solution it could be worth trying them.


Hello Mohan,

You have to retrive only those records from database and then bind into excel sheet. e.g.

DECLARE @From = 7;
DECLARE @To = SELECT COUNT(*) FROM MyTable;
WITH NumberedMyTable AS
(
    SELECT
        Id,
        Value,
        ROW_NUMBER() OVER (ORDER BY Id) AS RowNumber
    FROM
        MyTable
)
SELECT
    Id,
    Value
FROM
    NumberedMyTable
WHERE
    RowNumber BETWEEN @From AND @To


这篇关于使用C#.net将Excel中第8行的数据作为标题和剩余行作为数据上传到sql server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆