Reputation: 11
I am not exactly sure what the best approach here is. I am a novice programmer, trying to learn Java and I have a task I would like to complete. I have data in a Excel file. The Excel file has multiple columns. I need to take a the value from a particular column, use it to query a database. If the query returns null then add a value to a column, or mark it some how. If the the query returns a value then do nothing. Move to the next line.
anyone want to throw a noob a bone?
Upvotes: 1
Views: 973
Reputation: 8466
Try to use Apache POI jar,
FileInputStream fis = new FileInputStream(FILE_NAME);
XSSFWorkbook workbook = new XSSFWorkbook(fis);
Sheet sheet = workbook.getSheet(READ_PARTICULAR_SHEET);
for (Row readRow : sheet)
{
for (Cell readCell : readRow)
{
if (readCell.getCellType() == ANY_THING)
{
//anything you want
}
}
}
For reference here
Upvotes: 0
Reputation: 1801
I would look at using Apache POI for extracting the data from the excel file and MyBatis for database mapping/interaction.
Of course we can't write the code for you, but those two resources should give you a kickstart. Once you start writing the code, and you find yourself struggling, then I would post back here with code examples of what you're trying to achieve.
Upvotes: 0