I import an excel file
c1 c2 c3
1 3 5
2 4 6
fp = NotebookDirectory[] <> "Book1.xls";
excelSheet = Import[fp] [[1]];
t1 = Grid[excelSheet, Frame -> All, Alignment -> Left,
Background -> {None, {Gray, {White, LightGray}}}
The table shows each number with a "." at the end :( How do I get rid of it?
c1 c2 c3
1. 3. 5.
2. 4. 6.
Thanx
Solution:
For[i = 1, i <= Length[excelSheet], i++,
For[j = 1, j <= Length[excelSheet[[i]]], j++,
If[NumericQ[excelSheet[[i, j]]],
excelSheet[[i, j]] = Round[excelSheet[[i, j]]];
];
];
];
excelSheet /. x_?NumericQ :> With[{r = Round[x]}, r /; r == x]
is more robust, or since it's Excel,x_Real
instead ofx_?NumericQ
. (You might not want to convert6.4
to6
. This replacement rule will round to an integer only if the rounded value is equal to the original number.) $\endgroup$