我又重新编辑了一下
1.打开软件
2..点文件打开
3.打开psy++
4.手动打开了一个excel
5.spy++查看
这个时候我软件本来是要操作之前打开的report.xlsx, 就变成了操作新建 Microsoft Office Excel 2007 Workbook.xlsx了。。。
下面是打开程序
public static Excel._Application reportExcel;
public static Excel._Workbook reportWorkbook;
public static Excel._Worksheet reportSheet;
public static void openReportExcel()
{
// string fileName="";//= Application.StartupPath + @"\cfg\出货记录.xlsx";
if(Form1.companySelect==0)
{
reportExcelPath = Application.StartupPath + @"\cfg\rean\report.xlsx";
}
else
{
reportExcelPath = Application.StartupPath + @"\cfg\benan\report.xlsx";
}
reportExcel = new Excel.Application();
try
{
reportExcel.Visible = true;
reportWorkbook = (Excel._Workbook)reportExcel.Workbooks.Open(reportExcelPath,
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
);
openReportResult = 1;
}
catch (Exception err)
{
openReportResult = 2;
MessageBox.Show(Convert.ToString(err));
}
}