Results 1 to 3 of 3

Thread: [RESOLVED] WPF: How to Import data from Excel to DataGrid?

  1. #1

    Thread Starter
    Addicted Member Kram Kramer's Avatar
    Join Date
    Dec 2016
    Posts
    131

    Resolved [RESOLVED] WPF: How to Import data from Excel to DataGrid?

    Following code is okey in the WinForm Application.

    http://vb.net-informations.com/datag...iew_import.htm

    I need WPF version of that WinForm code.

    Note: DataGridView is named DataGrid in the WPF.

  2. #2
    Lively Member
    Join Date
    Jan 2020
    Posts
    90

    Re: [RESOLVED] WPF: How to Import data from Excel to DataGrid?

    private void button1_Click_1(object sender, EventArgs e)
    {
    OpenFileDialog fdlg = new OpenFileDialog();
    fdlg.Title = "Select file";
    fdlg.InitialDirectory = @"c:";
    fdlg.FileName = txtFileName.Text;
    fdlg.Filter = "Excel Sheet(*.xls)|*.xls|All Files(*.*)|*.*";
    fdlg.FilterIndex = 1;
    fdlg.RestoreDirectory = true;
    if (fdlg.ShowDialog() == DialogResult.OK)
    {
    txtFileName.Text = fdlg.FileName;
    Import();
    Application.DoEvents();
    }
    }

  3. #3
    Lively Member
    Join Date
    Jan 2020
    Posts
    90

    Post Re: [RESOLVED] WPF: How to Import data from Excel to DataGrid?

    private void button1_Click_1(object sender, EventArgs e)
    {
    OpenFileDialog fdlg = new OpenFileDialog();
    fdlg.Title = "Select file";
    fdlg.InitialDirectory = @"c:";
    fdlg.FileName = txtFileName.Text;
    fdlg.Filter = "Excel Sheet(*.xls)|*.xls|All Files(*.*)|*.*";
    fdlg.FilterIndex = 1;
    fdlg.RestoreDirectory = true;
    if (fdlg.ShowDialog() == DialogResult.OK)
    {
    txtFileName.Text = fdlg.FileName;
    Import();
    Application.DoEvents();
    }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width