168. Excel Sheet Column Title

Source: Internet
Author: User

    /** 168.     Excel Sheet Column Title * 12.12 by Mingyang * Be sure to note the case of Z for 0!!! */     Public StaticString Converttotitle (intN) {if(n <= 0)            return" "; StringBuffer SB=NewStringBuffer ();  while(N > 0) {            intTEMP = n 26; N= N/26; if(temp = = 0) {Sb.insert (0, ' Z '); N--; Continue; } Sb.insert (0, Character.tochars (64 +temp)); }        returnsb.tostring (); }    //The online short wording, here avoids the discussion of 26, because after 26-1=25, you can directly add     Public StaticString ConvertToTitle1 (intN) {StringBuilder sb=NewStringBuilder ();  while(N > 0) {n--; CharCH = (Char) (n% + ' A '); N/= 26; Sb.insert (0, CH); }        returnsb.tostring (); }    /** So about the problem of the system, we convert from 26 to 10 in the system and how to solve it? Please look at this question to try to counter the problem.*/     Public intTitletonumber (String s) {intresult = 0;  for(inti = 0; I < s.length (); i++) {result= result * + 1 + s.charat (i)-' A '; }        returnresult; }

168. Excel Sheet Column Title

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.