Paul Lutus wrote: > Does it produce a result that is different than your own code, when used > with 'pp'? Does it solve your problem? > >> And here is my codes with the problem: > > What is the problem at this point? What is 'pp'? How do you export your > data > to Excel? What happens if you adopt my method instead of your own? Hi Paul, When I run your script I need to use pp(pretty print) to get 8 rows x12 columns format on the screen. If I just use p I get all the elements on one line. But I still can see the result is a 2D array even they are printed one line. For me I need the format in result A only. Here is your codes with pp(8 row x12 column format): ###format A## >ruby format4.rb [[1256, 1165, 95, 330, 1320, 1425, 1489, 1953, 207, 1132, 1378, 1101], [530, 1340, 1842, 1136, 104, 888, 378, 741, 954, 1949, 1608, 597], [1379, 648, 95, 544, 1194, 1728, 1259, 691, 601, 20, 1301, 1625], [652, 32, 947, 241, 248, 656, 1197, 1308, 1870, 613, 1188, 1409], [680, 1294, 1842, 1947, 1467, 670, 989, 126, 1174, 964, 1868, 1875], [771, 990, 687, 706, 1372, 0, 1332, 1527, 411, 1885, 658, 1903], [207, 276, 71, 1097, 10, 1083, 1600, 1776, 1016, 374, 414, 472], [1477, 1183, 711, 1726, 1642, 1167, 1513, 316, 28, 1285, 181, 1681]] >Exit code: 0 ##format B## your code with p:(all elements in one line, 1 row x 96 column format) >ruby format4.rb [[631, 1224, 1534, 477, 642, 1915, 814, 1350, 998, 234, 1377, 1697], [1421, 1972, 1020, 789, 1258, 1585, 1979, 518, 1747, 1419, 169, 1067], [1395, 1103, 463, 1064, 1841, 1676, 1946, 1697, 1274, 153, 1125, 1415], [1857, 1322, 782, 778, 1704, 100, 1814, 1144, 1380, 1155, 626, 520], [137, 788, 1691, 1865, 1443, 20, 1699, 1595, 51, 1481, 1603, 558], [240, 92, 927, 635, 1910, 1806, 778, 170, 1152, 281, 1434, 1422], [1011, 143, 1315, 78, 1076, 828, 496, 559, 1878, 1660, 1613, 1721], [1344, 1716, 103, 760, 389, 1869, 716, 945, 637, 596, 1550, 752]] >Exit code: 0 If I run your codes with my data and if I use p I get the same format as that in result B. If I run your codes with my data and if I use pp I get the format C as follows: ##result C >ruby format3.rb [[2294.4, 3481.2, 2716.7, 1672.2, 1135.3, 2103.5, 591.1, 648.5, 603.0, 477.2, 264.1, 626.5], ... [459.2, 349.3, 358.0, 351.1, 340.2, 488.2, 13.0, 14.1, 14.1, 16.2, 16.1, 27.1]] >Exit code: 0 Whatever codes I run the same 2D array gives rise to different print format and the formats also depend on the data in the 2D array. This is the reason why I post my question. Again thank you very much for your time, Li -- Posted via http://www.ruby-forum.com/.