diff --git a/document/横山台こども園様_帳票テンプレート(Excel作成分)/幼児日誌.xlsx b/document/横山台こども園様_帳票テンプレート(Excel作成分)/幼児日誌.xlsx index 92a3740..a5ff1c9 100644 Binary files a/document/横山台こども園様_帳票テンプレート(Excel作成分)/幼児日誌.xlsx and b/document/横山台こども園様_帳票テンプレート(Excel作成分)/幼児日誌.xlsx differ diff --git a/src/2歳以上日誌/main.js b/src/2歳以上日誌/main.js index 572c21a..b8e2b74 100644 --- a/src/2歳以上日誌/main.js +++ b/src/2歳以上日誌/main.js @@ -41,7 +41,7 @@ await createExcelAndDownload({ api, excelName, - exportName: getExcelName(excelName, getFormatDateString(date).replaceAll('-','')), + exportName: getExcelName(excelName, getFormatDateString(date).replaceAll('-', '')), bizLogic: writeExcel(record, getJapaneseEraDate(date)), }); loading(false); @@ -49,47 +49,50 @@ function writeExcel(record, { era, year, month, day }) { return async (api, worksheet) => { - const baseCells = findCellsInfo(worksheet, ['園長', '行 事', '主な活動', 'クラス名']); + fillPage1(baseCells, worksheet); + fillPage2(baseCells, worksheet); + } - // page1 + function fillPage1(baseCells, worksheet) { const signLabels = ['園長', '主幹', '指導', '担任']; const signRow = baseCells['園長'][0].row + 1; for (let i = 0; i < signLabels.length; i++) { worksheet.getCell(signRow, baseCells['園長'][0].col + i).value = (record[signLabels[i]]?.value || ''); } - worksheet.getCell(1, 1).value = `${era} ${year}年 ${month}月 ${day}日 ${record['曜日'].value}日 天候(${record['天気']?.value || '--'})` + worksheet.getCell(1, 1).value = `${era} ${year}年 ${month}月 ${day}日 ${record['曜日'].value}日 天候(${record['天気']?.value || '     '})`; - updateCell(worksheet, { base: baseCells['行 事'][0], right: 1 }, record['行事'].value) + updateCell(worksheet, { base: baseCells['行 事'][0], right: 1 }, record['行事'].value); const headerRow = baseCells['主な活動'][0].row; const cols = getLabelColsMapping(worksheet, headerRow, ['活動', '子どもの様子', '反省評価']); const row = headerRow + 1; - const inputMergedData = getMergedInfo(worksheet, {row, col: baseCells['主な活動'][0].col }) + const inputMergedData = getMergedInfo(worksheet, { row, col: baseCells['主な活動'][0].col }); const inputMergedRowCnt = inputMergedData.bottom - inputMergedData.top + 1; for (let i = 0; i < 4; i++) { cols.forEach(col => { - updateCell(worksheet, { base: { row: row + i * inputMergedRowCnt, col: col.index } }, record[col.field + (i + 1)]?.value) + updateCell(worksheet, { base: { row: row + i * inputMergedRowCnt, col: col.index } }, record[col.field + (i + 1)]?.value); }); } - - const baseForDetail = baseCells['クラス名'][0]; - worksheet.getRow(baseForDetail.row - 2).addPageBreak(); - // page2 - const subRecords = record['園児別テーブル'].value + worksheet.getRow(baseCells['クラス名'][0].row - 2).addPageBreak(); + } + + function fillPage2(baseCells, worksheet) { + const baseForDetail = baseCells['クラス名'][0]; + const records = record['園児別テーブル'].value.map((e) => e.value); const pageSize = 10; - const totalPages = Math.ceil(subRecords.length / pageSize); - const inputMergedObjectForDetail = getMergedInfo(worksheet, {row: baseForDetail.row + 1, col: baseForDetail.col }) - const inputMergedRowCntForDetail = inputMergedObjectForDetail.bottom - inputMergedObjectForDetail.top + 1; + const totalPages = Math.ceil(records.length / pageSize); + const inputMergedObject = getMergedInfo(worksheet, { row: baseForDetail.row + 1, col: baseForDetail.col }); + const inputMergedRowCnt = inputMergedObject.bottom - inputMergedObject.top + 1; // make new copy if (totalPages > 1) { const lastPage = 1; const copyPageRowStart = baseForDetail.row - 1; - const copyPageRowEnd = baseForDetail.row + (pageSize * inputMergedRowCntForDetail); + const copyPageRowEnd = baseForDetail.row + (pageSize * inputMergedRowCnt); createCopyFromTemplate(worksheet, { startPage: lastPage + 1, @@ -103,12 +106,33 @@ col: last.col, row: last.row + rowCount }); - }) + }); } - }) + }); } - debugger; + const cols = getLabelColsMapping(worksheet, baseForDetail.row, ['クラス名', '名前', '子どもの様子', '反省評価_園児別テーブル']); + for (let i = 0; i < totalPages; i++) { + const childLabelCell = baseCells['クラス名'][i]; + let currentRow = childLabelCell.row + 1; + + for (let j = 0; j < pageSize; j++) { + const index = i * pageSize + j; + const record = records[index]; + if (!record) { + break; + } + const row = worksheet.getRow(currentRow); + cols.forEach(col => { + row.getCell(col.index).value = record[col.field].value; + row.getCell(col.index).alignment = { wrapText: true };; + }); + currentRow++; + } + + worksheet.getRow(childLabelCell.row + pageSize * inputMergedRowCnt).addPageBreak(); + } } + } })(); \ No newline at end of file