I'm trying to read a MS Office Excel document so I can test a group of regular expressions against it. I have something that works but it seems incredibly clumsy. Checking every single cell.... I just can't imagine this is the best way. Any suggestions to make this better.
    static void ReadMSOfficeExcelFile(string file) {
        try {
            Microsoft.Office.Interop.Excel.Application xlsApp = new Microsoft.Office.Interop.Excel.Application();
            object nullobj = System.Reflection.Missing.Value;
            object ofalse = false;
            object ofile = file;
            Microsoft.Office.Interop.Excel.Workbook xlsWorkbook = xlsApp.Workbooks.Open(
                                                             file, nullobj, nullobj,
                                                             nullobj, nullobj, nullobj,
                                                             nullobj, nullobj, nullobj,
                                                             nullobj, nullobj, nullobj,
                                                             nullobj, nullobj, nullobj);
            Microsoft.Office.Interop.Excel.Sheets xlsSheets = xlsWorkbook.Worksheets;
            foreach (Microsoft.Office.Interop.Excel.Worksheet xlsWorkSheet in xlsWorkbook.Sheets) {
                Microsoft.Office.Interop.Excel.Range xlsRange = xlsWorkSheet.UsedRange;
                foreach (Microsoft.Office.Interop.Excel.Range xlsRow in xlsRange.Rows) {
                    foreach (Microsoft.Office.Interop.Excel.Range xlsCell in xlsRow.Columns) {
                        CheckLineMatch(file, xlsCell.Text.ToString());
                    }
                }
            }
            xlsWorkbook.Close(ofalse, nullobj, nullobj);
        }
        catch {
            PrintError("Unable to parse file because of MS Office error.", file);
        }
    }
 
     
     
     
    