急急急!!!  如何将订单导入到OA中啊?

解决方案 »

  1.   

    我也在做类似的OA系统,把EXCEL表导入到OA数据库中。思路是EXCEL文件上传到服务器,在读取文件中的表,处理后加入OA数据库中。感觉简单其实也难。
      

  2.   

    你的订单是excel 么? 
      

  3.   

    楼主的意思是说将excel导入到数据库中吗?
      

  4.   

    try
      {
      ProductService.productAllDelete();
      string mystring = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" +Server.MapPath("upexcel/uplexcl.xls") + "; Extended Properties=\"Excel 8.0; HDR=No; IMEX=1;\"";
      OleDbConnection cnnxls = new OleDbConnection(mystring);
      OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [0.3-FJ-VS-VVS$]", cnnxls);
      DataSet myDs = new DataSet();
      myDa.Fill(myDs);
      DataTable table=myDs.Tables[0];
      foreach(DataRow row in table.Rows){
         这里面写插入数据库的方法
      }
      }
      catch (Exception)
      {
        
      Response.Write("<script>alert('导入Excel失败 请确保您上传的excel的编码格式是正确的!')</script>");
      }
      Response.Write("<script>alert('导入Excel成功!')</script>");这个是 excel 导入数据库的代码
      

  5.   

    想请教一下 如果是excel该怎么操作 详细点
    如果不是excel的又该怎样操作啊?
      

  6.   

    呃 这个具体操作逻辑要看你EXCEL 里面的设计来啊,上面的代码是将excel 当成一个表 然后读出来
    如果不是excel 那是什么文件呢? 不同的文件操作不同啊 你又没说是什么文件 我怎么说啊 
      

  7.   

    可以将Excel按列导入到数据库中去!~
      

  8.   

    try
      {
      ProductService.productAllDelete();
      string mystring = "Provider=Microsoft.Jet.Oledb.4.0; Data Source=" +Server.MapPath("upexcel/uplexcl.xls") + "; Extended Properties=\"Excel 8.0; HDR=No; IMEX=1;\"";
      OleDbConnection cnnxls = new OleDbConnection(mystring);
      OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [0.3-FJ-VS-VVS$]", cnnxls);
      DataSet myDs = new DataSet();
      myDa.Fill(myDs);
      DataTable table=myDs.Tables[0];
      foreach(DataRow row in table.Rows){
      if (row[3].ToString() == "形状")
      {
      continue;
      }
      if (row[3].ToString()=="")
      {
      break;
      }
      Product pd = new Product();
      pd.Product_bianhao1 = row[0].ToString();
      pd.Product_didian = row[1].ToString();
      pd.Product_bianhao2 = row[2].ToString();
      pd.Product_shape=row[3].ToString();
      double sumMoney= double.Parse( row[4].ToString());
      string dos = sumMoney.ToString("F3");
      pd.Product_Weight = dos;  pd.Product_color = row[5].ToString();
      pd.Product_Clarity = row[6].ToString();
      pd.Product_Cut = row[7].ToString();
      pd.Product_Polishing = row[8].ToString();
      pd.Product_duic=row[9].ToString();
      ProductService.productAdd(pd);
        
      }
      }
      catch (Exception)
      {
        
      Response.Write("<script>alert('导入Excel失败 请确保您上传的excel的编码格式是正确的!')</script>");
      }
      Response.Write("<script>alert('导入Excel成功!')</script>");
     
    上面是插入产品的列子