如何将excel文件导入datagrid,然后使用WPF MVVM保存在SQL Server数据库中?请帮忙 [英] How to import excel file into datagrid and after that save in SQL server database using WPF MVVM? Please help

查看:407
本文介绍了如何将excel文件导入datagrid,然后使用WPF MVVM保存在SQL Server数据库中?请帮忙的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我搜索了这么多帖子,解释静态方式的一些帖子不清楚,有些帖子不支持最新的excel文件这么多问题。请尽快帮我。谢谢你提前。



我尝试过的事情:



Excel表未使用C#WPF(MVVM)导入数据库。请帮忙举例。

I have searched for so many posts that explain static manner some of the posts are not clearly some of the posts are not supporting for latest excel files so many problems.Please help me as soon as possible. Thanks for advance.

What I have tried:

Excel Sheet Not Imported into database using C# WPF (MVVM). Please help with Example.

推荐答案

引用:

如何将excel文件导入datagrid然后使用WPF MVVM保存在SQL Server数据库中?

How to import excel file into datagrid and after that save in SQL server database using WPF MVVM?



你问的是3个不同的无关问题。

即使你的问题看起来像一个摇摆不定的解决方案另一个问题。

你问的方式,看起来你已经搜索了一个完整的爆炸解决方案,你可以简单地复制/粘贴。它不会那样工作。

你必须为每个问题搜索一个解决方案,然后你才能解决问题。



学习使用Google。


You are asking 3 different unrelated questions.
Even your question look like a wobbly solution to another problem.
And the way you ask it, it looks like you have searched a full blowup solution that you can simply copy/paste. It don't work like that.
You have to search a solution for each question and then you are the one that make the glue between the solutions.

Learn to use Google.


这是可能的,虽然你需要按照几个步骤,它们如下



步骤1:使用OpenFileDialog获取文件路径

It is Possible, though you need is to follow several steps,they are as following

Step 1 : Get the filepath using OpenFileDialog
var fd = new OpenFileDialog();
            fd.Multiselect = false;
            fd.Title = "Upload Excel File";
            fd.ValidateNames = true;
            fd.DefaultExt = "xls";
            fd.Filter = "Excel Files (*.xls)|*.xls";
            fd.FilterIndex = 1;

string fp = string.Empty;
fp = fd.FileName;





第2步:查询例如:



Step 2 : Make A query for eg:

select [column1],[column2],[column3],[column4],[column5] from [Sheet1






hereSheet1



here "Sheet1


这篇关于如何将excel文件导入datagrid,然后使用WPF MVVM保存在SQL Server数据库中?请帮忙的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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