본문으로 건너뛰기

Excel용 내보내기 및 가져오기

dhtmlxGantt 라이브러리는 Gantt 차트의 데이터를 Excel 형식으로 내보내는 기능을 제공합니다. 또한 Excel 파일로부터 Gantt에 데이터를 가져올 수도 있습니다. iCal 형식으로 데이터를 내보내려면 iCal로 내보내기를 참조하십시오.

노트

온라인 내보내기 서비스는 무료입니다. 라이선스 조건은 라이선스 및 워터마크를 참조하십시오.

다양한 내보내기 서비스가 있습니다. 이들을 컴퓨터에 설치하고 로컬에서 Gantt 차트를 Excel로 내보낼 수 있습니다. 내보내기 서비스는 Gantt 패키지에 포함되어 있지 않으므로, 각 서비스의 이용 조건을 알아보려면 해당 문서(링크의 기사)를 읽어보시기 바랍니다.

Online export service restrictions​

노트

온라인 내보내기 서비스에는 시간 제한과 요청 크기 제한이 있습니다. 온라인 내보내기 서비스 제한을 참조하십시오.

Using export modules​

대용량 차트를 내보내거나, 온라인 내보내기 서비스의 제한 없이 내보내거나, 데이터를 사내 네트워크에 보관하려면 자체 서버에 내보내기 모듈을 설치하십시오. PDF, PNG, Excel 및 iCal용 내보내기 모듈 사용에 대한 자세한 내용을 확인하십시오.

Excel로 내보내기​

Gantt 차트의 데이터를 Excel 문서로 내보내려면 다음과 같이 수행합니다:

  • 내보내기/가져오기 기능을 사용하려면 plugins 메서드를 통해 export_api 플러그인을 활성화합니다:
gantt.plugins({
export_api: true
});

온라인 내보내기 서비스나 로컬 내보내기 모듈 중 하나를 사용할 수 있습니다.

노트

Gantt 버전이 8.0 미만인 경우 Django 페이지에 내보내기 기능을 활성화하기 위해 https://export.dhtmlx.com/gantt/api.js를 포함해야 합니다. 예:

<script src="codebase/dhtmlxgantt.js"></script>
<script src="https://export.dhtmlx.com/gantt/api.js"></script>
  • Gantt 차트의 데이터를 Excel로 내보내기 위해서는 exportToExcel 메서드를 호출합니다:
<input value="Export to Excel" type="button" onclick='gantt.exportToExcel()'/>

<script>
gantt.init("gantt_here");
gantt.parse(demo_tasks);
</script>

관련 샘플: Export data : MS Project, PrimaveraP6, Excel & iCal

관련 샘플: Export data: store online

Parameters of the export method​

exportToExcel() 메서드는 여러 속성을 가진 객체를 매개변수로 받으며(모두 선택적):

  • name - (string) 출력 파일의 이름을 확장자 '.xlsx'와 함께 설정합니다.
  • columns - (array) 출력 Excel 시트의 열 구성을 설정합니다. 열 객체의 속성은 다음과 같습니다:
    • 'id' - (string,number) 열에 매핑될 이벤트의 속성
    • 'header' - (string) 열 머리글
    • 'width' - (number) 픽셀 단위의 열 너비
    • 'type' - (string) 열 타입
  • server - (string) 요청의 API 엔드포인트를 설정합니다. 로컬 설치의 내보내기 서비스와 함께 사용할 수 있습니다. 기본값은 https://export.dhtmlx.com/gantt
  • raw - (boolean) Gantt 데이터를 내보내는 방식을 정의합니다. 기본값은 false입니다. 자세한 내용은 Exporting filtered tasks and hidden columns 섹션을 참조하십시오
  • callback - (function) 생성된 XLSX 파일의 다운로드 URL을 받으려면 callback 속성을 사용할 수 있습니다. url 속성이 있는 JSON 객체를 수신합니다
  • visual - (boolean) 내보낸 Excel 문서에 타임라인 차트를 추가합니다. 기본값은 false
  • cellColors - (boolean) 이 값을 true로 설정하면, 내보낸 문서의 셀에 timeline_cell_class 템플릿에 정의된 색상이 적용되며, color 과 background-color 속성이 내보내집니다
  • data - (object) 출력 Gantt 차트에 표시될 사용자 정의 데이터 소스를 설정합니다
  • date_format - (string) 내보낸 Excel 문서에 날짜를 표시할 형식을 설정합니다. 사용 가능한 형식 코드의 전체 목록은 여기를 참조하십시오.
선택적 속성으로 export 메서드 호출
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: (res) => {
alert(res.url);
},
visual: true,
cellColors: true,
data: { },
date_format: "dddd d, mmmm yyyy"
});

Default date parameters​

Export 모듈은 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: (task) => {
return formatter.format(task.duration_formatted);
}
},
...
];

그렇지 않으면 Gantt 데이터가 내보내지지 않습니다. 관련 예제 확인.

