Interacting with Excel difficulties: read from Excel, Load XLS file, Save XLS file, etc

May 22 2004 8:43 AM
I'd like to do a number of things with Excel, and if you can answer any of these questions then that would be great: 1. I'd like to open a specific workbook XLS file, and choose a worksheet, so as to read cell values from the XLS file; 2. after changing some values I need to save a specific workbook and worksheet to a specific location. At the moment I can open a new workbook and worksheet, and I can write values in. But I can't refer to a specific XLS file, I can't get values from the XLS file, and I can't save the file after changing it. Here's what I have: Excel.Application objExcel = new Excel.Application(); objExcel.Visible = true; Excel.Workbook objBook = objExcel.Workbooks.Add(System.Reflection.Missing.Value); Excel.Worksheet objSheet = (Excel.Worksheet)objBook.Worksheets.get_Item(1); Excel.Range objRange; objRange = objSheet.get_Range("A1", System.Reflection.Missing.Value); objRange.Value2 = 75; I don't want to use SQL to read and write to the file.