4
$\begingroup$

I am not even sure whether it is possible. I would like to change column headings of TableView output to letters such as A, B, C etc instead of 1,2,3. Here is an example:

RandomVariate[UniformDistribution[{10, 20}], {10, 3}] // TableView

enter image description here

I want the results to look like an excel spreadsheet as follows: enter image description here

Any help is greatly appreciated. Thank you in advance.

$\endgroup$
1
$\begingroup$

This may not be efficient but could be a good starting point. It works for data up to 26 columns. If you need more columns, you can modify the function.

    tableView[data_] := Module[{rowheadings, columnheading, output},
      rowheadings = Flatten[{Range[1, Length[data]]}];
      columnheading =Flatten[{"", CharacterRange["A", "Z"][[1 ;; Dimensions[data] 
                     [[2]]]]}];
      output = Prepend[Join[List /@ rowheadings, Map[Style[NumberForm[#, 6]] &, data, {-1}], 2], 
             columnheading];
      Grid[output, Frame -> All, FrameStyle -> GrayLevel[.9],
 Alignment -> {Center, Center}, Background -> {{GrayLevel[.8], None}, {GrayLevel[.8], None}}]
      ]

Here is an example:

data = RandomVariate[UniformDistribution[{10, 20}], {7, 5}];
tableView[data]

enter image description here

|improve this answer|||||
$\endgroup$
  • $\begingroup$ @ ramesh, it definitely helps. Thank you. $\endgroup$ – DLT Jan 24 at 16:14
  • $\begingroup$ @ DLT, I am glad that it helped you. $\endgroup$ – ramesh Jan 24 at 16:59
0
$\begingroup$

Looking at the options of TableView it seems like it's not possible.

Options[TableView]

{Alignment -> {Automatic, Automatic}, AllowedDimensions -> Automatic, Appearance -> Automatic, AppearanceElements -> All, Background -> Automatic, BaselinePosition -> Automatic, BaseStyle -> {}, ContentPadding -> True, DefaultBaseStyle -> "TableView", Enabled -> Automatic, FieldSize -> {{1., 5.}, {1., 1.}}, FrameMargins -> Automatic, ImageMargins -> Automatic, ImageSize -> Automatic, Scrollbars -> {Automatic, Automatic}, ScrollPosition -> {0., 0.}, Spacings -> Automatic}

Anyway, as I suggested in the comment, the use of TableView is not advised as it causes crashes and is still under development.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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