小弟我来问一个excel 批量导入到数据库表中,如何做,要源码?

解决方案 »

  1.   

    引入excel对象,遍历,然后导入..相关内容可以在网上搜一下.
     public void Process(string xlsPath)
            {
                object MISSING_OBJECT = Type.Missing;
                Excel.Application excelApp = null;
                try
                {
                    excelApp = new Excel.ApplicationClass();
                    excelApp.DisplayAlerts = false;                excelApp.Workbooks.Open(xlsPath,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT,
                                            MISSING_OBJECT);
                    workBook = excelApp.Workbooks[1];                ///////////..........
                }
                catch
                {
                    throw;
                }
                finally
                {
                    excelApp.Quit();
                }
            }