asp.net  订单导入,例如:Excel其中备注一列的前10行为0,其它为正常中文备注,导入时候只显示零,其它中文备注都为空,将10行中间任意一行改成文字就可以导入!这是为什么?   望大侠们帮忙,谢谢!

解决方案 »

  1.   

                string filename;
                this.OpenFileDialog1.Filter = "Excle文件(*.xls)|*.xls";
                if (this.OpenFileDialog1.ShowDialog() == DialogResult.OK)
                {
                    filename = this.OpenFileDialog1.FileName;               
                    string strconn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source='" +filename + "';Extended Properties=Excel 8.0;";
                    OleDbConnection oleConnection = new OleDbConnection(strconn);                string strCommondText = " SELECT * FROM [Sheet1$]   ";
                    oleConnection.Open();
                    DataSet myDataSet = new DataSet();
                    OleDbDataAdapter oleAdper = new OleDbDataAdapter(strCommondText, oleConnection);
                    oleAdper.Fill(myDataSet,"print");
                    
                    oleConnection.Close();
                    this.dataGridView1.DataSource = myDataSet.Tables["print"].DefaultView;
                    this.dataGridView1.Enabled = true;
                    this.dataGridView1.Columns[0].Visible = false;
                    this.dataGridView1.Columns[1].Visible = false;
                    this.dataGridView1.Columns[2].Visible = false;
     
                }
      

  2.   

    我之前做的导入也是碰到这样的问题,后来摆渡找到NPOI,这东西已经完全解决到我的问题,导入导出都不错,建议试试,开源的东西,有demo,这里就不贴代码了