1

I have to read a text file and write it to an already existing excel file. The excel file is a customized excel sheet with different items in different columns. The items has different values for each of them... These items with there value can be found in a text file. But i dont have much idea as to how to do this.

E.g- example.txt

Name: John

Age=24

Sex=M

Graduate=M.S

example.xlsx

Age: Sex:

Name: Graduate:

Thanks in advance :)

user1957902
  • 37
  • 3
  • 5

3 Answers3

4

Just as for so many other problems that need solved, there's an Apache library for that! In this case, it's the POI library. I've only used it for very basic spreadsheet manipulation, but managed that by just following a few tutorials. I'd link to one, but I can't now remember where it was.

chooban
  • 9,018
  • 2
  • 20
  • 36
  • i have used POI apache earlier to write a hard coded value to a specific cell. But i have no clue as to how the code will read the value for a specific item n place that value to the specific cell in excel... – user1957902 May 22 '13 at 09:50
0

Please see Apache POI-HSSF library for reading and writing Excel files with Java. There are some quick guides to get you started.

This post How to read and write excel file in java might help you.

Community
  • 1
  • 1
Shreyos Adikari
  • 12,348
  • 19
  • 73
  • 82
0

You can also create a *.csv (comma separated value) file in Java. Just create a simple text file with CSV extension and put your values in there like that :

Age:,24,Sex:,M,

So you just separate your values with commas (or other delimiters like ';'). Every line in this file is a row, and every delimiter separates two columns. You won't be able to add colours/styles/formatting this way, but it gives you a file that is openable and understandable even without Excel (or other spreadsheet software).

Losiowaty
  • 7,911
  • 2
  • 32
  • 47