zoukankan      html  css  js  c++  java
  • 计算EXCEL列名代号的程序

    //计算结果格式:
            
    //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,
            
    //AA,AB,AC,AD,AE,AF,AG,AH,AI,AJ,AK,AL,AM,AN,AO,AP,AQ,AR,AS,AT,AU,AV,AW,AX,AY,AZ,
            
    //BA,BB,BC,BD,BE,BF,BG,BH,BI,BJ,BK,BL
            private void buttonXP1_Click(object sender, System.EventArgs e)
            
    {
                
    string s="A";
                
    for(int i=0;i<2700;i++)
                
    {
                    
    this.richTextBox1.Text +=s+",";
                    s
    =InreasingData(s);
                     
                }

              MessageBox.Show(s)  ;

            }

            
    private string InreasingData(string strTemp)
            
    {
                
    int i=strTemp.Length ;
                
    char[] ca=new char[i];
                ca
    =strTemp.ToCharArray();  
                
    bool bCarryFlag=true;
                
    int w=i-1;
            
                
    int AddResult=(int)ca[w];
                AddResult
    +=1;

            
                
    while((bCarryFlag)&&(w>=0))
                
    {
                    
                    
    if(AddResult>90)
                    
    {
                        ca[w]
    ='A';    
                        
                        
                        
    if(w>0)
                        AddResult
    =(char)((int)ca[w-1]+1);

                    
                    
                        bCarryFlag
    =true;
                    }

                    
    else
                    
    {
                        ca[w]
    =(char)((int)ca[w] +1);
                        bCarryFlag
    =false;
                    }

                    w
    --;
                        
                }

                strTemp
    ="";
                
    for(int j=0;j<i;j++)
                
    {
                    strTemp
    +=ca[j].ToString(); 
                }

                
    if((w<0)&&(bCarryFlag))
                
    {
                    strTemp
    ="A"+strTemp;
                }

                
                
    return strTemp;
            }
    Private Sub ButtonXP1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonXP1.Click
            
    Dim i As Int16 = 0
            
    Dim s As String = "A"
            
    Me.RichTextBox1.Text &= s & "',"
            
    For i = 0 To 1000
                s 
    = IncreasingData(s)
                
    Me.RichTextBox1.Text &= s & "',"
            
    Next


        
    End Sub


        
    Private Function IncreasingData(ByVal strTemp As StringAs String
            
    Dim i As Integer = strTemp.Length
            
    Dim ca(i) As Char
            ca 
    = strTemp.ToCharArray()
            
    Dim bCarryFlag As Boolean = True
            
    Dim w As Integer = (i - 1)
            
    Dim AddResult As Integer = Microsoft.VisualBasic.AscW(ca(w))
            AddResult 
    += 1
            
    While ((bCarryFlag) And (w >= 0))
                
    If (AddResult > 90Then
                    ca(w) 
    = "A"
                    
    If (w > 0Then
                        AddResult 
    = Microsoft.VisualBasic.AscW(ca(w - 1)) + 1
                        bCarryFlag 
    = True
                    
    End If
                
    Else
                    ca(w) 
    = Microsoft.VisualBasic.ChrW(Microsoft.VisualBasic.AscW(ca(w)) + 1)
                    bCarryFlag 
    = False
                
    End If
                w 
    = w - 1
            
    End While
            strTemp 
    = ""
            
    Dim j As Integer = 0
            
    For j = 0 To i - 1
                strTemp 
    &= ca(j).ToString()
            
    Next
            
    If ((w < 0And (bCarryFlag)) Then
                strTemp 
    = "A" & strTemp
            
    End If
            
    Return strTemp
        
    End Function
  • 相关阅读:
    Nginx在linux环境下(centos7)的安装、负载均衡设置
    ocr识别开源软件tesseract试用记录
    Nginx在windows环境下的安装、负载均衡设置
    一个测试程序迭代的故事05
    一个测试程序迭代的故事04
    一个测试程序迭代的故事03
    一个测试程序迭代的故事02
    一个测试程序迭代的故事01
    Delphi5和Delphi7属性编辑器内存泄漏问题的解决
    使用Calibre自带工具批量转换电子书格式
  • 原文地址:https://www.cnblogs.com/furenjun/p/420833.html
Copyright © 2011-2022 走看看