将excel文件导入WPF,C# [英] Import excel files to WPF ,C#

查看:558
本文介绍了将excel文件导入WPF,C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望用户能够从他们的excel文件导入一些数据,所以我使用它



 //创建OpenFileDialog 
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();



//设置文件扩展名和文件扩展名的过滤器
dlg.DefaultExt =。txt;
dlg.Filter =EXCEL Files(* .xls)| * .xlsx;


//通过调用ShowDialog方法显示OpenFileDialog
Nullable< bool> result = dlg.ShowDialog();


//获取所选文件名并显示在TextBox
if(result == true)
{
//打开文档
string filename = dlg.FileName;





通过这个他们可以浏览他们的excel文件。但是如何让WPF从选定的excel文件导入数据





谢谢。

解决方案
http://www.codearsenal.net/2012/06/c-sharp-read-excel-and-show-in-wpf.html#.URPyfPJJocU [ ^ ]



这可能会有所帮助。


I want users can be able to import some data from their excel files so i use this

// Create OpenFileDialog
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();



// Set filter for file extension and default file extension
dlg.DefaultExt = ".txt";
dlg.Filter = "EXCEL Files (*.xls)|*.xlsx";


// Display OpenFileDialog by calling ShowDialog method
Nullable<bool> result = dlg.ShowDialog();


// Get the selected file name and display in a TextBox
if (result == true)
{
    // Open document
    string filename = dlg.FileName;



By this they can browse their excel file. But how can i make the WPF import the data
from the selected excel file?

Thanks.

解决方案

http://www.codearsenal.net/2012/06/c-sharp-read-excel-and-show-in-wpf.html#.URPyfPJJocU[^]

That might help.


这篇关于将excel文件导入WPF,C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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