ExcelConvert
public static class ExcelConvert
{
#region - 由数字转换为Excel中的列字母 - public static int ToIndex(string columnName)
{
if (!Regex.IsMatch(columnName.ToUpper(), @"[A-Z]+")) { throw new Exception("invalid parameter"); }
int index = ;
char[] chars = columnName.ToUpper().ToCharArray();
for (int i = ; i < chars.Length; i++)
{
index += ((int)chars[i] - (int)'A' + ) * (int)Math.Pow(, chars.Length - i - );
}
return index - ;
} public static string ToName(int index)
{
if (index < ) { throw new Exception("invalid parameter"); }
List<string> chars = new List<string>();
do
{
if (chars.Count > ) index--;
chars.Insert(, ((char)(index % + (int)'A')).ToString());
index = (int)((index - index % ) / );
} while (index > );
return String.Join(string.Empty, chars.ToArray());
}
#endregion
}
ExcelConvert的更多相关文章
- 转载: 黄聪:C#中 Excel列字母与数字的转换
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Excel列A、B、C、D----与列序号的转换
public static class ExcelConvert { public static int ToExcelIndex(this string columnName) { if (!Reg ...
- [No0000107]C#中 Excel列字母与数字的转换
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
随机推荐
- 〖Linux〗安装和使用virtualenv,方便多个Python版本中切换
1. 安装pip easy_install pip 2. 安装virtualenvwrapper sudo pip install virtualenvwrapper 3. 使用virtualenv ...
- 【Linux】find命令
用途 find命令用于在指定目录下查找文件. 全称 无 参数 -name :后跟需要匹配的文件名模式,需要使用引号引起来 下面是一些简单的示例查找:(~表示$HOME目录) 1.查找当前$HOME下' ...
- 使用badblocks检测坏块
命令格式 badblocks [-svw][-b <区块大小>][-o <输出文件>][磁盘装置][磁盘区块数 [启始区块]] 典型的命令如下 # 写测试, 数据安全 -c - ...
- OpenWRT/LEDE长期运行记录截图
哈哈, 发图留念. 待会儿要把它换到别处去了. 在Newifi Y1上稳定运行了95天的自编译OpenWrt, Y1这个型号的特点是5G信号强度比2.4G的强 Update 2017-11-27 在W ...
- samba config
[global] netbios name = HARDY #设置服务器的netbios名字 server string = my server #对samba服务器的描述 workgroup ...
- oracle安装后tnsnames.ora内容
# tnsnames.ora Network Configuration File: D:\Develop\oracle11g\product\11.2.0\dbhome_1\network\admi ...
- PHP Fatal error: Call to undefined function mysql_connect() 错误解释
我使用的是5.6.11版本的php 刚开始以为编译参数加了--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd,就可以不能安装mysql了. 但是使用了mysq ...
- 上海租房找房建议及条件,上海IT行业开发常见公司的位置地点
上海租房,找房条件 以2号地铁线为中心,优先选择(回家方便,重点!),交通设施较集中地铁:2,3,4 区:普陀区,静安区,长宁区,闸北区,浦东新区,闵行区,徐汇区 路:镇坪路,威宁路,娄山关路,中山公 ...
- 树莓派进阶之路 (025) - ubuntu下使用VNC连接树莓派raspberry(转)
转载:http://www.embbnux.com/2014/03/24/on_ubuntu_use_vnc_connect_raspberry/ 参考: http://elinux.org/R ...
- [Android实例] Android之断点续传下载
在我们做开发的时候经常遇到的就是下载了,现在下载的方法有很多很多,那么怎么做到断点续传下载呢!很多人都头疼这个问题,如果我们没有很好的逻辑真不是很容易解决啊.我参考了一下前辈们的资料了整理了一个项目, ...