dhtmlxGantt 라이브러리는 간트 차트의 데이터를 Excel 및 iCal 형식으로 내보내는 기능을 지원합니다. 또한 Excel 파일에서 간트 차트로 데이터를 가져오는 것도 가능합니다.
내보내기 서비스는 무료로 사용할 수 있지만, 결과로 생성된 Excel/iCal 파일에는 GPL 라이선스 하에서 라이브러리 워터마크가 포함됩니다. 라이선스를 구매하면, 활성 지원 기간(모든 PRO 라이선스의 경우 12개월) 동안 내보낸 파일에 워터마크가 표시되지 않습니다.
여러 가지 내보내기 서비스를 컴퓨터에 설치하여 간트 차트를 Excel 또는 iCal로 로컬에서 내보낼 수 있습니다. 이 내보내기 서비스들은 Gantt 패키지에 포함되어 있지 않음을 유의하세요. 자세한 내용은 관련 문서를 참고하여 사용 조건을 확인하세요.
내보내기 서비스에는 처리 시간 및 요청 크기에 대한 제한이 있습니다.
내보내기 과정이 20초를 초과하면, 프로세스가 중단되고 다음과 같은 오류가 표시됩니다:
Error: Timeout trigger 20 seconds
여러 사용자가 동시에 간트 차트를 내보내는 경우, 처리 시간이 평소보다 길어질 수 있습니다. 하지만 각 사용자의 내보내기 요청에 소요된 시간은 별도로 계산됩니다.
주요 API 엔드포인트 https://export.dhtmlx.com/gantt에서는 모든 내보내기 메서드(exportToPDF, exportToPNG, exportToMSProject 등)를 처리합니다. 이 엔드포인트의 최대 요청 크기는 10 MB입니다.
또한 MSProject 및 Primavera P6 내보내기/가져오기 서비스(exportToMSProject / importFromMSProject / exportToPrimaveraP6 / importFromPrimaveraP6)를 위한 전용 API 엔드포인트 https://export.dhtmlx.com/gantt/project도 있습니다. 이 엔드포인트의 최대 요청 크기는 40 MB입니다.
대용량 차트 내보내기가 필요한 경우 독립 실행형 내보내기 모듈 사용을 고려하세요. 이 모듈은 Commercial, Enterprise, 또는 Ultimate 라이선스가 있으면 무료입니다. 그렇지 않은 경우 여기에서 별도 구매할 수 있습니다.
PDF 내보내기 모듈 사용법에 대한 자세한 내용은 다음 가이드에서 확인할 수 있습니다: PDF export module. 이 모듈은 PDF, PNG, Excel, iCal 형식으로 내보내기를 지원합니다.
간트 차트의 데이터를 Excel 파일로 내보내려면 다음 단계를 따르세요:
gantt.plugins({
export_api: true
});
Gantt 8.0 미만 버전에서는 온라인 내보내기 서비스를 활성화하려면 https://export.dhtmlx.com/gantt/api.js 스크립트를 페이지에 추가해야 합니다. 예시:
<script src="codebase/dhtmlxgantt.js"></script>
<script src="https://export.dhtmlx.com/gantt/api.js"></script>
<input value="Export to Excel" type="button" onclick='gantt.exportToExcel()'>
<script> gantt.init("gantt_here");
gantt.parse(demo_tasks);
</script>
Related sample: Export data : MS Project, PrimaveraP6, Excel & iCal
Related sample: Export data: store online
exportToExcel() 메서드는 여러 속성을 가진 선택적 객체를 인자로 받을 수 있습니다:
선택적 속성을 포함하여 내보내기 메서드를 호출하는 예시
gantt.exportToExcel({
name:"document.xlsx",
columns:[
{ id:"text", header:"Title", width:150 },
{ id:"start_date", header:"Start date", width:250, type:"date" }
],
server:"https://myapp.com/myexport/gantt",
callback: function(res){
alert(res.url);
},
visual:true,
cellColors:true,
data:{},
date_format: "dddd d, mmmm yyyy"
});
내보내기 모듈은 start_date 및 end_date 열이 Date 타입이고, duration 열이 number 타입일 것으로 기대합니다.
커스텀 템플릿을 사용할 경우, 반환 값이 기대 타입과 일치하도록 하거나, 열 설정의 name 필드에 다른 속성명을 지정하세요. 예시:
gantt.config.columns = [
...
{name: "start_date", align: "center", width: 100, resize: true,
editor: start_dateEditor},
{name: "end_date", align: "center", width: 100, resize: true,
editor: end_dateEditor},
{name: "duration_formatted", align: "center", width: 40, resize: true,
editor: durationEditor,
template: function(task){ return formatter.format(task.duration_formatted); }
},
...
];
이 작업을 하지 않으면 간트 데이터가 올바르게 내보내지지 않습니다. 관련 예시를 참고하세요.
간트 차트에 표시되는 데이터와 다른 커스텀 데이터셋을 기반으로 내보내려면, exportToExcel 메서드의 파라미터 객체의 data 속성을 사용하세요:
gantt.exportToExcel({
name:"document.xlsx",
data:[
{id:1, text:"Project #1", start_date:"01-04-2020", duration:18},
{id:2, text:"Task #1", start_date:"02-04-2020",duration:8, parent:1},
{id:3, text:"Task #2", start_date:"11-04-2020",duration:8, parent:1}
]
});
data 파라미터는 데이터 객체여야 하며, URL 문자열이 아니어야 합니다.
내보내는 Excel 파일에 작업 색상을 포함하려면 visual 속성을 "base-colors"로 설정하세요:
gantt.exportToExcel({
visual: "base-colors", cellColors: true
})
Related sample: Export colors of tasks
임의의 Excel 열을 Gantt 데이터 모델에 자동 매핑하는 기능은 지원되지 않으므로, 내보내기 서비스는 Excel 문서를 JSON으로 반환되는 행 배열로 변환합니다. 이 데이터를 Gantt 형식으로 변환하는 작업은 개발자가 직접 구현해야 합니다.
Excel 파일을 변환하려면, 다음 정보를 포함하여 내보내기 서비스에 요청을 보내세요:
요청 파라미터:
예시 폼:
<form action="https://export.dhtmlx.com/gantt" method="POST"
enctype="multipart/form-data">
<input type="file" name="file" />
<input type="hidden" name="type" value="excel-parse">
<button type="submit">Get</button>
</form>
또는 클라이언트 측 API를 사용할 수 있습니다:
gantt.importFromExcel({
server:"https://export.dhtmlx.com/gantt",
data: file,
callback: function(project){
console.log(project)
}
});
Related sample: Import Excel file
여기서 file은 Excel(xlsx) 파일을 나타내는 File 객체입니다.
gantt.importFromExcel은 HTML5 File API 지원이 필요합니다.
응답은 객체 배열로 구성된 JSON입니다:
[
{ "Name": "Task Name", "Start": "2018-08-11 10:00", "Duration": 8 },
...
]
상세 내용:
gantt.importFromExcel({
server:"https://export.dhtmlx.com/gantt",
data: file,
sheet:2, // 세 번째 시트 처리
callback: function (rows) {}
});
간트 차트 데이터를 iCal 문자열로 내보내려면 다음 단계를 따르세요:
gantt.plugins({
export_api: true
});
<input value="Export to iCal" type="button" onclick='gantt.exportToICal()'>
<script> gantt.init("gantt_here");
gantt.parse(demo_tasks);
</script>
Related sample: Export data : MS Project, PrimaveraP6, Excel & iCal
Related sample: Export data: store online
exportToICal() 메서드는 다음 속성을 가진 선택적 객체를 인자로 받을 수 있습니다:
선택적 속성을 포함하여 내보내기 메서드를 호출하는 예시
gantt.exportToICal({
server:"https://myapp.com/myexport/gantt"
});
Back to top