Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

There is InputField in mma but how to make InputTable? In MathCAD it`s possible to insert Excel spreadsheet with input and output variables.Input variables I use for filling of header row and column and output variable for output. How to make the same functionality in mma? Thanks in advance

share|improve this question
    
Thanks for the accept, but there's no need for speed. It's better to give it a few hours or even days, so that more answers come in. –  Sjoerd C. de Vries Sep 16 '12 at 15:15
    
This MathCAD feature is very good but nothing like it exists built in to Mma. The closest is TableView which @SjoerdC.deVries has shown below. It is undocumented and falls way short of the MathCAD implementation. Fingers crossed for a full documented and better version for V9. –  Mike Honeychurch Sep 16 '12 at 22:46
add comment

1 Answer 1

nrows = 3; ncols = 4;
t = ConstantArray[0, {nrows, ncols}];
it = Table[With[{i = i, j = j}, InputField[Dynamic[t[[i, j]]]]], {i,nrows}, {j, ncols}];

Dynamic[TableView[it]]

Mathematica graphics

Another dynamic view to show it works:

Transpose[t] // TableView // Dynamic

(the Transpose here just used to show it actively uses the input).

Mathematica graphics

Please note that I used the undocumented TableView to make it more Excel-like, but I noticed that cell selection is a bit sluggish and/or unpredictable. You may want to change to Grid instead, which seems to work better.

share|improve this answer
    
@NasserM.Abbasi As you can see in the figures it is quite possible to enter data in all the rows (I work on the same platform as you), but there is a good reason for my advice to use Grid. –  Sjoerd C. de Vries Sep 16 '12 at 15:12
2  
Dangerous to rely upon undocumented (even unreliable) TableView. It would be really convenient if TableView were implemented reliably and with documentation in a future Mathematica version, but that's something we cannot count on, of course. So Grid is probably better to use for now. –  murray Sep 16 '12 at 15:23
    
But inputed values dissapear after recalculation of notebook?! –  SergeyFomin Sep 16 '12 at 16:27
    
@SergeyFomin Did you notice the line: t = ConstantArray[0, {nrows, ncols}]; in the code? What do you think it does? –  Sjoerd C. de Vries Sep 16 '12 at 18:30
    
It initialize the array t of course.But I need to keep inputed values.I guess it`s obvious thing or no? –  SergeyFomin Sep 16 '12 at 19:34
show 5 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.