/// <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' 카테고리의 다른 글
c#으로 작성된 코드를 네이티브 빌드 해보자 (2) | 2024.06.19 |
---|---|
datatable row 순서 변경 Winform 그리드의 상하 이동시키는 Row 이동 하기 (1) | 2024.05.24 |
scoped_dir 폴더 삭제 프로그램 (33) | 2024.05.10 |
소켓 상태, 소켓 연결, 소켓 상태 체크 , 소켓 감시 체크 프로그램 (0) | 2014.07.16 |
CopyAssist 0.1 - 클립보드를 커스텀하게 변환하는 유틸, 복사 유틸 (1) | 2012.02.20 |