Hi Robert, here you have a bit:
Microsoft.Office.Interop.Excel.Application app = new
Microsoft.Office.Interop.Excel.Application();
Microsoft.Office.Interop.Excel.Workbook book = null; //to access to book
Microsoft.Office.Interop.Excel.Worksheet sheet = null; //to access to sheet
Microsoft.Office.Interop.Excel.Range range = null; //to access to a range of
data "A1:B2"
book = app.Workbooks.Open("c:\\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,
Missing.Value, Missing.Value);
sheet = (Microsoft.Office.Interop.Excel.Worksheet)book.Wor ksheets.get_Item[1];
range = sheet.get_Range("A1","B5");
Only take care about release resources from excel. Use ReleaseComObject
foreach com object that you use.
System.Runtime.InteropServices.Marshal.ReleaseComO bject(range);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(sheet);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(book);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(app);
Hope this helps.
Regards.
Josema
"Robert Bravery" wrote:
HI all,
I'm new to C#.
I want to open an excel document and work with it in C#.
I currently have Excel2000, I think it is version9.0. But Clients might have
office XP, XP2003 on
Could someone be so jind as to show me some code or point me in the right
direction.
Thanks
Robert