Click here to Skip to main content
15,899,679 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello ,
Sir I have a question.
Question: How to open xls file in browser on button click in asp.net.
so give me sutable asnwer? I wait that answer.
Posted
Updated 25-Oct-10 18:48pm
v3
Comments
Tarakeshwar Reddy 25-Oct-10 23:49pm    
Do not provide your email address in a public forum.

C#
private void btnBrowse_Click(object sender, EventArgs e)
        {
            ofBrowse.ShowDialog();
        }
        private void ofBrowse_FileOk(object sender, CancelEventArgs e)
        {
            txtFile.Text = ofBrowse.FileName;
        }



To Open It


C#
if (File.Exists(txtFile.Text))
                {
                    if (txtSheetName.Text.Trim() == "")
                    {
                        MessageBox.Show("Please enter Sheet Name", "Sheet Name Required", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        txtSheetName.Select();
                        txtSheetName.Focus();
                        return;
                    }
                    ds = new DataSet();
                    Data.Fill(ds);
                    ddlParameter.Items.Clear();
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (ds.Tables[0].Rows[i][1].ToString().Trim() != "")
                            ddlParameter.Items.Add(ds.Tables[0].Rows[i][1].ToString().Trim());
                        if (ddlParameter.Items.Count > 0)
                            ddlParameter.SelectedIndex = 0;
                    }

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900