excel - JXL Get Cell Address -
i using java jxl api v2.6.16 generate excel spread sheet. above title puts it, how address of cell or more writable cell writing if have cell's column , row? or have write algorithm can generate that?
thanks in advance.
you can use code. hope help. can use in way:
celladdress(cell.getrow() + 1, cell.getcolumn())
if cell defined cell cell = somecell;
private string celladdress(integer rownumber, integer colnumber){ return "$"+columnname(colnumber)+"$"+rownumber; } private string columname(integer colnumber) { base columns = new base(colnumber,26); columns.transform(); return columns.getresult(); } class base { string[] colnames = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(","); string equalto; int position; int number; int base; int[] digits; int[] auxiliar; public base(int n, int b) { position = 0; equalto = ""; base = b; number = n; digits = new int[1]; } public void transform() { if (number < base) { digits[position] = number; size(); } else { digits[position] = number % base; size(); position++; number = number / base; transform(); } } public string getresult() { (int j = digits.length - 2; j >= 0; j--) { equalto += colnames[j>0?digits[j]-1:digits[j]]; } return equalto; } private void size() { auxiliar = digits; digits = new int[auxiliar.length + 1]; system.arraycopy(auxiliar, 0, digits, 0, auxiliar.length); } }
Comments
Post a Comment