Excel数据的简单显示在ListBox上

显示第一列的数据!本人水平一般,有错就当参考!  

             Excel.Application xApp = new Excel.Application();
            xApp.Visible = false;
            Excel.Workbook xBook = xApp.Workbooks._Open(@"D:\test.xls",
            Missing.Value, Missing.Value, Missing.Value, Missing.Value
            , Missing.Value, Missing.Value, Missing.Value, Missing.Value
            , Missing.Value, Missing.Value, Missing.Value, Missing.Value);
            Excel.Worksheet xSheet = (Excel.Worksheet)xBook.Sheets[1];

            for (int row = 1; row < 4; ++row)
            {
                    Excel.Range rng2 = (Excel.Range)xSheet.Cells[row, 1];
                   lineListBox.Items.Add(Convert.ToString(rng2.Value.ToString()));   
            }

           xApp.Quit();

你可能感兴趣的:(listbox)