[TOC] > Mon May 17 2021 23:19:07 GMT+0800 (GMT+08:00) ```js /** * 插入日历 * @param {string} insertOption 要插入日历的起始单元格 * @param {number} fullYearNum 年份 * @param {number} monthIdexNum 月份顺序 */ function _m_insertCalendar(insertOption,fullYearNum, monthIdexNum) { let fullYear = arguments[1]|| new Date().getFullYear() let monthIdex = arguments[2]||new Date().getMonth() let weekDayRow = Range(Range(insertOption), Range(insertOption).Offset(0, 6)) let p = ["日", "一", "二", "三", "四", "五", "六"]; for (let i = 1; i <= weekDayRow.Count; i++) { weekDayRow.Item(i).Value2 = `星期${p[i - 1]}` } let ares = Range(Range(insertOption).Offset(1, 0), Range(insertOption).Offset(4, 6)) let z = new Date(...[fullYear, monthIdex, 1]).getDay() for (let i = 1; ; i++) { let itemDate = new Date(...[fullYear, monthIdex, i]) if (itemDate.getMonth() > monthIdex) { return } ares.Item(z + i).Value2 = i; } } function _m_doit() { _m_insertCalendar("K5",2021, 5) // 不是人类理解的月份,你可以进行改造,比如:"五月" 则是 4 } ```