How to create excel file using apache poi and upload it to S3

Hi
i am trying to create excel file using apache poi
i am uploading it to s3 using S3 put, but after upload file is getting corrupted.
any one please provide code to create excel file and upload to s3 on server