标签:
项目需要,今天写了个前端导出Excel的方法
/**
* 通过索引获取对应的Excel列名
* 索引从0开始,返回形如 A,B,C,...,Z,AA,AB,...,AZ,BA,...,ZZ,AAA,AAB,......
*/
var getExcelColumnName = function (index) {
var colName = ‘‘;
if (index >= 26)
{
colName = getExcelColumnName(index / 26 - 1);
colName += String.fromCharCode(65 + index % 26);
} else {
colName += String.fromCharCode(65 + index);
}
return colName;
};
代码段:通过索引获取对应的Excel列名; 索引从0开始,返回形如 A,B,C,...,Z,AA,AB,...,AZ,BA,...,ZZ,AAA,AAB,......
标签:
原文地址:http://www.cnblogs.com/petunsecn/p/5899221.html