I want to display excel sheet on android screen with horizontal and vertical scrollbars..plz help me.I have searched so much on net.thanks
4 Answers
There are base classes for horizontal scroll views and vertical scrollviews, but not one where one can scroll in two dimensions at the same time.
I have found this blog in which Matt Clark have created a new TwoDScrollView class.
http://blog.gorges.us/2010/06/android-two-dimensional-scrollview/

- 2,940
- 1
- 25
- 38
-
I think I've read it and it's good. But how do you display the grid? Each cell should be selectable and updatable. How would you achieve them? I don't think GridView will work because it's not going to be horizontally scrollable. – Tae-Sung Shin Dec 30 '11 at 08:09
-
Have you seen Predicate Layout ? http://stackoverflow.com/questions/549451/line-breaking-widget-layout-for-android You can use it with TwoDScrollView for your purpose. – Sourab Sharma Dec 30 '11 at 09:19
-
OK. I can see the predicate layout inside of TwoDScrollView. But three problems are there. One big issue is that predicate layout shows elements in a single line whatever I tried with layout width and height. Another problem is that it's so slow (10-20 sec) to load the 1000 items into predicate layout. Last problem is I have to specify size of direct child layout of TwoDScrollView in the layout XML. This is not going to work in practice of course. Did you try this before? If so, can you share your xml layout? – Tae-Sung Shin Dec 30 '11 at 17:17
PsuedoCode
Have a TableLayout inside a scrollview!!!
How to populate it->
For each row in spreadsheet
TableRow tr = new TableRow()
For each cell in row
//Create a textview.//
TextView trCell = new TextView()
//Set TextView text, get text from spreadsheet current cell.//
trCell.setText(cell.textvalue)
tr.addview(trCell)
}
tableLayout.addView(tr) //Add tablerow to the tablelayout.//
}
Since table is in a scrollview, if table rows extend length of scroll view, scrollbars will appear.
If you need more info, I'll post my exact code. And if you still cant get it, ill upload my whole class to GitHub.

- 389
- 4
- 15
Create a ScrollView and then inside of this place a HorizontalScrollView. Now this will behave as on object that has both Vertical and Horizontal Scrolling properties.

- 1,231
- 17
- 23
-
The user experience will be quite terrible however. But on the functional side, this solution does work. – Zsombor Erdődy-Nagy Oct 24 '11 at 01:03
I know GridView is not popular for your purpose. But it still gives us an easier way to build spreadsheet like UI.
As you said, GridView itself is not horizontally scrollable and will be extremely slow if number of controls in the gridview exceeds says 500.
But I think what you want to try is to fix size of the gridview that will display given rectangle area of data and to override its touch event to emulate scrolling actions. Thanks to base adapter and other techniques for gridview, your work will be minimal.
Good example of such a method is Dennis's work

- 20,215
- 33
- 138
- 240