日期:2014-05-17 浏览次数:21278 次
string ExcelStr = "aaaaaa";
string UserStr = "bbbbbbbbb";
if (string.Compare(ExcelStr, UserStr) == 0)
{
Response.Write("=========");
}
Excel.Application appExcel = new Excel.Application();
Excel.Workbook workBook;
Excel.Worksheet workSheet;
workBook = appExcel.Workbooks.Open("你Excel的路经", Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
workSheet = (Excel.Worksheet)workBook.Worksheets["Excel里的Sheet名字"];
Excel.Range rcol1 = (Excel.Range)workSheet.Cells[5,5];//Cells参数为第5行第5列的单元格
//rcol1.Value 这个就是Excel的值 然后和你C#的值做比较就好
workBook.Close(true,Missing.Value,Missing.Value); //关闭
appExcel.Quit(); //退出Excel