var excel = require('exceljs');
var workbook = new excel.Workbook();
workbook.xlsx.readFile("/tmp/tmpl.xlsx")
    .then(function() {
        var worksheet = workbook.getWorksheet(1);
        worksheet.columns=[
          { header: '年度', key: 'statisticalYear', width: 10 },
          { header: '月份', key: 'statisticalMonth', width: 10 },
          { header: '员工姓名', key: 'employeeName', width: 10 },
          { header: '本月税前薪资', key: 'preTaxSalary', width: 18 },
          { header: '累计税前薪资', key: 'accupreTaxSalary', width: 18 },
          { header: '本月五险一金', key: 'insuranceAndFund', width: 18, outlineLevel: 1 },
          { header: '累计五险一金', key: 'accuinsuranceAndFund', width: 18, outlineLevel: 1 },
          { header: '子女教育', key: 'childrenEducation', width: 10 },
          { header: '继续教育', key: 'continuingEducation', width: 10 },
          { header: '房贷利息', key: 'interestExpense', width: 10 },
          { header: '住房租金', key: 'housingRent', width: 10 },
          { header: '赡养老人', key: 'supportElderly', width: 10 },
          { header: '大病医疗', key: 'illnessMedicalTreatment', width: 10 },
          { header: '专项扣除合计', key: 'specialDeduction', width: 10 },
          { header: '累计已扣专项', key: 'accuSpecialDeduction', width: 18, outlineLevel: 1 },
          { header: '累计已纳个税', key: 'accuPersonalIncomeTax', width: 18 },
          { header: '累计免征额', key: 'accuExemptionAmount', width: 10 },
          { header: '适用税率', key: 'supportElderly', width: 10 },
          { header: '速算扣除', key: 'deductionNumber', width: 10 },
          { header: '本月应纳个税', key: 'personalIncomeTax', width: 18 },
          { header: '本月税后薪资', key: 'postTaxSalary', width: 18, outlineLevel: 1 }
        ];
        worksheet.addRow({employeeName:"hello"});
        workbook.xlsx.writeFile("/tmp/n.xlsx").then(async function(d) {
                  //console.log(d);
                  workbook.close();
            }).catch(function(e){

            });
    });
// var system=require("./app/base/system");
// ossClient=system.getObject("util.ossClient");
// async function writexls(wb,sharecode){
//   var that=this;
//   var fname="zc_"+sharecode+".xlsx";
//   var filepath="/tmp/"+fname;
//   var promise=new Promise((resv,rej)=>{
//     wb.xlsx.writeFile(filepath).then(async function(d) {
//             var rtn=await ossClient.upfile(fname,filepath);
//             resv(rtn);
//     }).catch(function(e){
//       rej(e);
//     });
//   });
//   return promise;
// }
// var workbook = new excel.Workbook();
// workbook.properties.date1904 = true;
// var sheet = workbook.addWorksheet('201901年个人所得税汇总表');
// sheet.columns = [
//     { header: '员工姓名', key: 'employeeName', width: 10 },
//     { header: '税前薪资', key: 'preTaxSalary', width: 10 },
//     { header: '五险一金', key: 'insuranceAndFund', width: 10, outlineLevel: 1 },
//     { header: '专项扣除-子女教育', key: 'childrenEducation', width: 18 },
//     { header: '专项扣除-继续教育', key: 'continuingEducation', width: 18 },
//     { header: '专项扣除-房贷利息', key: 'interestExpense', width: 18 },
//     { header: '专项扣除-住房租金', key: 'housingRent', width: 18 },
//     { header: '专项扣除-赡养老人', key: 'supportElderly', width: 18 },
//     { header: '专项扣除-大病医疗', key: 'illnessMedicalTreatment', width: 18 },
//     { header: '适用税率', key: 'supportElderly', width: 10 },
//     { header: '应纳个税', key: 'personalIncomeTax', width: 10 },
//     { header: '税后薪资', key: 'postTaxSalary', width: 10, outlineLevel: 1 }
// ];
// //sheet.addRow({id: 1, name: 'John Doe', dob: new Date(1970,1,1)});
// (async()=>{
//   var x=await writexls(workbook,"testcode");
//   console.log(x);
// })()

// var x=0b11111100000000001111110000000000;
// var m=350065;
// var c=m ^ x;
// console.log(c);
// console.log((c^x)/100);

// var crypto=require('crypto');
//
// var cipher = crypto.createCipher('aes-256-cbc','testkey');
// var text = "35000";
// var crypted = cipher.update(text,'utf8');
// crypted += cipher.final('hex');
// console.log('加密后的文本：'+crypted);
//
// var decipher = crypto.createDecipher('aes-256-cbc','testkey');
// var dec = decipher.update(crypted,'hex','utf8');
// dec += decipher.final('utf8');
// console.log('解密的文本：'+dec);
