java编程实现根据EXCEL列名求其索引的方法
作者:jdkleo 发布时间:2022-04-24 03:08:03
标签:java,EXCEL
本文实例讲述了java编程实现根据EXCEL列名求其索引的方法。分享给大家供大家参考,具体如下:
原理:
[a1-z26]*26^n-1 + [a1-z26]*26^n-2 + ... + [a1-z26]*26^0
具体代码如下:
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
import java.util.HashMap;
import java.util.Map;
/**
*
* @author jdkleo
*/
public class ExcelUtil {
public static int getCellNum(String cellStr) {
char[] cellStrArray = cellStr.toUpperCase().toCharArray();
int len = cellStrArray.length;
int n = 0;
for(int i=0;i<len;i++){
n += (((int)cellStrArray[i])-65+1)*Math.pow(26, len-i-1);
}
return n-1;
}
public static void main(String[] args) {
System.out.print(getCellNum("aaa"));
}
}
希望本文所述对大家java程序设计有所帮助。
0
投稿
猜你喜欢
- 先给最终效果图:当我们在最下边的gallery中切换图片时,上面的大图片会自动切换,切换时有动画效果哦,很简单的一个程序,有待完善更多的功能
- 本文实例讲述了C#中DataGridView常用操作。分享给大家供大家参考。具体如下:public void Binder1(){ Data
- 本文介绍了java web每天定时执行任务,分享给大家,具体如下:第一步:package com.eh.util;import java.u
- 1 前言到目前为止Java仍然是使用最多的编程语言,随着Java以及Java社区的不断壮大,Java也早已不再是简简单单的一门计算机语言了,
- 为了保持类型的安全性,默认情况下 C# 是不支持指针的,但是如果使用 unsafe 关键字来修饰类或类中的成员,这样的类或类中成员就会被视为
- 前言在学习android中图形图像处理技术这部分内容时,对绘制圆弧函数canvas.drawArc()的用法、参数含义及画图原理很是不理解,
- 1、每帧检查定义一个时间变量 timer,每帧将此时间减去帧间隔时间 Time.deltaTime,如果小于或者等于零,说明定时器到了,执行
- 经常会遇到这样的情况,我们在响应客户端请求的数据的时候需要对数据进行处理,比如数据库中的数据是int型,它可能表示某个枚举,或者其它的逻辑意
- 在开发时,手机先要ROOT,然后在通过代码改变权限。<span style="color:#330033;">
- 碰到一个项目,需要对指定的网页进行截图保存,晕死! 需求永远都是怪异的..... 解决是关键~ 遂写了以下代码,快准狠!(因为赶时间!) 可
- break和continue的说明break 循环结构,一旦执行,就结束(或跳出)当前循环结构,此关键字的后面,不能
- 在程序中封装了一个List集合对象,然后需要把该集合中的实体插入到数据库中,由于项目使用了Spring+MyBatis的配置,所以打算使用M
- 目录前言概念什么是循环依赖?报错信息通俗版理解两人对峙必须有一人妥协Spring版理解实例化和初始化什么区别? * 缓存创建过程(简易版)创建
- 开发中经常需要将某个文件向另一个应用程序传递,如图片上传到另一个应用程序、文件在不同存储路径之间的复制粘贴等都需要共享文件,可以这样理解接收
- 本文实例为大家分享了android密码输入框效果展示的具体代码,供大家参考,具体内容如下老规矩,先看效果;这是现在商城类app中很常见的支付
- 一、时间的单位转换1秒=1000毫秒(ms) 1毫秒=1/1,000秒(s)1秒=1,000,000 微秒(μs)&nb
- 一、常用的单位:相对单位主要有:px、sp、dp绝对单位主要有:pt、in、mm二、单位应用总结:一般用相对单位,而不是绝对单位1、字体的大
- 本篇我们讲解下使用spring创建bean的几种方式,创建bean,也可以叫组件注册,就是把单例bean放到spring容器中。我们定义如下
- future机制是在通过线程去执行某个任务的时候,如果比较耗时,我们可以通过futureTask机制,异步返回,继续去执行其他的任务,在需要
- 前言使用Redis来实现Session共享,其实网上已经有很多例子了,这是确保在集群部署中最典型的redis使用场景。在SpringBoot