日期:2014-05-17  浏览次数:21009 次

内蒙古的菜鸟求高手解决下问题
代码功能是从excel中读数据:代码如下
 for (int j = 1; j < 32; j++)
            {

                string path = @"D:\预警、重要报告、通报\乡镇\1\" + j + ".xls";
                MessageBox.Show(path);
                Microsoft.Office.Interop.Excel.Application excel2 = new Microsoft.Office.Interop.Excel.Application();
                excel2.Visible = true;             //得到WorkBook对象, 可以用两种方式之一: 下面的是打开已有的文件      
                Excel.Workbook xBook = excel2.Workbooks._Open(path, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);             //xBook=xApp.Workbooks.Add(Missing.Value);//新建文件的代码            
                Excel.Sheets objSheets;
                Excel._Worksheet objSheet;
                Excel.Range range;//=new Range[100];
                string[] td1 = new string[10000];
                string[] td2 = new string[10000];
                string[] tg1 = new string[10000];
                string[] tg2 = new string[10000];
                string[] qq1 = new string[10000];
                string[] qq2 = new string[10000];



                //Get a reference to the first sheet of the workbook.