• 通过访问注册表,表判断系统是否装excel


            #region 判断系统是否装excel
            /// <summary>
            /// 判断系统是否装excel
            /// </summary>
            /// <returns></returns>
            public static bool IsInstallExcel()
            {
                RegistryKey machineKey = Registry.LocalMachine;
                if (IsInstallExcelByVersion("12.0", machineKey))
                {
                    return true;
                }
                if (IsInstallExcelByVersion("11.0", machineKey))
                {
                    return true;
                }
                return false;
            }
            #endregion

            #region 判断系统是否装某版本的excel
            /// <summary>
            /// 判断系统是否装某版本的excel
            /// </summary>
            /// <param name="strVersion">版本号</param>
            /// <param name="machineKey"></param>
            /// <returns></returns>
            private static bool IsInstallExcelByVersion(string strVersion, RegistryKey machineKey)
            {
                try
                {
                    RegistryKey installKey = machineKey.OpenSubKey("Software").OpenSubKey("Microsoft").OpenSubKey("Office").OpenSubKey(strVersion).OpenSubKey("Excel").OpenSubKey("InstallRoot");
                    if (installKey == null)
                    {
                        return false;
                    }
                    return true;
                }
                catch
                {
                    return false;
                }
            }
            #endregion

  • 相关阅读:
    MySQL时间字段如何自动获取插入时间
    web.xml启动顺序
    如何开启Redis
    Windows下启动Redis命令
    Tomcat无法启动:Server Tomcat v8.5 Server at localhost failed to start
    浏览器报:Uncaught SyntaxError: Unexpected end of input 解决办法
    链表查询,双表及多表
    Spring Boot项目中开启事务支持及使用
    Java Servlet基础整理(一)
    Linux下部署Tomcat
  • 原文地址:https://www.cnblogs.com/tangtang615/p/1402908.html
Copyright © 2020-2023  润新知