• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to write data into Excel file in order  RSS feed

 
santhana Marimuthu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi to all,I need to write data into an Excel file in order. I've written this function:

It's working, but the result is appearing like this:

02 Ganesh 100000
01 bala 100000
Employee ID Employee Name Salary
03 Kumar 100000

I want to write employee id and name as first row in the sheet.

What do I need to do?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why is empData a Map<String, List<String>> instead of just a List<String>? Maps generally are not ordered, and you're not using the key anyway. Lists, on the other hand, are ordered (in the sequence of insertion).
 
santhana Marimuthu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

thanks for your reply.and one more thing is i dont know how to write data into excel from list object can you help me please?

thanks in advance.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you asking how to iterate through a List? It's very similar to iterating through a Map. Assuming you're now using a List<String> to hold the data, it would be something like this:

 
santhana Marimuthu
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you ulf Ditmer.and my question is how to apply values which is iterated from list to excell sheet.
thanks in advance...
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "apply"? Your code show that you already know how set certain cells to certain values. (I assume you have gone through http://poi.apache.org/spreadsheet/quick-guide.html to learn about how to accomplish various tasks using POI. If you haven't done so yet, then now would be a good time to do so.)
 
Jagadeesh Gudla
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Convert Your header to a String and write header String to Sheet first row...
form a Single String for each data row , fill them after filling Header row.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!