Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2014-04-03代码游戏 #29

Open
jcm872000 opened this issue Apr 3, 2014 · 1 comment
Open

2014-04-03代码游戏 #29

jcm872000 opened this issue Apr 3, 2014 · 1 comment

Comments

@jcm872000
Copy link

在工作中我们必然会经常与各类文件打交道,今天请大家试试用node.js来进行文件处理。请听题:
1、必须使用node.js完成
2、读取指定文件中的内容并将其输出(文件请见邮件,一同发出)
3、输出模式如下:
文件内容:
计划ID HR分类
437238 技术
436751 技术
……
输出结果:
计划ID HR分类
437238 技术
436751 技术
……
4、在原数据的基础上再增加以下行,生成新文件
EmployeeID Yourname

@jcm872000
Copy link
Author

var fs = require('fs');
var xlsx = require('node-xlsx');
// read
var obj = xlsx.parse('innerPlan.xlsx');
var dataObj = obj.worksheets[0].data;
var length=dataObj.length
for(var i=0;i<dataObj.length;i++){
var str='';
for(var j=0;j<dataObj[i].length;j++){
str += dataObj[i][j].value;
str += ' ';
}
console.log(str);
}
var myString=[{"value":"HXXXX","formatCode":"General"},{"value":"XXXX","formatCode":"General"}];
dataObj.push(myString);
obj.worksheets[0].maxRow+=1;
var buffer = xlsx.build(obj);
fs.writeFileSync("myFile.xlsx", buffer, "binary");

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant