OpenFileDialog ofd=new OpenFileDialog ();
Ofd. Filter="Excel file (*. XLS) | *. XLS";
Ofd. FilterIndex=1;
Ofd. RestoreDirectory=true;
If (ofd. ShowDialog ()==DialogResult. OK)
{
Microsoft. Office. Interop. Excel. Application myexcel=new Microsoft. Office. Interop. Excel. The Application ();
If (myexcel==null)
{
MessageBox. Show (" the file does not exist!" );
}
Myexcel. Visible=false;
Myexcel. DisplayAlerts=false;
Myexcel. AlertBeforeOverwriting=false;
. Microsoft. Office. Interop. Excel Workbooks Workbooks.=myexcel Workbooks.
. Microsoft. Office. Interop. Excel Workbook Workbook=workbooks. The Add (ofd. FileName);
. Microsoft. Office. Interop. Excel Sheets Sheets=workbook. Worksheets.
. Microsoft. Office. Interop. Excel Worksheet Worksheet=(. Microsoft. Office. Interop. Excel Worksheet) sheets. The Item [3].
Microsoft. Office. Interop. Excel. Range Range;
The range=worksheet. UsedRange;
,,,,,,,,,,
This code is to open a Excel file and read the data, in my work computer win10 system can run normally, but in the other location when a computer running Windows 7 system, when choosing to open the file, running to Microsoft. Office. Interop. Excel. The Workbook Workbook=workbooks. The Add (ofd. FileName); Popup "untreated COMException", "exception from HRESULT: 0 x800a03ec,"
A great god please help see how should solve, thank!
CodePudding user response:
Installed on the computer is a complete version of excel, digits (32/64) and your program of digits are consistentCodePudding user response: