var monthMap = {
"1": "H", "2": "I", "3": "J", "4": "K",
"5": "L", "6": "M", "7": "N", "8": "O",
"9": "P", "10": "Q", "11": "R", "12": "S"
};//表示月份对应的列号
var titleRowCount = 4; //标题所占用行数
//绑定行合计
$.Enumerable.From(rowPlan.ProductPlanDetails).ForEach(function (row, index) {
var nonRow = (titleRowCount + index); //当前行索引,从0计算
var excelNonRow = (nonRow + 1);//excel当前行索引,从1计算
sheet.setFormula(nonRow, 0, "=(H" + excelNonRow + "+I" + excelNonRow + ")/60");
if (row.CategoryName == "Iphone6")
{
sheet.setFormula(nonRow, 5, "=A" + excelNonRow + "-C" + excelNonRow);
var mouthDays = utils.GetDays(2016, 3);
var formula = String.format("=F{0}*{1}*0.994", excelNonRow, mouthDays);
sheet.setFormula(nonRow, 9, formula);
for (var i = titleRowCount, j = 10; i <= 12; i++, j++) {
//i:为当前月|monthMap[i - 1]:根据月份取出对应的EXCEL列头|preDays:上月天数|mouthDays:本月天数|nonRow:当前行
var preDays = utils.GetDays(2016, (i - 1));
var days = utils.GetDays(2016, i);
formula = String.format("={0}{1}/{2}*{3}*0.994", monthMap[i - 1], excelNonRow, preDays, days);
sheet.setFormula(nonRow, j, formula);
}
sheet.setFormula(nonRow, 20, "=(J" + excelNonRow + "-S" + excelNonRow + ")/J" + excelNonRow);
sheet.setFormula(nonRow, 21, "=C" + excelNonRow + "*305");
}
sheet.setFormula(nonRow, 19, "=SUM(H" + excelNonRow + ":S" + excelNonRow + ")");
});
|