• 大小: 0.04M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-03-28
  • 语言: C#
  • 标签: c#  

资源简介


c#实现从Excel导入数据到textbox中

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;

namespace WindowsFormsApplication5
{
    public partial class Form1 : Form
    {
        OpenFileDialog ofd = null;
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            ofd = new OpenFileDialog();
            ofd.Multiselect = false;
            ofd.InitialDirectory = “D:\\“;
            ofd.Filter = “Excel (.xls)|*.xls|Excel(.xlsx)|*.xlsx“;
            ofd.RestoreDirectory = true;
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                DataSet ds = ExecleDs(ofd.FileName);           //调用自定义方法
                DataRow[] dr = ds.Tables[0].Select();            //定义一个DataRow数组
                int rowsnum = ds.Tables[0]

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      10752  2009-11-12 11:24  从Excel导入数据到textbox中\WindowsFormsApplication5\bin\Debug\WindowsFormsApplication5.exe

     文件      26112  2009-11-12 11:24  从Excel导入数据到textbox中\WindowsFormsApplication5\bin\Debug\WindowsFormsApplication5.pdb

     文件      14328  2009-11-12 16:31  从Excel导入数据到textbox中\WindowsFormsApplication5\bin\Debug\WindowsFormsApplication5.vshost.exe

     文件        490  2009-06-11 05:14  从Excel导入数据到textbox中\WindowsFormsApplication5\bin\Debug\WindowsFormsApplication5.vshost.exe.manifest

     文件       3164  2009-11-12 16:32  从Excel导入数据到textbox中\WindowsFormsApplication5\Form1.cs

     文件       3351  2009-11-12 16:32  从Excel导入数据到textbox中\WindowsFormsApplication5\Form1.Designer.cs

     文件       6017  2009-11-12 16:32  从Excel导入数据到textbox中\WindowsFormsApplication5\Form1.resx

     文件        915  2009-11-12 16:31  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug\WindowsFormsApplication5.csproj.FileListAbsolute.txt

     文件        847  2009-11-12 11:24  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug\WindowsFormsApplication5.csproj.GenerateResource.Cache

     文件      10752  2009-11-12 11:24  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug\WindowsFormsApplication5.exe

     文件        180  2009-11-12 11:24  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug\WindowsFormsApplication5.Form1.resources

     文件      26112  2009-11-12 11:24  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug\WindowsFormsApplication5.pdb

     文件        180  2009-11-12 10:44  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug\WindowsFormsApplication5.Properties.Resources.resources

     文件        505  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\Program.cs

     文件       1380  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\Properties\AssemblyInfo.cs

     文件       2898  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\Properties\Resources.Designer.cs

     文件       5612  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\Properties\Resources.resx

     文件       1109  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\Properties\Settings.Designer.cs

     文件        249  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\Properties\Settings.settings

     文件       3759  2009-11-12 10:39  从Excel导入数据到textbox中\WindowsFormsApplication5\WindowsFormsApplication5.csproj

     文件        962  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5.sln

    ..A..H.     14336  2009-11-12 16:32  从Excel导入数据到textbox中\WindowsFormsApplication5.suo

     目录          0  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug\TempPE

     目录          0  2009-11-12 10:47  从Excel导入数据到textbox中\WindowsFormsApplication5\bin\Debug

     目录          0  2009-11-12 11:24  从Excel导入数据到textbox中\WindowsFormsApplication5\obj\Debug

     目录          0  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\bin

     目录          0  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\obj

     目录          0  2009-11-12 10:34  从Excel导入数据到textbox中\WindowsFormsApplication5\Properties

     目录          0  2009-11-12 16:32  从Excel导入数据到textbox中\WindowsFormsApplication5

     目录          0  2009-11-12 10:34  从Excel导入数据到textbox中

............此处省略4个文件信息

评论

共有 条评论