wangting
2024-12-26 fa261e8c1220b31af54e8167e4de9c3320b1af27
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.vci.client.common;
 
import com.vci.client.framework.delegate.SystemCfgClientDelegate;
import com.vci.client.ui.exception.VCIException;
 
/**
 * 配置信息统一读取类
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2012</p>
 * <p>Company: VCI</p>
 * @author xchao
 * @time 2013-3-20
 * @version 1.0
 */
public class ConfigUtils extends BaseConfitUtils {
 
    
    /**
     * 根据KEY,从远程服务器端conf.properties中配置值
     * <p>Description: 根据未找到相应的值,则返回KEY</p>
     * 
     * @author xchao
     * @time 2013-3-20
     * @param key
     * @return
     */
    public static String getConfigValue(String key){
        String res = key;
        try{
            res = new SystemCfgClientDelegate().getConfigValue(key);
        }catch(VCIException e){
            
        }
        return res;
    }
    
    /**
     * 在指定文件中读取配置信息
     * 如果文件名称是一个相对路径,将先在工作目录下查找文件,
     * 如果没有到包中查找文件,当文件或key不存在时返回""
     * @param propertyPath 文件路径名称
     * @param key
     * @return
     */
//    public static String getConfigValue(String propertyPath, String key){
//        String res = "";
//        try{
//            res = new SystemCfgClientDelegate().getConfigValue(propertyPath, key);
//        }catch(VCIException e){
//            e.printStackTrace();
//        }
//        return res;
//    }    
    
    /**
     * 将导入文件Excel第几列数字转换成字母  
     * 仅支持1--701,转换为 A--Z,AA--ZY
     * 
     * @param input 传递过来的第几列数字,如 1,2,...,701;
     * @return 字符A, B, C,..., Z, AA, AB, ...,ZY
     */
    public static String numToLetter(int input) {
        String res = "";
        int n = input / 26;
        int m = input / 27;
        int M = input % 26;
        if (n <= 1 && m == 0){
            res += ""+(char) (input +64); 
        }else if ( n >= 1 && n <= 26 && M != 0){
            res += ""+(char) (n + 64)  + ""+(char) (input - n*26 +64);
        }else if(n >= 1 && n <= 26 && M == 0){
            res += ""+(char) (n-1 + 64)  + ""+(char) (input - (n-1)*26 +64);
        }
        return res;
    }
}