I want create a File Excel, convert this file to MultipartFile.class because I have test that read files MultipartFile, I created my file, but I don't know transform byte[] to MultipartFile because my function read MultipartFile.
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.getSheetAt(0);
XSSFRow row = sheet.createRow((short) 1);
row.createCell(0).setCellValue("2019");
row.createCell(1).setCellValue("11");
row.createCell(2).setCellValue("1");
row.createCell(3).setCellValue("2");
byte[] fileContent = null;
ByteArrayOutputStream bos = null;
bos = new ByteArrayOutputStream();
workbook.write(bos);
workbook.close();
fileContent = bos.toByteArray();
bos.close();
MultipartFile multipart = (MultipartFile) fileContent;
err:
Cannot cast from byte[] to MultipartFile