Skip to content

Excel API

readExcelData(file: File, options?: ReadExcelOptions)

.xlsx, .csv 파일 내용을 읽는 함수.

ReadExcelOptions Interface
  • csv파일일 경우 delimiter의 default 값은 ,
ts
export interface ReadExcelOptions {
    delimiter?: string,
    customHeaders: any[],
};

Example

File

column1column2
12

Input(csv)

ts
readExcelData(csvFile);

Output(csv)

json
[
    {
        "column1": "1",
        "column2": "2"
    }
]

Input(xlsx)

ts
readExcelData(excelFile);

Output(xlsx)

json
[
    {
        "sheet_name": "Sheet1",
        "data": [
            {
                "column1": "1",
                "column2": "2"
            }
        ]
    }
]

downloadExcel(data: any[], options?: DownloadExcelOptions)

데이터를 .xlsx 또는 .csv 파일로 만들어 다운로드 하는 함수.
현재 단일 시트만 지원(시트명은 Sheet1).

DownloadExcelOptions Interface
  • isHeader의 default 값은 true
  • fileName의 default 값은 download
  • type의 default 값은 xlsx
ts
export interface DownloadExcelOptions {
    isHeader?: boolean,
    fileName?: string,
    type?: string,
    delimiter?: string,
};

Example

Input

ts
const data = [
    {
        'column1': '1',
        'column2': '1',
    }
];
downloadExcel(data, {
    type: 'csv',
});

Output

download.xlsx 파일이 다운로드됌.