mirror of
https://gh-proxy.org/https://github.com/klinsmaya/SQLBot.git
synced 2026-11-08 01:06:59 +08:00
Merge branch 'main' of https://github.com/dataease/SQLBot
This commit is contained in:
@@ -206,12 +206,9 @@ async def export_excel(excel_data: ExcelData):
|
||||
_fields_list.append(field.name)
|
||||
df = pd.DataFrame(np.array(data), columns=_fields_list)
|
||||
|
||||
file_name = f"{excel_data.name}-{datetime.datetime.now().strftime('%Y-%m-%d_%H-%M-%S')}_{hashlib.sha256(uuid.uuid4().bytes).hexdigest()[:10]}.xlsx"
|
||||
|
||||
file_path = f'{(settings.EXCEL_PATH if settings.EXCEL_PATH[-1] == "/" else (settings.EXCEL_PATH + "/"))}{file_name}'
|
||||
|
||||
buffer = io.BytesIO()
|
||||
df.to_excel(buffer, index=False)
|
||||
buffer.seek(0)
|
||||
|
||||
return StreamingResponse(io.BytesIO(buffer.getvalue()))
|
||||
return StreamingResponse(io.BytesIO(buffer.getvalue()),
|
||||
media_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
|
||||
|
||||
@@ -329,5 +329,5 @@ export const chatApi = {
|
||||
return request.fetchStream(`/chat/recommend_questions/${record_id}`, {}, controller)
|
||||
},
|
||||
checkLLMModel: () => request.get('/system/aimodel/default', { requestOptions: { silent: true } }),
|
||||
export2Excel: (data: any) => request.post('/chat/excel/export', data),
|
||||
export2Excel: (data: any) => request.post('/chat/excel/export', data, { responseType: 'blob' }),
|
||||
}
|
||||
|
||||
@@ -232,7 +232,9 @@ function exportToExcel() {
|
||||
chatApi
|
||||
.export2Excel({ ...chartRef.value?.getExcelData(), name: chartObject.value.title })
|
||||
.then((res) => {
|
||||
const blob = new Blob([res.data])
|
||||
const blob = new Blob([res], {
|
||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
})
|
||||
const link = document.createElement('a')
|
||||
link.href = URL.createObjectURL(blob)
|
||||
link.download = `${chartObject.value.title ?? 'Excel'}.xlsx`
|
||||
|
||||
Reference in New Issue
Block a user