This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Web Services and the fly likes Read\Write\Search a word in Excel using Java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Web Services
Bookmark "Read\Write\Search a word in Excel using Java" Watch "Read\Write\Search a word in Excel using Java" New topic
Author

Read\Write\Search a word in Excel using Java

Dhivya Krishnan
Ranch Hand

Joined: Apr 27, 2010
Posts: 41
Hi,

I have an excel file. Using POI, I am able to read the contents and write contents to it.

But my specification is to read the value of a particular cell and write a value to the particular cell.

Search a value in a specific column.

I need to do this using JAVA.

Thanks in Advance.

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41148
    
  45
If you are able to "read and write a spreadsheet", how is that different from "reading and writing particular cells" of a spreadsheet? In other words, what do you have so far, and where are you stuck making progress?


Ping & DNS - my free Android networking tools app
Dhivya Krishnan
Ranch Hand

Joined: Apr 27, 2010
Posts: 41
I wanted to search using a particular word.

I fetched a column using columns name., adding all the column values to an arraylist and searching if the value is there in the list.

Can you please tell me which collection to use. Hash map, Arraylist,linkedlist or anything else.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41148
    
  45
What would be the point of this additional data structure? It seems you could just as easily iterate over rows and columns...?

Otherwise, a List of Lists might work for representing a sheet.
Dhivya Krishnan
Ranch Hand

Joined: Apr 27, 2010
Posts: 41
Let me clearly explain the requirement, Please guide me the best approach.
I need to fetch data from excel file and upload them in a form.

Below are the constraints.
1. The number of columns or the position of the columns is not fixed.
2. Need to sort the content based on a column.
3. Search for a value in the specified column and fetch the entire row.

Ex: The excel has Name|ID|Age|Address| as columns.
The number and position of columns might vary.
Need to sort the content based on id and fetch the compelte row of id 123456.

Please suggest me the best approach.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41148
    
  45
What is the connection between #2 and #3? Sorting and searching are orthogonal activities. Or do you intend to implement something like binary search?

Also, what is the "upload" part about? Upload what - all the data form the file, some of the data from the file, ... ?
Dhivya Krishnan
Ranch Hand

Joined: Apr 27, 2010
Posts: 41
Its not like binary search.

Column 1 | Column 2 | Column 3 | Column 4
AT ABC 123 JUNK1
EU XYZ 456 JUNK2
US ABC 789 JUNK3

In the table above., I need to filter the table column 2 with ABC. I will end up having two rows. Now I need to search in column 1 for AT and fetch the complete row details.

James Boswell
Bartender

Joined: Nov 09, 2011
Posts: 1012
    
    5

@Dhivya Krishnan

Does that not simply equate to:

Return all the rows where column1="AT" and column2="ABC"?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Read\Write\Search a word in Excel using Java
 
Similar Threads
JXL search for cell according string value
Problem with adding time
Read MS Excel Sheet Formula Execution Value Without Opening it
JExcel Help
Copying and adding values in excel using java code