-
c# 엑셀 버전 찾기Development Programs 2022. 11. 18. 13:46반응형
/// <summary>
/// 엑셀 버전찾기
/// </summary>
/// <returns></returns>
/// <remarks>
/// 8 = 97
/// 9 = 2000
/// 10 = 2002
/// 11 = 2003
/// 12 = 2007
/// 14 = 2010
/// 15 = 2013
/// 16 = 2016
/// 18 = 2019
/// 18 = offcie365
/// </remarks>
public static int GetExcelVersion()
{
try
{
RegistryKey subKey = Registry.ClassesRoot.OpenSubKey(@"Excel.Application\CurVer");
if (subKey != null)
{
try
{
string[] temp = ((string)(subKey.GetValue(""))).Split('.');
int excelVersion;
if (int.TryParse(temp[temp.Length - 1], out excelVersion))
{
return excelVersion;
}
return 0;
}
catch
{
return 0;
}
}
return 0;
}
catch (System.Exception ex)
{
return 0;
}
}t사용예
if (HelperUtil.GetExcelVersion() <= 12)
{
connectionString = string.Format(Excel03ConString, filePath, header);
}
else
{
connectionString = string.Format(Excel07ConString, filePath, header);
}반응형'Development Programs' 카테고리의 다른 글
소켓 상태, 소켓 연결, 소켓 상태 체크 , 소켓 감시 체크 프로그램 (0) 2014.07.16 CopyAssist 0.1 - 클립보드를 커스텀하게 변환하는 유틸, 복사 유틸 (1) 2012.02.20