I'm new in Vue and now trying to handle an bytearray as an .xls file
For now i have an issue that the file looks like
broken
If i'm saving it as file at server side, data looks fine and nothing going wrong
Server side:
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("Payments");
for (int i = 0; i < payments.size(); i++) {
Payment payment = payments.get(i);
Row row = sheet.createRow(i);
...(adding a lot of data)
}
try (ByteArrayOutputStream bos = new ByteArrayOutputStream()) {
wb.write(bos);
wb.close();
return bos.toByteArray();
}
Vue side:
axios.post(myRequestAndData)
.then(resp => {
var fileURL = window.URL.createObjectURL(new Blob([resp.data]));
var fileLink = document.createElement('a');
fileLink.href = fileURL;
fileLink.setAttribute('download', 'file.xls');
document.body.appendChild(fileLink);
fileLink.click();
So how can i handle my ByteArray data to create a file in the right way?
Thanks anyway
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…