当我想通过 SWT OleClient 显示 EXCEL 文件时,出现以下错误:
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
File openFile = new File("D:\\eDefterKutuphanesi\\eDefter\\excel.xlsx");
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleClientSite site2 = new OleClientSite(frame,SWT.NONE,"D:\\test.xlsx");
错误消息:
Exception in thread "main" org.eclipse.swt.SWTException: Class ID not found in registry
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:317)
at org.eclipse.swt.ole.win32.OLE.error(OLE.java:283)
at org.eclipse.swt.ole.win32.OleClientSite.<init>(OleClientSite.java:226)
at infina.accounting.reports.views.ExcelDonusturView.main(ExcelDonusturView.java:438)
最佳答案
试试这个:
final Shell shell = new Shell(display);
shell.setLayout(new FillLayout());
OleFrame frame = new OleFrame(shell, SWT.NONE);
OleClientSite site = new OleClientSite(frame, SWT.NONE, "Excel.Sheet", new File("D:\\test.xlsx"));
您将 "D:\\test.xlsx"
作为第三个参数传递,该参数应该是 progId
,对于 Excel,它是 "Excel.Sheet"
。
另请确保您的计算机上安装了 Microsoft Excel。
在注册表中找不到类 ID
表示缺少所需的应用程序。
关于java - 在注册表中找不到客户端 ID - OLE 打开 XSLX 文档错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40973852/