1

I made a randomly generated list of people with names, ages, weight, height, etc. in Excel. I would like to know how I can use the information in Excel to create a "Person" in Java so that each file would contain the information of each person created in Excel. There are about 200,000 "People". For example a Java template: "name = [INSERT FROM EXCEL CELL A1]" then goes to "age = [INSERT FROM EXCEL CELL A2]" and it does this for the first row then saves the file and uses the empty variable template again and does this for the 200,000 individuals. Is this possible or will I have to do this by hand? Can this be automated?

1
  • yes it should :)) sorry. Commented Aug 16, 2013 at 9:27

3 Answers 3

2

Save the excel file in CSV format. CSV is relatively easy to read and write, and is an industry recognized format.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you very much :)) I will try it when I get back from vacation.
1

Save your excel file as .xml and then parsing that data in java. As others have said you can also save it as a .csv file which you can also parse in java.

1 Comment

Thank you very much will try it when I get back :))
0

You can use opencsv for convert each row to bean. You need to save your excel as a csv file.

CSVReader reader = new CSVReader(new FileReader("yourfile.csv"));

ColumnPositionMappingStrategy strat = new ColumnPositionMappingStrategy();
strat.setType(Person.class);

// the fields to bind do in your JavaBean
String[] columns = new String[] {"name", "age"}; 
strat.setColumnMapping(columns);

CsvToBean csv = new CsvToBean();
List list = csv.parse(strat, reader); // the people

1 Comment

Wow thank you so much for the code too. That seems simple enough. :)) Thanks again, best answer!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.