0

I am working on below environment:

  • Spring 3.0.5
  • JDK 1.6

After some specific operation, need to send a mail with attached xls file to specified mails. Presently i have raw data which need to write in xls file.

Have search how to attach file in spring framework while sending mail. But want to know byte Array format which will be rendered in specified column & row of xls file. Actually need to created xls file on the fly through string raw data.

Any better way to attach xls file while sending mail through spring will be welcomed. :)

Atul Kumar
  • 719
  • 3
  • 8
  • 29

1 Answers1

0

Apache POI will help with creating the xls file.

JavaMail will send the mail message. I'm sure there's a Spring-specific way of using JavaMail as well.

Bill Shannon
  • 29,579
  • 6
  • 38
  • 40
  • [Send mail through spring with attachment](http://gauravmutreja.wordpress.com/2010/09/01/attaching-excel-or-pdf-files-to-a-mail-using-spring-framework/) In this link it passing `byte[] byteArray` as argument of method, my main question is what will be format for this byte array (how to create this byte array). As i want to generate xls on the fly with my raw string. – Atul Kumar Nov 28 '13 at 08:50
  • @Atul You'll need to serialize the object. See http://stackoverflow.com/questions/5837698/converting-any-object-to-a-byte-array-in-java – Bart Nov 28 '13 at 09:33
  • @bart what my question is, I have raw sting data... and I want to fit this to some specific cells at some specific index in xls, which will be need to attached in mail. my last way to do this will be as: 1. Create Temp XlS file through POI 2. Read this file 3. Convert to byte array 4. pass array to mimeHelper to attach as XLS. which i don't want to do. – Atul Kumar Nov 28 '13 at 09:58