Setting a custom data source to export​

Gantt 차트를 커스텀 데이터 세트로 내보내려면(초기 Gantt 차트에 표시된 데이터가 아닌 경우) exportToExcel 메서드 매개변수의 data 속성을 사용합니다:

gantt.exportToExcel({   
name: "document.xlsx",
data: [
{ id: 1, text: "Project #1", start_date: "01-04-2026", duration: 18},
{ id: 2, text: "Task #1", start_date: "02-04-2026", duration: 8, parent: 1},
{ id: 3, text: "Task #2", start_date: "11-04-2026", duration: 8, parent: 1}
]
});
노트

주의: data 매개변수의 값으로 URL을 지정할 수 없으며, 데이터 객체만 사용할 수 있습니다.

Adding colors of tasks to export​

작업의 색상을 내보낸 Excel 파일에 추가하려면 visual 속성을 "base-colors" 로 설정하고, cellColors를 true로 설정합니다:

gantt.exportToExcel({
visual: "base-colors",
cellColors: true
})

관련 샘플: Export colors of tasks

Exporting filtered tasks and hidden columns​

기본적으로 exportToExcel() 메서드는 onBeforeTaskDisplay 이벤트를 통해 적용된 필터링이나 hide:true 설정으로 숨겨진 열과 관계없이 Gantt 차트의 모든 작업과 열을 내보냅니다.

onBeforeTaskDisplay를 통해 필터링된 작업을 내보내기에서 제외하려면 raw 속성을 true로 설정합니다:

gantt.attachEvent("onBeforeTaskDisplay", function(id, task){
// hide tasks that don't match the search value
return task.text.toLowerCase().indexOf(filterValue.toLowerCase()) > -1;
});

gantt.exportToExcel({
raw: true
});

관련 샘플: Gantt. Export filtered data to PDF, Excel, and MSProject files

마찬가지로 hide:true 설정으로 숨겨진 열을 제외하려면 raw 속성을 true로 설정합니다:

gantt.config.columns = [
{ name: "text", tree: true, width: 150, resize: true },
{ name: "start_date", align: "center", width: 120, resize: true },
// hidden columns are excluded from the export when raw: true
{ name: "end_date", align: "center", label: "End Time", hide: true, width: 120, resize: true },
{ name: "duration", align: "center", width: 70, hide: true, resize: true }
];

gantt.exportToExcel({
raw: true
});

관련 샘플: Gantt. Export to Excel. Hide grid columns with the raw mode

Import from Excel​

Excel 문서의 임의 열을 Gantt 데이터 모델에 자동으로 매핑하는 방법은 없으므로, 내보내기 서비스는 문서를 JSON으로 반환되는 행 배열로 변환합니다. 결과 문서를 Gantt 데이터로 변환하는 책임은 최종 개발자에게 있습니다.

Excel 파일을 변환하려면 내보내기 서비스에 아래와 같은 요청을 보내야합니다:

  • Request URL - https://export.dhtmlx.com/gantt
  • Request Method - POST
  • Content-Type - multipart/form-data

요청 매개변수는 다음과 같습니다:

  • file - 엑셀 파일
  • type - "excel-parse"
  • data - (optional) 설정이 포함된 JSON 문자열

예를 들면:

<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>

또는 client-side API를 사용할 수 있습니다:

gantt.importFromExcel({
server: "https://export.dhtmlx.com/gantt",
data: file,
callback: (project) => {
console.log(project)
}
});

관련 샘플: Import Excel file

여기서 file은 Excel(xlsx) 파일을 포함해야 하는 File 인스턴스입니다.

노트

gantt.importFromExcel 는 HTML5 File API 지원이 필요합니다.

Response​

응답은 객체 배열이 포함된 JSON을 반환합니다:

[
{ "Name": "Task Name", "Start": "2026-04-11 10:00", "Duration": 8 },
...
]

여기서:

  • 첫 번째 행의 값은 가져온 객체의 속성 이름으로 사용됩니다.
  • 각 행은 개별 객체로 직렬화됩니다.
  • 날짜 값은 "%Y-%m-%d %H:%i" 형식으로 직렬화됩니다.

Import settings​

  • 가져오기 서비스는 가져온 시트의 첫 번째 행이 열 이름을 포함하는 머리글 행이 되기를 기대합니다.
  • 기본적으로 서비스는 문서의 첫 번째 시트를 반환합니다. 다른 시트를 반환하려면 sheet 매개변수를 사용합니다(제로 기반)
gantt.importFromExcel({
server: "https://export.dhtmlx.com/gantt",
data: file,
sheet: 2, // print third sheet
callback: (rows) => {}
});

iCal로 Export​

iCal로 내보내기는 iCal로 내보내기 문서에 설명되어 있습니다.

Need help?
Got a question about the documentation? Reach out to our technical support team for help and guidance. For custom component solutions, visit the Services page.