Front/JS & jQuery

[js][datatables] 엑셀 파일명 특수문자 처리

오선지♬ 2024. 12. 22. 15:30
728x90
반응형

& 이 변환되지 않고 빈문자로 출력되어서,

& 를 특정 문자열로 대체

function sanitizeFileName(fileName) {
    return fileName.replace(/&/g, '_and_');  // &를 '_and_'로 대체
}

$('#example').DataTable({
    dom: 'Bfrtip',
    buttons: [
        {
            extend: 'excelHtml5',
            title: sanitizeFileName('엑셀&파일명_2024')
        }
    ]
});
728x90
반응형