PureJS excel export 관련 문의
페이지 정보
작성자 팬더곰 작성일 2023-06-21 09:05 조회 353회 댓글 0건본문
관련링크
안녕하세요.
컬럼 foramt을 'n1,'으로 설정하고 , grid format item에서 특정 row의 셀의 innerHTML을 아래와 같이 변경했습니다.
formatItem: (s, e) => {
if (e.panel == s.cells) {
let r = s.rows[e.row];
let item = s.rows[e.row].dataItem;
let col = s.columns[e.col];
if(item.id == 'RATE') { //row가 rate인 경우 포맷을 별도로 셋팅
e.cell.firstChild.innerHTML = Math.round(Number(item[col.binding])*10)/10 ;
} else {
col.format = 'n1,';
}
}
}
-- 컬럼의 celltemplate
cellTemplate: wijmo.grid.cellmaker.CellMaker.makeLink({
click: (e, ctx) => fn_goDetail(ctx),
cssClass:'cell-link'
})
--엑셀 formatitem
function exportFormatItem(args) {
let p = args.panel, row = args.row, col = args.col, xlsxCell = args.xlsxCell;
if (p.cellType === wijmo.grid.CellType.Cell ) {
if (p.rows[row].dataItem.id == 'RATE') {
let cell = args.getFormattedCell();
xlsxCell.value = cell.textContent.trim ;
console.log( xlsxCell.value);
}
}
}
엑셀 다운로드시 console 로그에는 제대로 나오는데, 엑셀파일에는 컬럼 포맷(n1,)이 적용된 데이터가 다운로드 됩니다.
확인 부탁드립니다.
감사합니다.
댓글목록
등록된 댓글이 없습니다.