匯出excel

HuangBingQuan發表於2024-04-26
/**
 * 匯出excel
 *
 * @param {blob} data 後端返回的檔案流
 * @param {String} fileName 檔名
 */
export const exportFile = (data, fileName) => {
  const binaryData = [];
  binaryData.push(data);
  const url = URL.createObjectURL(new Blob(binaryData));
  const link = document.createElement('a');
  link.download = `${fileName}.xlsx`;
  link.href = url;
  link.click();
  URL.revokeObjectURL(url);
};

相關文章