1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936 4937 4938 4939 4940 4941 4942 4943 4944 4945 4946 4947 4948 4949 4950 4951 4952 4953 4954 4955 4956 4957 4958 4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971 4972 4973 4974 4975 4976 4977 4978 4979 4980 4981 4982 4983 4984 4985 4986 4987 4988 4989 4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020 5021 5022 5023 5024 5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047 5048 5049 5050 5051 5052 5053 5054 5055 5056 5057 5058 5059 5060 5061 5062 5063 5064 5065 5066 5067 5068 5069 5070 5071 5072 5073 5074 5075 5076 5077 5078 5079 5080 5081 5082 5083 5084 5085 5086 5087 5088 5089 5090 5091 5092 5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120 5121 5122 5123 5124 5125 5126 5127 5128 5129 5130 5131 5132 5133 5134 5135 5136 5137 5138 5139 5140 5141 5142 5143 5144 5145 5146 5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171 5172 5173 5174 5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203 5204 5205 5206 5207 5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 5256 5257 5258 5259 5260 5261 5262 5263 5264 5265 5266 5267 5268 5269 5270 5271 5272 5273 5274 5275 5276 5277 5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299 5300 5301 5302 5303 5304 5305 5306
|
<HTML>
<HEAD>
<TITLE>Spreadsheet::WriteExcel - Write to a cross-platform Excel binary file.</TITLE>
<LINK REV="made" HREF="mailto:">
</HEAD>
<style type="text/css">
<!--
pre {
font-family : courier new, sans-serif;
font-size : 10pt;
color : #0066cc;
}
CODE {
font-family : courier new, sans-serif;
font-size : 10pt;
color : #0066cc;
}
-->
</style>
<BODY>
<!-- INDEX BEGIN -->
<UL>
<LI><A HREF="#NAME">NAME</A></LI>
<LI><A HREF="#VERSION">VERSION</A></LI>
<LI><A HREF="#SYNOPSIS">SYNOPSIS</A></LI>
<LI><A HREF="#DESCRIPTION">DESCRIPTION</A></LI>
<LI><A HREF="#QUICK_START">QUICK START</A></LI>
<LI><A HREF="#WORKBOOK_METHODS">WORKBOOK METHODS</A></LI>
<UL>
<code><LI><A HREF="#new_">new()</A></LI>
<LI><A HREF="#close_">close()</A></LI>
<LI><A HREF="#addworksheet_sheetname_">addworksheet($sheetname)</A></LI>
<LI><A HREF="#addformat_properties_">addformat(%properties)</A></LI>
<LI><A HREF="#set_custom_color_index_red_">set_custom_color($index, $red, $green, $blue)</A></LI>
<LI><A HREF="#set_palette_xl5_">set_palette_xl5()</A></LI>
<LI><A HREF="#sheets_">sheets()</A></LI>
<LI><A HREF="#set_1904_">set_1904()</A></LI></code>
</UL>
<LI><A HREF="#WORKSHEET_METHODS">WORKSHEET METHODS</A></LI>
<UL>
<code><LI><A HREF="#Cell_notation">Cell notation</A></LI>
<LI><A HREF="#write_row_column_token_fo">write($row, $column, $token, $format)</A></LI>
<LI><A HREF="#write_number_row_column_num">write_number($row, $column, $number, $format)</A></LI>
<LI><A HREF="#write_string_row_column_str">write_string($row, $column, $string, $format)</A></LI>
<LI><A HREF="#write_formula_row_column_fo">write_formula($row, $column, $formula, $format)</A></LI>
<LI><A HREF="#write_blank_row_column_form">write_blank($row, $column, $format)</A></LI>
<LI><A HREF="#write_row_row_column_array_">write_row($row, $column, $array_ref, $format)</A></LI>
<LI><A HREF="#write_col_row_column_array_">write_col($row, $column, $array_ref, $format)</A></LI>
<LI><A HREF="#write_url_row_col_url_str">write_url($row, $col, $url, $string, $format)</A></LI>
<LI><A HREF="#write_url_range_row1_col1_r">write_url_range($row1, $col1, $row2, $col2, $url, $string, $format)</A></LI>
<LI><A HREF="#insert_bitmap_row_col_filen">insert_bitmap($row, $col, $filename, $x, $y, $scale_x, $scale_y)</A></LI>
<LI><A HREF="#get_name_">get_name()</A></LI>
<LI><A HREF="#activate_">activate()</A></LI>
<LI><A HREF="#select_">select()</A></LI>
<LI><A HREF="#set_first_sheet_">set_first_sheet()</A></LI>
<LI><A HREF="#protect_password_">protect($password)</A></LI>
<LI><A HREF="#set_selection_first_row_first">set_selection($first_row, $first_col, $last_row, $last_col)</A></LI>
<LI><A HREF="#set_row_row_height_format_">set_row($row, $height, $format)</A></LI>
<LI><A HREF="#set_column_first_col_last_col">set_column($first_col, $last_col, $width, $format, $hidden)</A></LI>
<LI><A HREF="#freeze_panes_row_col_top_ro">freeze_panes($row, $col, $top_row, $left_col)</A></LI>
<LI><A HREF="#thaw_panes_y_x_top_row_le">thaw_panes($y, $x, $top_row, $left_col)</A></LI>
<LI><A HREF="#merge_cells_first_row_first_c">merge_cells($first_row, $first_col, $last_row, $last_col)</A></LI>
<LI><A HREF="#set_zoom_scale_">set_zoom($scale)</A></LI></code>
</UL>
<LI><A HREF="#PAGE_SET_UP_METHODS">PAGE SET-UP METHODS</A></LI>
<UL>
<code><LI><A HREF="#set_landscape_">set_landscape()</A></LI>
<LI><A HREF="#set_portrait_">set_portrait()</A></LI>
<LI><A HREF="#set_paper_index_">set_paper($index)</A></LI>
<LI><A HREF="#center_horizontally_">center_horizontally()</A></LI>
<LI><A HREF="#center_vertically_">center_vertically()</A></LI>
<LI><A HREF="#set_margins_inches_">set_margins($inches)</A></LI>
<LI><A HREF="#set_header_string_margin_">set_header($string, $margin)</A></LI>
<LI><A HREF="#set_footer_">set_footer()</A></LI>
<LI><A HREF="#repeat_rows_first_row_last_ro">repeat_rows($first_row, $last_row)</A></LI>
<LI><A HREF="#repeat_columns_first_col_last">repeat_columns($first_col, $last_col)</A></LI>
<LI><A HREF="#hide_gridlines_">hide_gridlines()</A></LI>
<LI><A HREF="#print_row_col_headers_">print_row_col_headers()</A></LI>
<LI><A HREF="#print_area_first_row_first_co">print_area($first_row, $first_col, $last_row, $last_col)</A></LI>
<LI><A HREF="#fit_to_pages_width_height_">fit_to_pages($width, $height)</A></LI>
<LI><A HREF="#set_print_scale_scale_">set_print_scale($scale)</A></LI>
<LI><A HREF="#set_h_pagebreaks_breaks_">set_h_pagebreaks(@breaks)</A></LI>
<LI><A HREF="#set_v_pagebreaks_breaks_">set_v_pagebreaks(@breaks)</A></LI></code>
</UL>
<LI><A HREF="#CELL_FORMATTING">CELL FORMATTING</A></LI>
<UL>
<LI><A HREF="#Creating_and_using_a_Format_obje">Creating and using a Format object</A></LI>
<LI><A HREF="#Format_methods_and_Format_proper">Format methods and Format properties</A></LI>
<LI><A HREF="#Working_with_formats">Working with formats</A></LI>
</UL>
<LI><A HREF="#FORMAT_METHODS">FORMAT METHODS</A></LI>
<UL>
<code><LI><A HREF="#set_properties_properties_">set_properties(%properties)</A></LI>
<LI><A HREF="#set_font_fontname_">set_font($fontname)</A></LI>
<LI><A HREF="#set_size_">set_size()</A></LI>
<LI><A HREF="#set_color_">set_color()</A></LI>
<LI><A HREF="#set_bold_">set_bold()</A></LI>
<LI><A HREF="#set_italic_">set_italic()</A></LI>
<LI><A HREF="#set_underline_">set_underline()</A></LI>
<LI><A HREF="#set_strikeout_">set_strikeout()</A></LI>
<LI><A HREF="#set_script_">set_script()</A></LI>
<LI><A HREF="#set_outline_">set_outline()</A></LI>
<LI><A HREF="#set_shadow_">set_shadow()</A></LI>
<LI><A HREF="#set_num_format_">set_num_format()</A></LI>
<LI><A HREF="#set_locked_">set_locked()</A></LI>
<LI><A HREF="#set_hidden_">set_hidden()</A></LI>
<LI><A HREF="#set_align_">set_align()</A></LI>
<LI><A HREF="#set_merge_">set_merge()</A></LI>
<LI><A HREF="#set_text_wrap_">set_text_wrap()</A></LI>
<LI><A HREF="#set_rotation_">set_rotation()</A></LI>
<LI><A HREF="#set_text_justlast_">set_text_justlast()</A></LI>
<LI><A HREF="#set_pattern_">set_pattern()</A></LI>
<LI><A HREF="#set_fg_color_">set_fg_color()</A></LI>
<LI><A HREF="#set_border_">set_border()</A></LI>
<LI><A HREF="#set_border_color_">set_border_color()</A></LI>
<LI><A HREF="#copy_format_">copy($format)</A></LI></code>
</UL>
<LI><A HREF="#COLOURS_IN_EXCEL">COLOURS IN EXCEL</A></LI>
<LI><A HREF="#DATES_IN_EXCEL">DATES IN EXCEL</A></LI>
<LI><A HREF="#FORMULAS_AND_FUNCTIONS_IN_EXCEL">FORMULAS AND FUNCTIONS IN EXCEL</A></LI>
<LI><A HREF="#EXAMPLES">EXAMPLES</A></LI>
<UL>
<code><LI><A HREF="#Example_1">Example 1</A></LI>
<LI><A HREF="#Example_2">Example 2</A></LI>
<LI><A HREF="#Example_3">Example 3</A></LI>
<LI><A HREF="#Example_4">Example 4</A></LI>
<LI><A HREF="#Example_5">Example 5</A></LI>
<LI><A HREF="#Additional_Examples">Additional Examples</A></LI></code>
</UL>
<LI><A HREF="#LIMITATIONS">LIMITATIONS</A></LI>
<LI><A HREF="#REQUIREMENTS">REQUIREMENTS</A></LI>
<LI><A HREF="#PORTABILITY">PORTABILITY</A></LI>
<LI><A HREF="#DIAGNOSTICS">DIAGNOSTICS</A></LI>
<LI><A HREF="#THE_EXCEL_BINARY_FORMAT">THE EXCEL BINARY FORMAT</A></LI>
<LI><A HREF="#WRITING_EXCEL_FILES">WRITING EXCEL FILES</A></LI>
<LI><A HREF="#READING_EXCEL_FILES">READING EXCEL FILES</A></LI>
<LI><A HREF="#BUGS">BUGS</A></LI>
<LI><A HREF="#TO_DO">TO DO</A></LI>
<LI><A HREF="#SEE_ALSO">SEE ALSO</A></LI>
<LI><A HREF="#ACKNOWLEDGEMENTS">ACKNOWLEDGEMENTS</A></LI>
<LI><A HREF="#AUTHOR">AUTHOR</A></LI>
<LI><A HREF="#COPYRIGHT">COPYRIGHT</A></LI>
</UL>
<!-- INDEX END -->
<HR>
<P>
<H1><A NAME="NAME">NAME</A></H1>
<P>
Spreadsheet::WriteExcel - Write to a cross-platform Excel binary file.
</P>
<P>
<HR>
<H1><A NAME="VERSION">VERSION</A></H1>
<P>
This document refers to version 0.36 of Spreadsheet::WriteExcel, released
April 9, 2002.
</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<P>
To write a string, a formatted string, a number and a formula to the first
worksheet in an Excel workbook called perl.xls:
</P>
<P>
<PRE>
use Spreadsheet::WriteExcel;
</PRE>
</P>
<P>
<PRE>
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("perl.xls");
</PRE>
</P>
<P>
<PRE>
# Add a worksheet
$worksheet = $workbook->addworksheet();
</PRE>
</P>
<P>
<PRE>
# Add and define a format
$format = $workbook->addformat(); # Add a format
$format->set_bold();
$format->set_color('red');
$format->set_align('center');
</PRE>
</P>
<P>
<PRE>
# Write a formatted and unformatted string, row and column notation.
$col = $row = 0;
$worksheet->write($row, $col, "Hi Excel!", $format);
$worksheet->write(1, $col, "Hi Excel!");
</PRE>
</P>
<P>
<PRE>
# Write a number and a formula using A1 notation
$worksheet->write('A3', 1.2345);
$worksheet->write('A4', '=SIN(PI()/4)');
</PRE>
</P>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
The Spreadsheet::WriteExcel module can be used to create a cross-platform
Excel binary file. Multiple worksheets can be added to a workbook and
formatting can be applied to cells. Text, numbers, formulas, hyperlinks and
images can be written to the cells.
</P>
<P>
The Excel file produced by this module is compatible with Excel 5, 95, 97,
2000 and 2002.
</P>
<P>
The module will work on the majority of Windows, UNIX and Macintosh
platforms. Generated files are also compatible with the Linux/UNIX
spreadsheet applications Gnumeric and OpenOffice.
</P>
<P>
This module cannot be used to write to an existing Excel file.
</P>
<P>
<HR>
<H1><A NAME="QUICK_START">QUICK START</A></H1>
<P>
Spreadsheet::WriteExcel tries to provide an interface to as many of Excel's
features as possible. As a result there is a lot of documentation to
accompany the interface and it can be difficult at first glance to see what
it important and what is not. So for those of you who prefer to assemble
Ikea furniture first and then read the instructions, here are three easy
steps:
</P>
<P>
1. Create a new Excel <EM>workbook</EM> (i.e. file) using <CODE>new()</CODE>.
</P>
<P>
2. Add a <EM>worksheet</EM> to the new workbook using <CODE>addworksheet()</CODE>.
</P>
<P>
3. Write to the worksheet using <CODE>write()</CODE>.
</P>
<P>
Like this:
</P>
<P>
<PRE>
use Spreadsheet::WriteExcel; # Step 0
</PRE>
</P>
<P>
<PRE>
$workbook = Spreadsheet::WriteExcel->new("perl.xls"); # Step 1
$worksheet = $workbook->addworksheet(); # Step 2
$worksheet->write('A1', "Hi Excel!"); # Step 3
</PRE>
</P>
<P>
This will create an Excel file called <CODE>perl.xls</CODE> with a single worksheet and the text <CODE>"Hi Excel!"</CODE> in the relevant cell. And that's it. Okay, so there is actually a zeroth
step as well, but <CODE>use module</CODE> goes without saying. There are also more than 20 examples that come with
the distribution and which you can use to get you started. See <A HREF="#EXAMPLES">EXAMPLES</A>.
</P>
<P>
Those of you who read the instructions first and assemble the furniture
afterwards will know how to proceed. ;-)
</P>
<P>
<HR>
<H1><A NAME="WORKBOOK_METHODS">WORKBOOK METHODS</A></H1>
<P>
The Spreadsheet::WriteExcel module provides an object oriented interface to
a new Excel workbook. The following methods are available through a new
workbook.
</P>
<P>
<PRE>
new()
close()
addworksheet()
set_custom_color()
set_palette_xl5()
addformat()
sheets()
set_1904()
</PRE>
</P>
<P>
If you are unfamiliar with object oriented interfaces or the way that they
are implemented in Perl have a look at <CODE>perlobj</CODE> and <CODE>perltoot</CODE> in the main Perl documentation.
</P>
<P>
<HR>
<H2><A NAME="new_">new()</A></H2>
<P>
A new Excel workbook is created using the <CODE>new()</CODE> constructor which accepts either a filename or a filehandle as a parameter.
The following example creates a new Excel file based on a filename:
</P>
<P>
<PRE>
my $workbook = Spreadsheet::WriteExcel->new('filename.xls');
my $worksheet = $workbook->addworksheet();
$worksheet->write(0, 0, "Hi Excel!");
</PRE>
</P>
<P>
Here are some other examples of using <CODE>new()</CODE> with filenames:
</P>
<P>
<PRE>
my $workbook1 = Spreadsheet::WriteExcel->new($filename);
my $workbook2 = Spreadsheet::WriteExcel->new("/tmp/filename.xls");
my $workbook3 = Spreadsheet::WriteExcel->new("c:\\tmp\\filename.xls");
my $workbook4 = Spreadsheet::WriteExcel->new('c:\tmp\filename.xls');
</PRE>
</P>
<P>
The last two examples demonstrates how to create a file on DOS or Windows
where it is necessary to either escape the directory separator <CODE>\</CODE> or to use single quotes to ensure that it isn't interpolated. For more
information see <CODE>perlfaq5: Why can't I use "C:\temp\foo" in DOS paths?</CODE>.
</P>
<P>
The <CODE>new()</CODE> constructor returns a Spreadsheet::WriteExcel object that you can use to
add worksheets and store data. It should be noted that although <CODE>my</CODE> is not specifically required it defines the scope of the new workbook
variable and, in the majority of cases, ensures that the workbook is closed
properly without explicitly calling the <CODE>close()</CODE> method.
</P>
<P>
If the file cannot be created, due to file permissions or some other
reason, <CODE>new</CODE> will return <CODE>undef</CODE>. Therefore, it is good practice to check the return value of <CODE>new</CODE> before proceeding. As usual the Perl variable <CODE>$!</CODE> will be set if there is a file creation error. You will also see one of the
warning messages detailed in <A HREF="#DIAGNOSTICS">DIAGNOSTICS</A>:
</P>
<P>
<PRE>
my $workbook = Spreadsheet::WriteExcel->new('protected.xls');
die "Problems creating new Excel file: $!" unless defined $workbook;
</PRE>
</P>
<P>
You can also pass a valid filehandle to the <CODE>new()</CODE> constructor. For example in a CGI program you could do something like this:
</P>
<P>
<PRE>
binmode(STDOUT);
my $workbook = Spreadsheet::WriteExcel->new(\*STDOUT);
</PRE>
</P>
<P>
The requirement for <CODE>binmode()</CODE> is explained below.
</P>
<P>
For CGI programs you can also use the special Perl filename <CODE>'-'</CODE> which will redirect the output to STDOUT:
</P>
<P>
<PRE>
my $workbook = Spreadsheet::WriteExcel->new('-');
</PRE>
</P>
<P>
See also, the <CODE>cgi.pl</CODE> program in the <CODE>examples</CODE> directory of the distro. However, this special case will not work in <CODE>mod_perl</CODE> programs where you will have to do something like the following:
</P>
<P>
<PRE>
tie *XLS, 'Apache';
binmode(XLS);
my $workbook = Spreadsheet::WriteExcel->new(\*XLS);
</PRE>
</P>
<P>
Filehandles can also be useful if you want to stream an Excel file over a
socket or if you want to store an Excel file in a tied scalar. For some
examples of using filehandles with Spreadsheet::WriteExcel see the <CODE>filehandle.pl</CODE> program in the <CODE>examples</CODE> directory of the distro.
</P>
<P>
Note about the requirement for <CODE>binmode()</CODE>: An Excel file is comprised of binary data. Therefore, if you are using a
filehandle you should ensure that you <CODE>binmode()</CODE> it prior to passing it to <CODE>new()</CODE>.You can safely do this regardless of whether your platform requires it or
not. For more information about <CODE>binmode()</CODE> see <CODE>perlfunc</CODE> and <CODE>perlopentut</CODE> in the main Perl documentation. It is equally important to note that you do
not need to <CODE>binmode()</CODE> a filename. In fact it would cause an error. Spreadsheet::WriteExcel
performs the <CODE>binmode()</CODE> internally when it converts the filename to a filehandle.
</P>
<P>
<HR>
<H2><A NAME="close_">close()</A></H2>
<P>
The <CODE>close()</CODE> method can be used to explicitly close an Excel file.
</P>
<P>
<PRE>
$workbook->close();
</PRE>
</P>
<P>
An explicit <CODE>close()</CODE> is required if the file must be closed prior to performing some external
action on it such as copying it, reading its size or attaching it to an
email.
</P>
<P>
In addition, <CODE>close()</CODE> may be required if the scope of the Workbook, Worksheet or Format objects
cannot be determined by perl. Situations where this can occur are:
</P>
<UL>
<LI><A NAME="item_If">If my() was not used to declare the scope of a workbook variable created using new().</A>
<LI><A NAME="item_If">If the new(), addworksheet() or addformat() methods are called in subroutines.</A>
</UL>
<P>
The reason for this is that Spreadsheet::WriteExcel relies on Perl's <CODE>DESTROY</CODE> mechanism to trigger destructor methods in a specific sequence. This will
not happen if the scope of the variables cannot be determined.
</P>
<P>
In general, if you create a file with a size of 0 bytes or you fail to
create a file you need to call <CODE>close()</CODE>.
</P>
<P>
<HR>
<H2><A NAME="addworksheet_sheetname_">addworksheet($sheetname)</A></H2>
<P>
At least one worksheet should be added to a new workbook. A worksheet is
used to write data into cells:
</P>
<P>
<PRE>
$worksheet1 = $workbook->addworksheet(); # Sheet1
$worksheet2 = $workbook->addworksheet('Foglio2'); # Foglio2
$worksheet3 = $workbook->addworksheet('Data'); # Data
$worksheet4 = $workbook->addworksheet(); # Sheet4
</PRE>
</P>
<P>
If <CODE>$sheetname</CODE> is not specified the default Excel convention will be followed, i.e.
Sheet1, Sheet2, etc.
</P>
<P>
Note, you cannot use the same sheet name in more than one worksheet.
</P>
<P>
<HR>
<H2><A NAME="addformat_properties_">addformat(%properties)</A></H2>
<P>
The <CODE>addformat()</CODE> method can be used to create new Format objects which are used to apply
formatting to a cell. You can either define the properties at creation time
via a hash of property values or later via method calls.
</P>
<P>
<PRE>
$format1 = $workbook->addformat(%props); # Set properties at creation
$format2 = $workbook->addformat(); # Set properties later
</PRE>
</P>
<P>
See the <A HREF="#CELL_FORMATTING">CELL FORMATTING</A> section for more details about Format properties and how to set them.
</P>
<P>
<HR>
<H2><A NAME="set_custom_color_index_red_">set_custom_color($index, $red, $green, $blue)</A></H2>
<P>
The <CODE>set_custom_color()</CODE> method can be used to override one of the built-in palette values with a
more suitable colour.
</P>
<P>
The value for <CODE>$index</CODE> should be in the range 8..63, see <A HREF="#COLOURS_IN_EXCEL">COLOURS IN EXCEL</A>.
</P>
<P>
The default named colours use the following indices:
</P>
<P>
<PRE>
8 => black
9 => white
10 => red
11 => lime
12 => blue
13 => yellow
14 => magenta
15 => cyan
16 => brown
17 => green
18 => navy
20 => purple
22 => silver
23 => gray
53 => orange
</PRE>
</P>
<P>
A new colour is set using its RGB (red green blue) components. The <CODE>$red</CODE>, <CODE>$green</CODE> and <CODE>$blue</CODE> values must be in the range 0..255. You can determine the required values
in Excel using the <CODE>Tools->Options->Colors->Modify</CODE> dialog.
</P>
<P>
The <CODE>set_custom_color()</CODE> workbook method can also be used with a HTML style <CODE>#zzyyzz</CODE> hex value:
</P>
<P>
<PRE>
$workbook->set_custom_color(40, 255, 102, 0 ); # Orange
$workbook->set_custom_color(40, 0xFF, 0x66, 0x00); # Same thing
$workbook->set_custom_color(40, '#FF6600' ); # Same thing
my $font = $workbook->addformat(color => 40); # Use the modified colour
</PRE>
</P>
<P>
The return value from <CODE>set_custom_color()</CODE> is the index of the colour that was changed:
</P>
<P>
<PRE>
my $ferrari = $workbook->set_custom_color(40, 216, 12, 12);
</PRE>
</P>
<P>
<PRE>
my $format = $workbook->addformat(
fg_color => $ferrari,
pattern => 1,
border => 1
);
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_palette_xl5_">set_palette_xl5()</A></H2>
<P>
Prior to this version (0.36), Spreadsheet::WriteExcel used the Excel 5
default colour palette. It has been changed to the Excel 97+ palette for
future compatibility.
</P>
<P>
However, if you have programs that rely on the colours and indices of the
Excel 5 palette you can revert to the previous default by using the <CODE>set_palette_xl5()</CODE> method:
</P>
<P>
<PRE>
$workbook->set_palette_xl5();
</PRE>
</P>
<P>
A comparison of the colour components in the Excel 5 and Excel 97+ colour
palettes is shown in <CODE>rgb5-97.txt</CODE> in the <CODE>doc</CODE> directory of the distro.
</P>
<P>
See also <A HREF="#COLOURS_IN_EXCEL">COLOURS IN EXCEL</A>.
</P>
<P>
<HR>
<H2><A NAME="sheets_">sheets()</A></H2>
<P>
The <CODE>sheets()</CODE> method returns a list of the worksheets in a workbook. This can be useful
if you want to repeat an operation on each worksheet in a workbook or if
you wish to refer to a worksheet by its index:
</P>
<P>
<PRE>
foreach $worksheet ($workbook->sheets()) {
print $worksheet->get_name();
}
# or:
($workbook->sheets())[5]->write('A1', "Hello");
</PRE>
</P>
<P>
Note: This functionality was previously available via the <CODE>worksheets()</CODE> method which returned an array ref. This was unnecessarily complicated. The <CODE>worksheets()</CODE> method is still available but deprecated.
</P>
<P>
<HR>
<H2><A NAME="set_1904_">set_1904()</A></H2>
<P>
Excel stores dates as real numbers where the integer part stores the number
of days since the epoch and the fractional part stores the percentage of
the day. The epoch can be either 1900 or 1904. Excel for Windows uses 1900
and Excel for Macintosh uses 1904. However, Excel on either platform will
convert automatically between one system and the other.
</P>
<P>
Spreadsheet::WriteExcel stores dates in the 1900 format by default. If you
wish to change this you can call the <CODE>set_1904()</CODE> workbook method. You can query the current value by calling the <CODE>get_1904()</CODE> workbook method. This returns 0 for 1900 and 1 for 1904.
</P>
<P>
See also <A HREF="#Dates_in_Excel">Dates in Excel</A> for more information about working with Excel's date system.
</P>
<P>
In general you probably won't need to use <CODE>set_1904()</CODE>.
</P>
<P>
<HR>
<H1><A NAME="WORKSHEET_METHODS">WORKSHEET METHODS</A></H1>
<P>
A new worksheet is created by calling the <CODE>addworksheet()</CODE> method from a workbook object:
</P>
<P>
<PRE>
$worksheet1 = $workbook->addworksheet();
$worksheet2 = $workbook->addworksheet();
</PRE>
</P>
<P>
The following methods are available through a new worksheet:
</P>
<P>
<PRE>
write()
write_row()
write_col()
write_number()
write_string()
write_formula()
write_blank()
write_url()
write_url_range()
insert_bitmap()
get_name()
activate()
select()
protect()
set_first_sheet()
set_selection()
set_row()
set_column()
freeze_panes()
thaw_panes()
merge_cells()
set_zoom()
</PRE>
</P>
<P>
<HR>
<H2><A NAME="Cell_notation">Cell notation</A></H2>
<P>
Spreadsheet::WriteExcel supports two forms of notation to designate the
position of cells: Row-column notation and A1 notation.
</P>
<P>
Row-column notation uses a zero based index for both row and column while
A1 notation uses the standard Excel alphanumeric sequence of column letter
and 1-based row. For example:
</P>
<P>
<PRE>
(0, 0) # The top left cell in row-column notation.
('A1') # The top left cell in A1 notation.
</PRE>
</P>
<P>
<PRE>
(1999, 29) # Row-column notation.
('AD2000') # The same cell in A1 notation.
</PRE>
</P>
<P>
Row-column notation is useful if you are referring to cells
programmatically:
</P>
<P>
<PRE>
for my $i (0 .. 9) {
$worksheet->write($i, 0, 'Hello'); # Cells A1 to A10
}
</PRE>
</P>
<P>
A1 notation is useful for setting up a worksheet manually and for working
with formulas:
</P>
<P>
<PRE>
$worksheet->write('H1', 200);
$worksheet->write('H2', '=H1+1');
</PRE>
</P>
<P>
The <CODE>Spreadsheet::WriteExcel::Utility</CODE> module that is included in the distro contains helper functions for dealing
with A1 notation, for example:
</P>
<P>
<PRE>
use Spreadsheet::WriteExcel::Utility;
($row, $col) = xl_cell_to_rowcol('C2'); # (1, 2)
$str = xl_rowcol_to_cell(1, 2); # C2
</PRE>
</P>
<P>
For simplicity, the parameter lists for the worksheet method calls in the
following sections are given in terms of row-column notation. In all cases
it is also possible to use A1 notation.
</P>
<P>
<HR>
<H2><A NAME="write_row_column_token_fo">write($row, $column, $token, $format)</A></H2>
<P>
Excel distinguishes between data types such as strings, numbers, blanks,
formulas and hyperlinks. To simplify the process of writing data <CODE>Spreadsheet::WriteExcel</CODE> provides the <CODE>write()</CODE> method as a general alias to several more specific methods for writing to a
cell in Excel:
</P>
<P>
<PRE>
write_string()
write_number()
write_blank()
write_formula()
write_url()
write_row()
write_col()
</PRE>
</P>
<P>
Here are some examples in both row-column and A1 notation:
</P>
<P>
<PRE>
# Same as:
$worksheet->write(0, 0, "Hello" ); # write_string()
$worksheet->write(1, 0, 'One' ); # write_string()
$worksheet->write(2, 0, 2 ); # write_number()
$worksheet->write(3, 0, 3.00001 ); # write_number()
$worksheet->write(4, 0, "" ); # write_blank()
$worksheet->write(5, 0, '' ); # write_blank()
$worksheet->write(6, 0, undef ); # write_blank()
$worksheet->write(7, 0 ); # write_blank()
$worksheet->write(8, 0, '<A HREF="http://www.perl.com/">http://www.perl.com/</A>'); # write_url()
$worksheet->write('A9', '<A HREF="ftp://ftp.cpan.org/">ftp://ftp.cpan.org/</A>' ); # write_url()
$worksheet->write('A10', 'internal:Sheet1!A1' ); # write_url()
$worksheet->write('A11', 'external:c:\foo.xls' ); # write_url()
$worksheet->write('A12', '=A3 + 3*A4' ); # write_formula()
$worksheet->write('A13', '=SIN(PI()/4)' ); # write_formula()
$worksheet->write('A14', \@array ); # write_row()
$worksheet->write('A15', [\@array] ); # write_col()
</PRE>
</P>
<P>
The general rule is that if it looks like a <EM>something</EM> then a <EM>something</EM> is written. The "looks like" is defined by regular expressions:
</P>
<P>
<CODE>write_number()</CODE> if <CODE>$token</CODE> is a number based on the following regex: <CODE>$token =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/</CODE>.
</P>
<P>
<CODE>write_blank()</CODE> if <CODE>$token</CODE> is undef or a blank string: <CODE>undef</CODE>, <CODE>""</CODE> or <CODE>''</CODE>.
</P>
<P>
<CODE>write_url()</CODE> if <CODE>$token</CODE> is a http, ftp or mailto URL based on the following regexes: <CODE>$token =~ m|^[fh]tt?p://|</CODE> or <CODE>$token =~ m|^mailto:|</CODE>.
</P>
<P>
<CODE>write_url()</CODE> if <CODE>$token</CODE> is an internal or external sheet reference based on the following regex: <CODE>$token =~ m[^(in|ex)ternal:]</CODE>.
</P>
<P>
<CODE>write_formula()</CODE> if the first character of <CODE>$token</CODE> is <CODE>"="</CODE>.
</P>
<P>
<CODE>write_row()</CODE> if <CODE>$token</CODE> is an array ref.
</P>
<P>
<CODE>write_col()</CODE> if <CODE>$token</CODE> is an array ref of array refs.
</P>
<P>
<CODE>write_string()</CODE> if none of the previous conditions apply.
</P>
<P>
The <CODE>$format</CODE> parameter is optional. It should be a valid Format object, see <A HREF="#CELL_FORMATTING">CELL FORMATTING</A>:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_bold();
$format->set_color('red');
$format->set_align('center');
</PRE>
</P>
<P>
<PRE>
$worksheet->write(4, 0, "Hello", $format ); # Formatted string
</PRE>
</P>
<P>
The <CODE>write()</CODE> method will ignore empty string or <CODE>undef</CODE> tokens unless a format is also supplied. As such you needn't worry about
special handling for empty or <CODE>undef</CODE> values in your data. See also the the <CODE>write_blank()</CODE> method.
</P>
<P>
One problem with the <CODE>write()</CODE> method is that occasionally data looks like a number but you don't want it
treated as a number. For example, zip codes or phone numbers often start
with a leading zero. If you write it as a number then the leading
<CODE>zero(s)</CODE> will be stripped. To get around this you can either
write the number with a number format or explicitly write the number as a
string:
</P>
<P>
<PRE>
# Write as a number (1209)
$worksheet->write('A1', '01209');
</PRE>
</P>
<P>
<PRE>
# Format as a number (01209)
my $format1 = $workbook->addformat(num_format => '00000');
$worksheet->write('A2', '01209', $format1);
</PRE>
</P>
<P>
<PRE>
# Write as a string (01209)
$worksheet->write_string('A3', '01209');
</PRE>
</P>
<P>
However, if the user edits the string in the last example it will convert
back to a number. To get around this you can use the Excel text format <CODE>@</CODE>:
</P>
<P>
<PRE>
# Format as a string (01209)
my $format2 = $workbook->addformat(num_format => '@');
$worksheet->write_string('A4', '01209', $format2);
</PRE>
</P>
<P>
Note also that Excel writes strings with a left justification and numbers
with a right justification by default.
</P>
<P>
The <CODE>write</CODE> methods return:
</P>
<P>
<PRE>
0 for success.
-1 for insufficient number of arguments.
-2 for row or column out of bounds.
-3 for string too long.
</PRE>
</P>
<P>
<HR>
<H2><A NAME="write_number_row_column_num">write_number($row, $column, $number, $format)</A></H2>
<P>
Write an integer or a float to the cell specified by <CODE>$row</CODE> and <CODE>$column</CODE>:
</P>
<P>
<PRE>
$worksheet->write_number(0, 0, 123456);
$worksheet->write_number('A2', 2.3451);
</PRE>
</P>
<P>
See the note about <A HREF="#Cell_notation">Cell notation</A>. The <CODE>$format</CODE> parameter is optional.
</P>
<P>
In general it is sufficient to use the <CODE>write()</CODE> method.
</P>
<P>
<HR>
<H2><A NAME="write_string_row_column_str">write_string($row, $column, $string, $format)</A></H2>
<P>
Write a string to the cell specified by <CODE>$row</CODE> and <CODE>$column</CODE>:
</P>
<P>
<PRE>
$worksheet->write_string(0, 0, "Your text here" );
$worksheet->write_string('A2', "or here" );
</PRE>
</P>
<P>
The maximum string size is 255 characters. The <CODE>$format</CODE> parameter is optional.
</P>
<P>
In general it is sufficient to use the <CODE>write()</CODE> method. However, you may sometimes wish to use the <CODE>write_string()</CODE> method to write data that looks like a number but that you don't want
treated as a number. For example, zip codes or phone numbers:
</P>
<P>
<PRE>
# Write as a plain string
$worksheet->write_string('A1', '01209');
</PRE>
</P>
<P>
However, if the user edits this string Excel may convert it back to a
number. To get around this you can use the Excel text format <CODE>@</CODE>:
</P>
<P>
<PRE>
# Format as a string. Doesn't change to a number when edited
my $format1 = $workbook->addformat(num_format => '@');
$worksheet->write_string('A2', '01209', $format1);
</PRE>
</P>
<P>
See also the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
<HR>
<H2><A NAME="write_formula_row_column_fo">write_formula($row, $column, $formula, $format)</A></H2>
<P>
Write a formula or function to the cell specified by <CODE>$row</CODE> and <CODE>$column</CODE>:
</P>
<P>
<PRE>
$worksheet->write_formula(0, 0, '=$B$3 + B4' );
$worksheet->write_formula(1, 0, '=SIN(PI()/4)');
$worksheet->write_formula(2, 0, '=SUM(B1:B5)' );
$worksheet->write_formula('A4', '=IF(A3>1,"Yes", "No")' );
$worksheet->write_formula('A5', '=AVERAGE(1, 2, 3, 4)' );
$worksheet->write_formula('A6', '=DATEVALUE("1-Jan-2001")');
</PRE>
</P>
<P>
See the note about <A HREF="#Cell_notation">Cell notation</A>. For more information about writing Excel formulas see <A HREF="#FORMULAS_AND_FUNCTIONS_IN_EXCEL">FORMULAS AND FUNCTIONS IN EXCEL</A>
</P>
<P>
In general it is sufficient to use the <CODE>write()</CODE> method.
</P>
<P>
<HR>
<H2><A NAME="write_blank_row_column_form">write_blank($row, $column, $format)</A></H2>
<P>
Write a blank cell specified by <CODE>$row</CODE> and <CODE>$column</CODE>:
</P>
<P>
<PRE>
$worksheet->write_blank(0, 0, $format);
</PRE>
</P>
<P>
This method is used to add formatting to a cell which doesn't contain a
string or number value.
</P>
<P>
Excel differentiates between an "Empty" cell and a
"Blank" cell. An "Empty" cell is a cell which doesn't
contain data whilst a "Blank" cell is a cell which doesn't
contain data but does contain formatting. Excel stores "Blank"
cells but ignores "Empty" cells.
</P>
<P>
As such, if you write an empty cell without formatting it is ignored:
</P>
<P>
<PRE>
$worksheet->write('A1', undef, $format); # write_blank()
$worksheet->write('A2', undef ); # Ignored
</PRE>
</P>
<P>
This seemingly uninteresting fact means that you can write arrays of data
without special treatment for undef or empty string values.
</P>
<P>
See the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
<HR>
<H2><A NAME="write_row_row_column_array_">write_row($row, $column, $array_ref, $format)</A></H2>
<P>
The <CODE>write_row()</CODE> method can be used to write a 1D or 2D array or data in one go. This is
useful for converting the results of a database query into an Excel
worksheet. You must pass a reference to the array of data rather than the
array itself. The <CODE>write()</CODE> method is then called for each element of the data. For example:
</P>
<P>
<PRE>
@array = ('awk', 'gawk', 'mawk');
$array_ref = \@array;
$worksheet->write_row(0, 0, $array_ref);
# The above example is equivalent to:
$worksheet->write(0, 0, $array[0]);
$worksheet->write(0, 1, $array[1]);
$worksheet->write(0, 2, $array[2]);
</PRE>
</P>
<P>
Note: For convenience the <CODE>write()</CODE> method behaves in the same way as <CODE>write_row()</CODE> if it is passed an array reference. Therefore the following two method
calls are equivalent:
</P>
<P>
<PRE>
$worksheet->write_row('A1', $array_ref); # Write a row of data
$worksheet->write( 'A1', $array_ref); # Same thing
</PRE>
</P>
<P>
As with all of the write methods the <CODE>$format</CODE> parameter is optional. If a format is specified it is applied to all the
elements of the data array.
</P>
<P>
Array references within the data will be treated as columns. This allows
you to write 2D arrays of data in one go. For example:
</P>
<P>
<PRE>
@eec = (
['maggie', 'milly', 'molly', 'may' ],
[13, 14, 15, 16 ],
['shell', 'star', 'crab', 'stone']
);
$worksheet->write_row('A1', \@eec);
</PRE>
</P>
<P>
Would produce a worksheet as follows:
</P>
<P>
<PRE>
-----------------------------------------------------------
| | A | B | C | D | E | ...
-----------------------------------------------------------
| 1 | maggie | 13 | shell | ... | ... | ...
| 2 | milly | 14 | star | ... | ... | ...
| 3 | molly | 15 | crab | ... | ... | ...
| 4 | may | 16 | stone | ... | ... | ...
| 5 | ... | ... | ... | ... | ... | ...
| 6 | ... | ... | ... | ... | ... | ...
</PRE>
</P>
<P>
To write the data in a row-column order refer to the <CODE>write_col()</CODE> method below.
</P>
<P>
Any <CODE>undef</CODE> values in the data will be ignored unless a format is applied to the data,
in which case a formatted blank cell will be written. In either case the
appropriate row or column value will still be incremented.
</P>
<P>
To find out more about array references refer to <CODE>perlref</CODE> and <CODE>perlreftut</CODE> in the main Perl documentation. To find out more about 2D arrays or
"lists of lists" refer to <CODE>perllol</CODE>.
</P>
<P>
The <CODE>write_row()</CODE> method returns the first error encountered when writing the elements of the
data or zero if no errors were encountered. See the return values described
for the <CODE>write()</CODE> method above.
</P>
<P>
See also the <CODE>write_arrays.pl</CODE> program in the <CODE>examples</CODE> directory of the distro.
</P>
<P>
<HR>
<H2><A NAME="write_col_row_column_array_">write_col($row, $column, $array_ref, $format)</A></H2>
<P>
The <CODE>write_col()</CODE> method can be used to write a 1D or 2D array or data in one go. This is
useful for converting the results of a database query into an Excel
worksheet. You must pass a reference to the array of data rather than the
array itself. The <CODE>write()</CODE> method is then called for each element of the data. For example:
</P>
<P>
<PRE>
@array = ('awk', 'gawk', 'mawk');
$array_ref = \@array;
$worksheet->write_col(0, 0, $array_ref);
# The above example is equivalent to:
$worksheet->write(0, 0, $array[0]);
$worksheet->write(1, 0, $array[1]);
$worksheet->write(2, 0, $array[2]);
</PRE>
</P>
<P>
As with all of the write methods the <CODE>$format</CODE> parameter is optional. If a format is specified it is applied to all the
elements of the data array.
</P>
<P>
Array references within the data will be treated as rows. This allows you
to write 2D arrays of data in one go. For example:
</P>
<P>
<PRE>
@eec = (
['maggie', 'milly', 'molly', 'may' ],
[13, 14, 15, 16 ],
['shell', 'star', 'crab', 'stone']
);
$worksheet->write_col('A1', \@eec);
</PRE>
</P>
<P>
Would produce a worksheet as follows:
</P>
<P>
<PRE>
-----------------------------------------------------------
| | A | B | C | D | E | ...
-----------------------------------------------------------
| 1 | maggie | milly | molly | may | ... | ...
| 2 | 13 | 14 | 15 | 16 | ... | ...
| 3 | shell | star | crab | stone | ... | ...
| 4 | ... | ... | ... | ... | ... | ...
| 5 | ... | ... | ... | ... | ... | ...
| 6 | ... | ... | ... | ... | ... | ...
</PRE>
</P>
<P>
To write the data in a column-row order refer to the <CODE>write_row()</CODE> method above.
</P>
<P>
Any <CODE>undef</CODE> values in the data will be ignored unless a format is applied to the data,
in which case a formatted blank cell will be written. In either case the
appropriate row or column value will still be incremented.
</P>
<P>
As noted above the <CODE>write()</CODE> method can be used as a synonym for <CODE>write_row()</CODE> and <CODE>write_row()</CODE> handles nested array refs as columns. Therefore, the following two method
calls are equivalent although the more explicit call to <CODE>write_col()</CODE> would be preferable for maintainability:
</P>
<P>
<PRE>
$worksheet->write_col('A1', $array_ref ); # Write a column of data
$worksheet->write( 'A1', [ $array_ref ]); # Same thing
</PRE>
</P>
<P>
To find out more about array references refer to <CODE>perlref</CODE> and <CODE>perlreftut</CODE> in the main Perl documentation. To find out more about 2D arrays or
"lists of lists" refer to <CODE>perllol</CODE>.
</P>
<P>
The <CODE>write_col()</CODE> method returns the first error encountered when writing the elements of the
data or zero if no errors were encountered. See the return values described
for the <CODE>write()</CODE> method above.
</P>
<P>
See also the <CODE>write_arrays.pl</CODE> program in the <CODE>examples</CODE> directory of the distro.
</P>
<P>
<HR>
<H2><A NAME="write_url_row_col_url_str">write_url($row, $col, $url, $string, $format)</A></H2>
<P>
Write a hyperlink to a URL in the cell specified by <CODE>$row</CODE> and <CODE>$column</CODE>. The hyperlink is comprised of two elements: the visible label and the
invisible link. The visible label is the same as the link unless an
alternative string is specified. The parameters <CODE>$string</CODE> and the <CODE>$format</CODE> are optional and their position is interchangeable.
</P>
<P>
The label is written using the <CODE>write_string()</CODE> method. Therefore the 255 characters string limit applies to the label: the
URL can be any length.
</P>
<P>
There are three web style URI's supported: <CODE>http://</CODE>, <CODE>ftp://</CODE> and <CODE>mailto:</CODE>:
</P>
<P>
<PRE>
$worksheet->write_url(0, 0, '<A HREF="ftp://www.perl.org/">ftp://www.perl.org/</A>' );
$worksheet->write_url(1, 0, '<A HREF="http://www.perl.com/">http://www.perl.com/</A>', 'Perl home' );
$worksheet->write_url('A3', '<A HREF="http://www.perl.com/">http://www.perl.com/</A>', $format );
$worksheet->write_url('A4', '<A HREF="http://www.perl.com/">http://www.perl.com/</A>', 'Perl', $format);
$worksheet->write_url('A5', '<A HREF="mailto:jmcnamara@cpan.org">mailto:jmcnamara@cpan.org</A>' );
</PRE>
</P>
<P>
There are two local URIs supported: <CODE>internal:</CODE> and <CODE>external:</CODE>. These are used for hyperlinks to internal worksheet references or
external workbook and worksheet references:
</P>
<P>
<PRE>
$worksheet->write_url('A6', 'internal:Sheet2!A1' );
$worksheet->write_url('A7', 'internal:Sheet2!A1', $format );
$worksheet->write_url('A8', 'internal:Sheet2!A1:B2' );
$worksheet->write_url('A9', q{internal:'Sales Data'!A1} );
$worksheet->write_url('A10', 'external:c:\temp\foo.xls' );
$worksheet->write_url('A11', 'external:c:\temp\foo.xls#Sheet2!A1' );
$worksheet->write_url('A12', 'external:..\..\..\foo.xls' );
$worksheet->write_url('A13', 'external:..\..\..\foo.xls#Sheet2!A1' );
$worksheet->write_url('A13', 'external:\\\\NETWORK\share\foo.xls' );
</PRE>
</P>
<P>
All of the these URI types are recognised by the <CODE>write()</CODE> method, see above.
</P>
<P>
Worksheet references are typically of the form <CODE>Sheet1!A1</CODE>. You can also refer to a worksheet range using the standard Excel
notation: <CODE>Sheet1!A1:B2</CODE>.
</P>
<P>
In external links the workbook and worksheet name must be separated by the <CODE>#</CODE> character: <CODE>external:Workbook.xls#Sheet1!A1'</CODE>.
</P>
<P>
You can also link to a named range in the target worksheet. For example say
you have a named range called <CODE>my_name</CODE> in the workbook <CODE>c:\temp\foo.xls</CODE> you could link to it as follows:
</P>
<P>
<PRE>
$worksheet->write_url('A14', 'external:c:\temp\foo.xls#my_name');
</PRE>
</P>
<P>
Note, you cannot currently create named ranges with <CODE>Spreadsheet::WriteExcel</CODE>.
</P>
<P>
Excel requires that worksheet names containing spaces or non alphanumeric
characters are single quoted as follows <CODE>'Sales Data'!A1</CODE>. If you need to do this in a single quoted string then you can either
escape the single quotes <CODE>\'</CODE> or use the quote operator <CODE>q{}</CODE> as described in <CODE>perlop</CODE> in the main Perl documentation.
</P>
<P>
Links to network files are also supported. MS/Novell Network files normally
begin with two back slashes as follows <CODE>\\NETWORK\etc</CODE>. In order to generate this in a single or double quoted string you will
have to escape the backslashes, <CODE>'\\\\NETWORK\etc'</CODE>.
</P>
<P>
If you are using double quote strings then you should be careful to escape
anything that looks like a metacharacter. For more information see <CODE>perlfaq5: Why can't I use "C:\temp\foo" in DOS paths?</CODE>.
</P>
<P>
Finally, you can avoid most of these quoting problems by using forward
slashes. These are translated internally to backslashes:
</P>
<P>
<PRE>
$worksheet->write_url('A14', "external:c:/temp/foo.xls" );
$worksheet->write_url('A15', 'external://NETWORK/share/foo.xls' );
</PRE>
</P>
<P>
Note: Hyperlinks are not available in Excel 5. They will appear as a string
only.
</P>
<P>
See also, the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
<HR>
<H2><A NAME="write_url_range_row1_col1_r">write_url_range($row1, $col1, $row2, $col2, $url, $string, $format)</A></H2>
<P>
This method is essentially the same as the <CODE>write_url()</CODE> method described above. The main difference is that you can specify that
the link is available for a range of cells:
</P>
<P>
<PRE>
$worksheet->write_url(0, 0, 0, 3, '<A HREF="ftp://www.perl.org/">ftp://www.perl.org/</A>' );
$worksheet->write_url(1, 0, 0, 3, '<A HREF="http://www.perl.com/">http://www.perl.com/</A>', 'Perl home');
$worksheet->write_url('A3:D3', 'internal:Sheet2!A1' );
$worksheet->write_url('A4:D4', 'external:c:\temp\foo.xls' );
</PRE>
</P>
<P>
This method is generally only required when used in conjunction with merged
cells. See the <CODE>merge_cells()</CODE> method and the <CODE>merge</CODE> property of a Format object, <A HREF="#CELL_FORMATTING">CELL FORMATTING</A>.
</P>
<P>
There is no way to force this behaviour through the <CODE>write()</CODE> method.
</P>
<P>
The parameters <CODE>$string</CODE> and the <CODE>$format</CODE> are optional and their position is interchangeable. However, they are
applied only to the first cell in the range.
</P>
<P>
Note: Hyperlinks are not available in Excel 5. They will appear as a string
only.
</P>
<P>
See also, the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
<HR>
<H2><A NAME="insert_bitmap_row_col_filen">insert_bitmap($row, $col, $filename, $x, $y, $scale_x, $scale_y)</A></H2>
<P>
This method can be used to insert a bitmap into a worksheet. The bitmap
must be a 24 bit, true colour, bitmap. No other format is supported. The <CODE>$x</CODE>, <CODE>$y</CODE>, <CODE>$scale_x</CODE> and <CODE>$scale_y</CODE> parameters are optional.
</P>
<P>
<PRE>
$worksheet1->insert_bitmap('A1', 'perl.bmp');
$worksheet2->insert_bitmap('A1', '../images/perl.bmp');
$worksheet3->insert_bitmap('A1', '.c:\images\perl.bmp');
</PRE>
</P>
<P>
Note: you must call <CODE>set_row()</CODE> or <CODE>set_column()</CODE> before <CODE>insert_bitmap()</CODE> if you wish to change the default dimensions of any of the rows or columns
that the images occupies. Also, if you use large fonts then the height of
the row that they occupy may change automatically. This in turn could
affect the scaling of your image. To avoid this you should explicitly set
the height of the row using <CODE>set_row()</CODE>.
</P>
<P>
The parameters <CODE>$x</CODE> and <CODE>$y</CODE> can be used to specify an offset from the top left hand corner of the the
cell specified by <CODE>$row</CODE> and <CODE>$col</CODE>. The offset values are in pixels.
</P>
<P>
<PRE>
$worksheet1->insert_bitmap('A1', 'perl.bmp', 32, 10);
</PRE>
</P>
<P>
The default width of a cell is 63 pixels. The default height of a cell is
17 pixels. The offsets are ignored if they are greater than the width or
height of the underlying cell.
</P>
<P>
The pixels offsets can be calculated using the following relationships:
</P>
<P>
<PRE>
Wp = 7We +5
Hp = 4/3He
</PRE>
</P>
<P>
<PRE>
where:
We is the cell width in Excels units
Wp is width in pixels
He is the cell height in Excels units
Hp is height in pixels
</PRE>
</P>
<P>
The parameters <CODE>$scale_x</CODE> and <CODE>$scale_y</CODE> can be used to scale the inserted image horizontally and vertically:
</P>
<P>
<PRE>
# Scale the inserted image: width x 2.0, height x 0.8
$worksheet->insert_bitmap('A1', 'perl.bmp', 0, 0, 2, 0.8);
</PRE>
</P>
<P>
Note: although Excel allows you to import several graphics formats such as
gif, jpeg, png and eps these are converted internally into a proprietary
format. One of the few non-proprietary formats that Excel supports is 24
bit, true colour, bitmaps. Therefore if you wish to use images in any other
format you must first use an external application such as
ImageMagick/Perl::Magick to convert them to 24 bit bitmaps.
</P>
<P>
A later release will support the use of file handles and pre-encoded bitmap
strings.
</P>
<P>
See also the <CODE>images.pl</CODE> program in the <CODE>examples</CODE> directory of the distro.
</P>
<P>
<HR>
<H2><A NAME="get_name_">get_name()</A></H2>
<P>
The <CODE>get_name()</CODE> method is used to retrieve the name of a worksheet. For example:
</P>
<P>
<PRE>
foreach my $sheet ($workbook->sheets()) {
print $sheet->get_name();
}
</PRE>
</P>
<P>
<HR>
<H2><A NAME="activate_">activate()</A></H2>
<P>
The <CODE>activate()</CODE> method is used to specify which worksheet is initially visible in a
multi-sheet workbook:
</P>
<P>
<PRE>
$worksheet1 = $workbook->addworksheet('To');
$worksheet2 = $workbook->addworksheet('the');
$worksheet3 = $workbook->addworksheet('wind');
</PRE>
</P>
<P>
<PRE>
$worksheet3->activate();
</PRE>
</P>
<P>
This is similar to the Excel VBA activate method. More than one worksheet
can be selected via the <CODE>select()</CODE> method, however only one worksheet can be active. The default value is the
first worksheet.
</P>
<P>
<HR>
<H2><A NAME="select_">select()</A></H2>
<P>
The <CODE>select()</CODE> method is used to indicate that a worksheet is selected in a multi-sheet
workbook:
</P>
<P>
<PRE>
$worksheet1->activate();
$worksheet2->select();
$worksheet3->select();
</PRE>
</P>
<P>
A selected worksheet has its tab highlighted. Selecting worksheets is a way
of grouping them together so that, for example, several worksheets could be
printed in one go. A worksheet that has been activated via the <CODE>activate()</CODE> method will also appear as selected. You probably won't need to use the <CODE>select()</CODE> method very often.
</P>
<P>
<HR>
<H2><A NAME="set_first_sheet_">set_first_sheet()</A></H2>
<P>
The <CODE>activate()</CODE> method determines which worksheet is initially selected. However, if there
are a large number of worksheets the selected worksheet may not appear on
the screen. To avoid this you can select which is the leftmost visible
worksheet using <CODE>set_first_sheet()</CODE>:
</P>
<P>
<PRE>
for (1..20) {
$workbook->addworksheet;
}
</PRE>
</P>
<P>
<PRE>
$worksheet21 = $workbook->addworksheet();
$worksheet22 = $workbook->addworksheet();
</PRE>
</P>
<P>
<PRE>
$worksheet21->set_first_sheet();
$worksheet22->activate();
</PRE>
</P>
<P>
This method is not required very often. The default value is the first
worksheet.
</P>
<P>
<HR>
<H2><A NAME="protect_password_">protect($password)</A></H2>
<P>
The <CODE>protect()</CODE> method is used to protect a worksheet from modification:
</P>
<P>
<PRE>
$worksheet->protect();
</PRE>
</P>
<P>
It can be turned off in Excel via the <CODE>Tools->Protection->Unprotect Sheet</CODE> menu command.
</P>
<P>
The <CODE>protect()</CODE> method also has the effect of enabling a cell's <CODE>locked</CODE> and <CODE>hidden</CODE> properties if they have been set. A "locked" cell cannot be
edited. A "hidden" cell will display the results of a formula but
not the formula itself. In Excel a cell's locked property is on by default.
</P>
<P>
<PRE>
# Set some format properties
my $unlocked = $workbook->addformat(locked => 0);
my $hidden = $workbook->addformat(hidden => 1);
# Enable worksheet protection
$worksheet->protect();
# This cell cannot be edited, it is locked by default
$worksheet->write('A1', '=1+2');
# This cell can be edited
$worksheet->write('A2', '=1+2', $unlocked);
# The formula in this cell isn't visible
$worksheet->write('A3', '=1+2', $hidden);
</PRE>
</P>
<P>
See also the <CODE>set_locked</CODE> and <CODE>set_hidden</CODE> format methods in <A HREF="#CELL_FORMATTING">CELL FORMATTING</A>.
</P>
<P>
You can optionally add a password to the worksheet protection:
</P>
<P>
<PRE>
$worksheet->protect('drowssap');
</PRE>
</P>
<P>
Note, the worksheet level password in Excel provides very weak protection.
It does not encrypt your data in any way and it is very easy to deactivate.
Therefore, do not use the above method if you wish to protect sensitive
data or calculations. However, before you get worried, Excel's own workbook
level password protection does provide strong encryption in Excel 97+. For
technical reasons this will never be supported by <CODE>Spreadsheet::WriteExcel</CODE>.
</P>
<P>
<HR>
<H2><A NAME="set_selection_first_row_first">set_selection($first_row, $first_col, $last_row, $last_col)</A></H2>
<P>
This method can be used to specify which cell or cells are selected in a
worksheet. The most common requirement is to select a single cell, in which
case <CODE>$last_row</CODE> and <CODE>$last_col</CODE> can be omitted. The active cell within a selected range is determined by
the order in which <CODE>$first</CODE> and <CODE>$last</CODE> are specified. It is also possible to specify a cell or a range using A1
notation. See the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
Examples:
</P>
<P>
<PRE>
$worksheet1->set_selection(3, 3); # 1. Cell D4.
$worksheet2->set_selection(3, 3, 6, 6); # 2. Cells D4 to G7.
$worksheet3->set_selection(6, 6, 3, 3); # 3. Cells G7 to D4.
$worksheet4->set_selection('D4'); # Same as 1.
$worksheet5->set_selection('D4:G7'); # Same as 2.
$worksheet6->set_selection('G7:D4'); # Same as 3.
</PRE>
</P>
<P>
The default cell selections is (0, 0), 'A1'.
</P>
<P>
<HR>
<H2><A NAME="set_row_row_height_format_">set_row($row, $height, $format)</A></H2>
<P>
This method can be used to specify the height of a row. The <CODE>$format</CODE> parameter is optional, for additional information, see <A HREF="#CELL_FORMATTING">CELL FORMATTING</A>.
</P>
<P>
<PRE>
$worksheet->set_row(0, 20); # Row 1 height set to 20
</PRE>
</P>
<P>
If you wish to set the format without changing the height you can pass <CODE>undef</CODE> as the height parameter:
</P>
<P>
<PRE>
$worksheet->set_row(0, undef, $format);
</PRE>
</P>
<P>
The <CODE>$format</CODE> parameter will only define a format if <CODE>set_row()</CODE> is called after the cells have been written:
</P>
<P>
<PRE>
$worksheet->write('A1', "Hello"); # Formatted
$worksheet->set_row(0, undef, $format);
$worksheet->write('B1', "Hello"); # Not formatted
</PRE>
</P>
<P>
This behaviour will be fixed in a future release.
</P>
<P>
<HR>
<H2><A NAME="set_column_first_col_last_col">set_column($first_col, $last_col, $width, $format, $hidden)</A></H2>
<P>
This method can be used to specify the width of a single column or a range
of columns. If the method is applied to a single column the value of <CODE>$first_col</CODE> and <CODE>$last_col</CODE> should be the same. It is also possible to specify a column range using the
form of A1 notation used for columns. See the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
Examples:
</P>
<P>
<PRE>
$worksheet->set_column(0, 0, 20); # Column A width set to 20
$worksheet->set_column(1, 3, 30); # Columns B-D width set to 30
$worksheet->set_column('E:E', 20); # Column E width set to 20
$worksheet->set_column('F:H', 30); # Columns F-H width set to 30
</PRE>
</P>
<P>
The width corresponds to the column width value that is specified in Excel.
It is approximately equal to the length of a string in the default font of
Arial 10. Unfortunately, there is no way to specify "AutoFit" for
a column in the Excel file format. This feature is only available at
runtime from within Excel.
</P>
<P>
The <CODE>$format</CODE> parameter is optional, for additional information, see <A HREF="#CELL_FORMATTING">CELL FORMATTING</A>. If you wish to set the format without changing the width you can pass <CODE>undef</CODE> as the width parameter:
</P>
<P>
<PRE>
$worksheet->set_column(0, 0, undef, $format);
</PRE>
</P>
<P>
The <CODE>$format</CODE> parameter will not set the format for individual cells written by
Spreadsheet::WriteExcel, it only has an effect on cells written after the
workbook is opened in Excel. This behaviour will be fixed in a future
release.
</P>
<P>
The <CODE>$hidden</CODE> parameter is optional. It should be set to 1 if you wish to hide a column.
This can be used, for example, to hide intermediary steps in a complicated
calculation:
</P>
<P>
<PRE>
$worksheet->set_column('D:D', 20, $format, 1);
$worksheet->set_column('E:E', undef, undef, 1);
</PRE>
</P>
<P>
<HR>
<H2><A NAME="freeze_panes_row_col_top_ro">freeze_panes($row, $col, $top_row, $left_col)</A></H2>
<P>
This method can be used to divide a worksheet into horizontal or vertical
regions known as panes and to also "freeze" these panes so that
the splitter bars are not visible. This is the same as the <CODE>Window->Freeze Panes</CODE> menu command in Excel
</P>
<P>
The parameters <CODE>$row</CODE> and <CODE>$col</CODE> are used to specify the location of the split. It should be noted that the
split is specified at the top or left of a cell and that the method uses
zero based indexing. Therefore to freeze the first row of a worksheet it is
necessary to specify the split at row 2 (which is 1 as the zero-based
index). This might lead you to think that you are using a 1 based index but
this is not the case.
</P>
<P>
You can set one of the <CODE>$row</CODE> and <CODE>$col</CODE> parameters as zero if you do not want either a vertical or horizontal
split.
</P>
<P>
Examples:
</P>
<P>
<PRE>
$worksheet->freeze_panes(1, 0); # Freeze the first row
$worksheet->freeze_panes('A2'); # Same using A1 notation
$worksheet->freeze_panes(0, 1); # Freeze the first column
$worksheet->freeze_panes('B1'); # Same using A1 notation
$worksheet->freeze_panes(1, 2); # Freeze the first row and first 2 columns
$worksheet->freeze_panes('C2'); # Same using A1 notation
</PRE>
</P>
<P>
The parameters <CODE>$top_row</CODE> and <CODE>$left_col</CODE> are optional. They are used to specify the top-most or left-most visible
row or column in the scrolling region of the panes. For example to freeze
the first row and to have the scrolling region begin at row twenty:
</P>
<P>
<PRE>
$worksheet->freeze_panes(1, 0, 20, 0);
</PRE>
</P>
<P>
You cannot use A1 notation for the <CODE>$top_row</CODE> and <CODE>$left_col</CODE> parameters.
</P>
<P>
See also the <CODE>panes.pl</CODE> program in the <CODE>examples</CODE> directory of the distribution.
</P>
<P>
<HR>
<H2><A NAME="thaw_panes_y_x_top_row_le">thaw_panes($y, $x, $top_row, $left_col)</A></H2>
<P>
This method can be used to divide a worksheet into horizontal or vertical
regions known as panes. This method is different from the <CODE>freeze_panes()</CODE> method in that the splits between the panes will be visible to the user and
each pane will have its own scroll bars.
</P>
<P>
The parameters <CODE>$y</CODE> and <CODE>$x</CODE> are used to specify the vertical and horizontal position of the split. The
units for <CODE>$y</CODE> and <CODE>$x</CODE> are the same as those used by Excel to specify row height and column width.
However, the vertical and horizontal units are different from each other.
Therefore you must specify the <CODE>$y</CODE> and <CODE>$x</CODE> parameters in terms of the row heights and column widths that you have set
or the default values which are <CODE>12.75</CODE> for a row and <CODE>8.43</CODE> for a column.
</P>
<P>
You can set one of the <CODE>$y</CODE> and <CODE>$x</CODE> parameters as zero if you do not want either a vertical or horizontal
split. The parameters <CODE>$top_row</CODE> and <CODE>$left_col</CODE> are optional. They are used to specify the top-most or left-most visible
row or column in the bottom-right pane.
</P>
<P>
Example:
</P>
<P>
<PRE>
$worksheet->thaw_panes(12.75, 0, 1, 0); # First row
$worksheet->thaw_panes(0, 8.43, 0, 1); # First column
$worksheet->thaw_panes(12.75, 8.43, 1, 1); # First row and column
</PRE>
</P>
<P>
You cannot use A1 notation with this method.
</P>
<P>
See also the <CODE>freeze_panes()</CODE> method and the <CODE>panes.pl</CODE> program in the <CODE>examples</CODE> directory of the distribution.
</P>
<P>
<HR>
<H2><A NAME="merge_cells_first_row_first_c">merge_cells($first_row, $first_col, $last_row, $last_col)</A></H2>
<P>
Merging cells is generally achieved by setting the <CODE>merge</CODE> property of a Format object, see <A HREF="#CELL_FORMATTING">CELL FORMATTING</A>. However, in certain circumstances this is not sufficient and you must
additionally specify the cells to be merged via the <CODE>merge_cells()</CODE> method.
</P>
<P>
The main use of the <CODE>merge_cells()</CODE> method is to merge cells vertically. The <CODE>merge_cells()</CODE> method can also be used to merge cells that contain hyperlinks although
this can also be achieved via the <CODE>write_url_range()</CODE> method.
</P>
<P>
For an example of how to use this method see the <CODE>merge3.pl</CODE> program in the <CODE>examples</CODE> directory of the distribution.
</P>
<P>
This method is currently of limited use. It will play a more important role
when Spreadsheet::WriteExcel moves to the Excel 97/2000 file format.
</P>
<P>
In general the <CODE>set_merge()</CODE> method is all that you will require to create merged cells, see <A HREF="#CELL_FORMATTING">CELL FORMATTING</A>.
</P>
<P>
<HR>
<H2><A NAME="set_zoom_scale_">set_zoom($scale)</A></H2>
<P>
Set the worksheet zoom factor in the range <CODE>10 <= $scale <= 400</CODE>:
</P>
<P>
<PRE>
$worksheet1->set_zoom(50);
$worksheet2->set_zoom(75);
$worksheet3->set_zoom(300);
$worksheet4->set_zoom(400);
</PRE>
</P>
<P>
The default zoom factor is 100. You cannot zoom to "Selection"
because it is calculated by Excel at run-time.
</P>
<P>
Note, <CODE>set_zoom()</CODE> does not affect the scale of the printed page. For that you should use <CODE>set_print_scale()</CODE>.
</P>
<P>
<HR>
<H1><A NAME="PAGE_SET_UP_METHODS">PAGE SET-UP METHODS</A></H1>
<P>
Page set-up methods affect the way that a worksheet looks when it is
printed. They control features such as page headers and footers and
margins. These methods are really just standard worksheet methods. They are
documented here in a separate section for the sake of clarity.
</P>
<P>
The following methods are available for page set-up:
</P>
<P>
<PRE>
set_landscape()
set_portrait()
set_paper()
center_horizontally()
center_vertically()
set_margins()
set_header()
set_footer()
repeat_rows()
repeat_columns()
hide_gridlines()
print_row_col_headers()
print_area()
fit_to_pages()
set_print_scale()
set_h_pagebreaks()
set_v_pagebreaks()
</PRE>
</P>
<P>
A common requirement when working with Spreadsheet::WriteExcel is to apply
the same page set-up features to all of the worksheets in a workbook. To do
this you can use the <CODE>sheets()</CODE> method of the <CODE>workbook</CODE> class to access the array of worksheets in a workbook:
</P>
<P>
<PRE>
foreach $worksheet ($workbook->sheets()) {
$worksheet->set_landscape();
}
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_landscape_">set_landscape()</A></H2>
<P>
This method is used to set the orientation of a worksheet's printed page to
landscape:
</P>
<P>
<PRE>
$worksheet->set_landscape(); # Landscape mode
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_portrait_">set_portrait()</A></H2>
<P>
This method is used to set the orientation of a worksheet's printed page to
portrait. The default worksheet orientation is portrait, so you won't
generally need to call this method.
</P>
<P>
<PRE>
$worksheet->set_portrait(); # Portrait mode
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_paper_index_">set_paper($index)</A></H2>
<P>
This method is used to set the paper format for the printed output of a
worksheet. The following paper styles are available:
</P>
<P>
<PRE>
Index Paper format Paper size
===== ============ ==========
0 Printer default -
1 Letter 8 1/2 x 11 in
2 Letter Small 8 1/2 x 11 in
3 Tabloid 11 x 17 in
4 Ledger 17 x 11 in
5 Legal 8 1/2 x 14 in
6 Statement 5 1/2 x 8 1/2 in
7 Executive 7 1/4 x 10 1/2 in
8 A3 297 x 420 mm
9 A4 210 x 297 mm
10 A4 Small 210 x 297 mm
11 A5 148 x 210 mm
12 B4 250 x 354 mm
13 B5 182 x 257 mm
14 Folio 8 1/2 x 13 in
15 Quarto 215 x 275 mm
16 - 10x14 in
17 - 11x17 in
18 Note 8 1/2 x 11 in
19 Envelope 9 3 7/8 x 8 7/8
20 Envelope 10 4 1/8 x 9 1/2
21 Envelope 11 4 1/2 x 10 3/8
22 Envelope 12 4 3/4 x 11
23 Envelope 14 5 x 11 1/2
24 C size sheet -
25 D size sheet -
26 E size sheet -
27 Envelope DL 110 x 220 mm
28 Envelope C3 324 x 458 mm
29 Envelope C4 229 x 324 mm
30 Envelope C5 162 x 229 mm
31 Envelope C6 114 x 162 mm
32 Envelope C65 114 x 229 mm
33 Envelope B4 250 x 353 mm
34 Envelope B5 176 x 250 mm
35 Envelope B6 176 x 125 mm
36 Envelope 110 x 230 mm
37 Monarch 3.875 x 7.5 in
38 Envelope 3 5/8 x 6 1/2 in
39 Fanfold 14 7/8 x 11 in
40 German Std Fanfold 8 1/2 x 12 in
41 German Legal Fanfold 8 1/2 x 13 in
</PRE>
</P>
<P>
Note, it is likely that not all of these paper types will be available to
the end user since it will depend on the paper formats that the user's
printer supports. Therefore, it is best to stick to standard paper types.
</P>
<P>
<PRE>
$worksheet->set_paper(1); # US Letter
$worksheet->set_paper(9); # A4
</PRE>
</P>
<P>
If you do not specify a paper type the worksheet will print using the
printer's default paper.
</P>
<P>
<HR>
<H2><A NAME="center_horizontally_">center_horizontally()</A></H2>
<P>
Center the worksheet data horizontally between the margins on the printed
page:
</P>
<P>
<PRE>
$worksheet->center_horizontally();
</PRE>
</P>
<P>
<HR>
<H2><A NAME="center_vertically_">center_vertically()</A></H2>
<P>
Center the worksheet data vertically between the margins on the printed
page:
</P>
<P>
<PRE>
$worksheet->center_vertically();
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_margins_inches_">set_margins($inches)</A></H2>
<P>
There are several methods available for setting the worksheet margins on
the printed page:
</P>
<P>
<PRE>
set_margins() # Set all margins to the same value
set_margins_LR() # Set left and right margins to the same value
set_margins_TB() # Set top and bottom margins to the same value
set_margin_left(); # Set left margin
set_margin_right(); # Set right margin
set_margin_top(); # Set top margin
set_margin_bottom(); # Set bottom margin
</PRE>
</P>
<P>
All of these methods take a distance in inches as a parameter. Note: 1 inch
= 25.4mm. ;-) The default left and right margin is 0.75 inch. The default
top and bottom margin is 1.00 inch.
</P>
<P>
<HR>
<H2><A NAME="set_header_string_margin_">set_header($string, $margin)</A></H2>
<P>
Headers and footers are generated using a <CODE>$string</CODE> which is a combination of plain text and control characters. The <CODE>$margin</CODE> parameter is optional.
</P>
<P>
The available control character are:
</P>
<P>
<PRE>
Control Category Description
======= ======== ===========
&L Justification Left
&C Center
&R Right
&P Information Page number
&N Total number of pages
&D Date
&T Time
&F File name
&A Worksheet name
&fontsize Font Font size
&"font,style" Font name and style
&U Single underline
&E Double underline
&S Strikethrough
&X Superscript
&Y Subscript
&& Miscellaneous Literal ampersand &
</PRE>
</P>
<P>
Text in headers and footers can be justified (aligned) to the left, center
and right by prefixing the text with the control characters <CODE>&L</CODE>, <CODE>&C</CODE> and <CODE>&R</CODE>.
</P>
<P>
For example (with ASCII art representation of the results):
</P>
<P>
<PRE>
$worksheet->set_header('&LHello');
---------------------------------------------------------------
| |
| Hello |
| |
$worksheet->set_header('&CHello');
---------------------------------------------------------------
| |
| Hello |
| |
$worksheet->set_header('&RHello');
---------------------------------------------------------------
| |
| Hello |
| |
</PRE>
</P>
<P>
For simple text, if you do not specify any justification the text will be
centred. However, you must prefix the text with <CODE>&C</CODE> if you specify a font name:
</P>
<P>
<PRE>
$worksheet->set_header('Hello');
---------------------------------------------------------------
| |
| Hello |
| |
</PRE>
</P>
<P>
You can also have text in each of the justification regions:
</P>
<P>
<PRE>
$worksheet->set_header('&LCiao&CBello&RCielo');
---------------------------------------------------------------
| |
| Ciao Bello Cielo |
| |
</PRE>
</P>
<P>
The information control characters act as variables that Excel will update
as the workbook or worksheet changes. Times and dates are in the users
default format:
</P>
<P>
<PRE>
$worksheet->set_header('&CPage &P of &N');
---------------------------------------------------------------
| |
| Page 1 of 6 |
| |
$worksheet->set_header('&CUpdated at &T');
---------------------------------------------------------------
| |
| Updated at 12:30 PM |
| |
</PRE>
</P>
<P>
You can specify the font size of a section of the text by prefixing it with
the control character <CODE>&n</CODE> where <CODE>n</CODE> is the font size:
</P>
<P>
<PRE>
$worksheet1->set_header('&C&30Hello Big' );
$worksheet2->set_header('&C&10Hello Small');
</PRE>
</P>
<P>
You can specify the font of a section of the text by prefixing it with the
control sequence <CODE>&"font,style"</CODE> where <CODE>fontname</CODE> is a font name such as "Courier New" or "Times New
Roman" and <CODE>style</CODE> is one of the standard Windows font descriptions: "Regular",
"Italic", "Bold" or "Bold Italic":
</P>
<P>
<PRE>
$worksheet1->set_header('&C&"Courier New,Italic"Hello');
$worksheet2->set_header('&C&"Courier New,Bold Italic"Hello');
$worksheet3->set_header('&C&"Times New Roman,Regular"Hello');
</PRE>
</P>
<P>
It is possible to combine all of these features together to create
sophisticated headers and footers. As an aid to setting up complicated
headers and footers you can record a page set-up as a macro in Excel and
look at the format strings that VBA produces. Remember however that VBA
uses two double quotes <CODE>""</CODE> to indicate a single double quote. For the last example above the
equivalent VBA code looks like this:
</P>
<P>
<PRE>
.LeftHeader = ""
.CenterHeader = "&""Times New Roman,Regular""Hello"
.RightHeader = ""
</PRE>
</P>
<P>
To include a single literal ampersand <CODE>&</CODE> in a header or footer you should use a double ampersand <CODE>&&</CODE>:
</P>
<P>
<PRE>
$worksheet1->set_header('&CCuriouser && Curiouser - Attorneys at Law');
</PRE>
</P>
<P>
As stated above the margin parameter is optional. As with the other margins
the value should be in inches. The default header and footer margin is 0.50
inch. The header and footer margin size can be set as follows:
</P>
<P>
<PRE>
$worksheet->set_header('&CHello', 0.75);
</PRE>
</P>
<P>
The header and footer margins are independent of the top and bottom
margins.
</P>
<P>
Note, the header or footer string must be less than 255 characters. Strings
longer than this will not be written and a warning will be generated.
</P>
<P>
See, also the <CODE>headers.pl</CODE> program in the <CODE>examples</CODE> directory of the distribution.
</P>
<P>
<HR>
<H2><A NAME="set_footer_">set_footer()</A></H2>
<P>
The syntax of the <CODE>set_footer()</CODE> method is the same as the <CODE>set_header()</CODE>, see above.
</P>
<P>
<HR>
<H2><A NAME="repeat_rows_first_row_last_ro">repeat_rows($first_row, $last_row)</A></H2>
<P>
Set the number of rows to repeat at the top of each printed page.
</P>
<P>
For large Excel documents it is often desirable to have the first row or
rows of the worksheet print out at the top of each page. This can be
achieved by using the <CODE>repeat_rows()</CODE> method. The parameters <CODE>$first_row</CODE> and <CODE>$last_row</CODE> are zero based. The <CODE>$last_row</CODE> parameter is optional if you only wish to specify one row:
</P>
<P>
<PRE>
$worksheet1->repeat_rows(0); # Repeat the first row
$worksheet2->repeat_rows(0, 1); # Repeat the first two rows
</PRE>
</P>
<P>
<HR>
<H2><A NAME="repeat_columns_first_col_last">repeat_columns($first_col, $last_col)</A></H2>
<P>
Set the columns to repeat at the left hand side of each printed page.
</P>
<P>
For large Excel documents it is often desirable to have the first column or
columns of the worksheet print out at the left hand side of each page. This
can be achieved by using the <CODE>repeat_columns()</CODE> method. The parameters <CODE>$first_column</CODE> and <CODE>$last_column</CODE> are zero based. The <CODE>$last_column</CODE> parameter is optional if you only wish to specify one column. You can also
specify the columns using A1 column notation, see the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
<PRE>
$worksheet1->repeat_columns(0); # Repeat the first column
$worksheet2->repeat_columns(0, 1); # Repeat the first two columns
$worksheet3->repeat_columns('A:A'); # Repeat the first column
$worksheet4->repeat_columns('A:B'); # Repeat the first two columns
</PRE>
</P>
<P>
<HR>
<H2><A NAME="hide_gridlines_">hide_gridlines()</A></H2>
<P>
This method is used to hide the gridlines on a printed page.
</P>
<P>
Gridlines are the lines that divide the cells on a worksheet. Printed
gridlines are turned on by default. If you have defined your own cell
borders you may wish to hide the gridlines on the printed page.
</P>
<P>
<PRE>
$worksheet->hide_gridlines();
</PRE>
</P>
<P>
<HR>
<H2><A NAME="print_row_col_headers_">print_row_col_headers()</A></H2>
<P>
Set the option to print the row and column headers on the printed page.
</P>
<P>
An Excel worksheet looks something like the following;
</P>
<P>
<PRE>
------------------------------------------
| | A | B | C | D | ...
------------------------------------------
| 1 | | | | | ...
| 2 | | | | | ...
| 3 | | | | | ...
| 4 | | | | | ...
|...| ... | ... | ... | ... | ...
</PRE>
</P>
<P>
The headers are the letters and numbers at the top and the left of the
worksheet. Since these headers serve mainly as a indication of position on
the worksheet they generally do not appear on the printed page. If you wish
to have them printed you can use the <CODE>print_row_col_headers()</CODE> method :
</P>
<P>
<PRE>
$worksheet->print_row_col_headers()
</PRE>
</P>
<P>
Do not confuse these headers with page headers as described in the <CODE>set_header()</CODE> section above.
</P>
<P>
<HR>
<H2><A NAME="print_area_first_row_first_co">print_area($first_row, $first_col, $last_row, $last_col)</A></H2>
<P>
This method is used to specify the area of the worksheet that will be
printed. All four parameters must be specified. You can also use A1
notation, see the note about <A HREF="#Cell_notation">Cell notation</A>.
</P>
<P>
<PRE>
$worksheet1->print_area("A1:H20"); # Cells A1 to H20
$worksheet2->print_area(0, 0, 19, 7); # The same
</PRE>
</P>
<P>
<HR>
<H2><A NAME="fit_to_pages_width_height_">fit_to_pages($width, $height)</A></H2>
<P>
The <CODE>fit_to_pages()</CODE> method is used to fit the printed area to a specific number of pages both
vertically and horizontally. If the printed area exceeds the specified
number of pages it will be scaled down to fit. This guarantees that the
printed area will always appear on the specified number of pages even if
the page size or margins change.
</P>
<P>
<PRE>
$worksheet1->fit_to_pages(1, 1); # Fit to 1x1 pages
$worksheet2->fit_to_pages(2, 1); # Fit to 2x1 pages
$worksheet3->fit_to_pages(1, 2); # Fit to 1x2 pages
</PRE>
</P>
<P>
The print area can be defined using the <CODE>print_area()</CODE> method as described above.
</P>
<P>
A common requirement is to fit the printed output to "n" pages
wide but have the height be as long as necessary. To achieve this set the <CODE>$height</CODE> to zero or leave it blank:
</P>
<P>
<PRE>
$worksheet1->fit_to_pages(1, 0); # 1 page wide and as long as necessary
$worksheet2->fit_to_pages(1); # The same
</PRE>
</P>
<P>
Note that although it is valid to use both <CODE>fit_to_pages()</CODE> and <CODE>set_print_scale()</CODE> on the same worksheet only one of these options can be active at a time.
The last method call made will set the active option.
</P>
<P>
Note that <CODE>fit_to_pages()</CODE> will override any manual page breaks that are defined in the worksheet.
</P>
<P>
<HR>
<H2><A NAME="set_print_scale_scale_">set_print_scale($scale)</A></H2>
<P>
Set the scale factor of the printed page. Scale factors in the range <CODE>10 <= $scale <= 400</CODE> are valid:
</P>
<P>
<PRE>
$worksheet1->set_print_scale(50);
$worksheet2->set_print_scale(75);
$worksheet3->set_print_scale(300);
$worksheet4->set_print_scale(400);
</PRE>
</P>
<P>
The default scale factor is 100. Note, <CODE>set_print_scale()</CODE> does not affect the scale of the visible page in Excel. For that you should
use <CODE>set_zoom()</CODE>.
</P>
<P>
Note also that although it is valid to use both <CODE>fit_to_pages()</CODE> and <CODE>set_print_scale()</CODE> on the same worksheet only one of these options can be active at a time.
The last method call made will set the active option.
</P>
<P>
<HR>
<H2><A NAME="set_h_pagebreaks_breaks_">set_h_pagebreaks(@breaks)</A></H2>
<P>
Add horizontal page breaks to a worksheet. A page break causes all the data
that follows it to be printed on the next page. Horizontal page breaks act
between rows. To create a page break between rows 20 and 21 you must
specify the break at row 21. However in zero index notation this is
actually row 20. So you can pretend for a small while that you are using 1
index notation:
</P>
<P>
<PRE>
$worksheet1->set_h_pagebreaks(20); # Break between row 20 and 21
</PRE>
</P>
<P>
The <CODE>set_h_pagebreaks()</CODE> method will accept a list of page breaks and you can call it more than
once:
</P>
<P>
<PRE>
$worksheet2->set_h_pagebreaks( 20, 40, 60, 80, 100); # Add breaks
$worksheet2->set_h_pagebreaks(120, 140, 160, 180, 200); # Add some more
</PRE>
</P>
<P>
Note: If you specify the "fit to page" option via the <CODE>fit_to_pages()</CODE> method it will override all manual page breaks.
</P>
<P>
There is a silent limitation of about 1000 horizontal page breaks per
worksheet in line with an Excel internal limitation.
</P>
<P>
<HR>
<H2><A NAME="set_v_pagebreaks_breaks_">set_v_pagebreaks(@breaks)</A></H2>
<P>
Add vertical page breaks to a worksheet. A page break causes all the data
that follows it to be printed on the next page. Vertical page breaks act
between columns. To create a page break between columns 20 and 21 you must
specify the break at column 21. However in zero index notation this is
actually column 20. So you can pretend for a small while that you are using
1 index notation:
</P>
<P>
<PRE>
$worksheet1->set_v_pagebreaks(20); # Break between column 20 and 21
</PRE>
</P>
<P>
The <CODE>set_v_pagebreaks()</CODE> method will accept a list of page breaks and you can call it more than
once:
</P>
<P>
<PRE>
$worksheet2->set_v_pagebreaks( 20, 40, 60, 80, 100); # Add breaks
$worksheet2->set_v_pagebreaks(120, 140, 160, 180, 200); # Add some more
</PRE>
</P>
<P>
Note: If you specify the "fit to page" option via the <CODE>fit_to_pages()</CODE> method it will override all manual page breaks.
</P>
<P>
<HR>
<H1><A NAME="CELL_FORMATTING">CELL FORMATTING</A></H1>
<P>
This section describes the methods and properties that are available for
formatting cells in Excel. The properties of a cell that can be formatted
include: fonts, colours, patterns, borders, alignment and number
formatting.
</P>
<P>
<HR>
<H2><A NAME="Creating_and_using_a_Format_obje">Creating and using a Format object</A></H2>
<P>
Cell formatting is defined through a Format object. Format objects are
created by calling the workbook <CODE>addformat()</CODE> method as follows:
</P>
<P>
<PRE>
my $format1 = $workbook->addformat(); # Set properties later
my $format2 = $workbook->addformat(%props); # Set properties at creation
</PRE>
</P>
<P>
The format object holds all the formatting properties that can be applied
to a cell, a row or a column. The process of setting these properties is
discussed in the next section.
</P>
<P>
Once a Format object has been constructed and it properties have been set
it can be passed as an argument to the worksheet <CODE>write</CODE> methods as follows:
</P>
<P>
<PRE>
$worksheet->write(0, 0, "One", $format);
$worksheet->write_string(1, 0, "Two", $format);
$worksheet->write_number(2, 0, 3, $format);
$worksheet->write_blank(3, 0, $format);
</PRE>
</P>
<P>
Formats can also be passed to the worksheet <CODE>set_row()</CODE> and <CODE>set_column()</CODE> methods to define the default property for a row or column.
</P>
<P>
<PRE>
$worksheet->set_row(0, 15, $format);
$worksheet->set_column(0, 0, 15, $format);
</PRE>
</P>
<P>
However, the <CODE>set_row()</CODE> and <CODE>set_column()</CODE> methods will not set the format for individual cells written by WriteExcel,
they only have an effect on cells written after the workbook is opened in
Excel.
</P>
<P>
<HR>
<H2><A NAME="Format_methods_and_Format_proper">Format methods and Format properties</A></H2>
<P>
The following table shows the Excel format categories, the formatting
properties that can be applied and the equivalent object method:
</P>
<P>
<PRE>
Category Description Property Method Name
-------- ----------- -------- -----------
Font Font type font set_font()
Font size size set_size()
Font color color set_color()
Bold bold set_bold()
Italic italic set_italic()
Underline underline set_underline()
Strikeout font_strikeout set_font_strikeout()
Super/Subscript font_script set_font_script()
Outline font_outline set_font_outline()
Shadow font_shadow set_font_shadow()
Number Numeric format num_format set_num_format()
Protection Lock cells locked set_locked()
Hide formulas hidden set_hidden()
Alignment Horizontal align align set_align()
Vertical align valign set_align()
Rotation rotation set_rotation()
Text wrap text_wrap set_text_wrap()
Justify last text_justlast set_text_justlast()
Merge merge set_merge()
Pattern Cell pattern pattern set_pattern()
Background color bg_color set_bg_color()
Foreground color fg_color set_fg_color()
Border Cell border border set_border()
Bottom border bottom set_bottom()
Top border top set_top()
Left border left set_left()
Right border right set_right()
Border color border_color set_border_color()
Bottom color bottom_color set_bottom_color()
Top color top_color set_top_color()
Left color left_color set_left_color()
Right color right_color set_right_color()
</PRE>
</P>
<P>
There are two ways of setting Format properties: by using the object method
interface or by setting the property directly. For example, a typical use
of the method interface would be as follows:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_bold();
$format->set_color('red');
</PRE>
</P>
<P>
By comparison the properties can be set directly by passing a hash of
properties to the Format constructor:
</P>
<P>
<PRE>
my $format = $workbook->addformat(bold => 1, color => 'red');
</PRE>
</P>
<P>
or after the Format has been constructed by means of the <CODE>set_properties()</CODE> method as follows:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_properties(bold => 1, color => 'red');
</PRE>
</P>
<P>
You can also store the properties in one or more named hashes and pass them
to the required method:
</P>
<P>
<PRE>
my %font = (
font => 'Arial',
size => 12,
color => 'blue',
bold => 1,
);
</PRE>
</P>
<P>
<PRE>
my %shading = (
fg_color => 'green',
pattern => 1,
);
</PRE>
</P>
<P>
<PRE>
my $format1 = $workbook->addformat(%font); # Font only
my $format2 = $workbook->addformat(%font, %shading); # Font and shading
</PRE>
</P>
<P>
The provision of two ways of setting properties might lead you to wonder
which is the best way. The answer depends on the amount of formatting that
will be required in your program. Initially, Spreadsheet::WriteExcel only
allowed individual Format properties to be set via the appropriate method.
While this was sufficient for most circumstances it proved very cumbersome
in programs that required a large amount of formatting. In addition the
mechanism for reusing properties between Format objects was complicated.
</P>
<P>
As a result the Perl/Tk style of adding properties was added to, hopefully,
facilitate developers who need to define a lot of formatting. In fact the
Tk style of defining properties is also supported:
</P>
<P>
<PRE>
my %font = (
-font => 'Arial',
-size => 12,
-color => 'blue',
-bold => 1,
);
</PRE>
</P>
<P>
An additional advantage of working with hashes of properties is that it
allows you to share formatting between workbook objects
</P>
<P>
You can also create a format "on the fly" and pass it directly to
a write method as follows:
</P>
<P>
<PRE>
$worksheet->write('A1', "Title", $workbook->addformat(bold => 1));
</PRE>
</P>
<P>
This corresponds to an "anonymous" format in the Perl sense of
anonymous data or subs.
</P>
<P>
If you need to create an Excel file with a large amount of formatting you
can also use the <CODE>lecxe.pl</CODE> program in the <CODE>examples</CODE> directory of the distribution. <CODE>lecxe</CODE> is a Win32::OLE program written by Tomas Andersson which converts Excel
files to Spreadsheet::WriteExcel files. Therefore, you can use Excel to
define your formatting and have <CODE>lecxe</CODE> do the hard work for you.
</P>
<P>
<HR>
<H2><A NAME="Working_with_formats">Working with formats</A></H2>
<P>
The default format is Arial 10 with all other properties off.
</P>
<P>
Each unique format in Spreadsheet::WriteExcel must have a corresponding
Format object. It isn't possible to use a Format with a
<CODE>write()</CODE> method and then redefine the Format for use at a later
stage. This is because a Format is applied to a cell not in its current
state but in its final state. Consider the following example:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_bold();
$format->set_color('red');
$worksheet->write('A1', "Cell A1", $format);
$format->set_color('green');
$worksheet->write('B1', "Cell B1", $format);
</PRE>
</P>
<P>
Cell A1 is assigned the Format <CODE>$format</CODE> which is initially set to the colour red. However, the colour is
subsequently set to green. When Excel displays Cell A1 it will display the
final state of the Format which in this case will be the colour green.
</P>
<P>
In general a method call without an argument will turn a property on, for
example:
</P>
<P>
<PRE>
my $format1 = $workbook->addformat();
$format1->set_bold(); # Turns bold on
$format1->set_bold(1); # Also turns bold on
$format1->set_bold(0); # Turns bold off
</PRE>
</P>
<P>
<HR>
<H1><A NAME="FORMAT_METHODS">FORMAT METHODS</A></H1>
<P>
The Format object methods are described in more detail in the following
sections. In addition, there is a Perl program called <CODE>formats.pl</CODE> in the <CODE>examples</CODE> directory of the WriteExcel distribution. This program creates an Excel
workbook called <CODE>formats.xls</CODE> which contains examples of almost all the format types.
</P>
<P>
The following Format methods are available:
</P>
<P>
<PRE>
set_font()
set_size()
set_color()
set_bold()
set_italic()
set_underline()
set_font_strikeout()
set_font_script()
set_font_outline()
set_font_shadow()
set_num_format()
set_locked()
set_hidden()
set_align()
set_align()
set_rotation()
set_text_wrap()
set_text_justlast()
set_merge()
set_pattern()
set_bg_color()
set_fg_color()
set_border()
set_bottom()
set_top()
set_left()
set_right()
set_border_color()
set_bottom_color()
set_top_color()
set_left_color()
set_right_color()
</PRE>
</P>
<P>
The above methods can also be applied directly as properties. For example <CODE>$worksheet->set_bold()</CODE> is equivalent to <CODE>set_properties(bold => 1)</CODE>.
</P>
<P>
<HR>
<H2><A NAME="set_properties_properties_">set_properties(%properties)</A></H2>
<P>
The properties of an existing Format object can be set by means of <CODE>set_properties()</CODE>:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_properties(bold => 1, color => 'red');
</PRE>
</P>
<P>
You can also store the properties in one or more named hashes and pass them
to the <CODE>set_properties()</CODE> method:
</P>
<P>
<PRE>
my %font = (
font => 'Arial',
size => 12,
color => 'blue',
bold => 1,
);
</PRE>
</P>
<P>
<PRE>
my $format = $workbook->set_properties(%font);
</PRE>
</P>
<P>
This method can be used as an alternative to setting the properties with <CODE>addformat()</CODE> or the specific format methods that are detailed in the following sections.
</P>
<P>
<HR>
<H2><A NAME="set_font_fontname_">set_font($fontname)</A></H2>
<P>
<PRE>
Default state: Font is Arial
Default action: None
Valid args: Any valid font name
</PRE>
</P>
<P>
Specify the font used:
</P>
<P>
<PRE>
$format->set_font('Times New Roman');
</PRE>
</P>
<P>
Excel can only display fonts that are installed on the system that it is
running on. Therefore it is best to use the fonts that come as standard
such as 'Arial', 'Times New Roman' and 'Courier New'. See also the Fonts
worksheet created by formats.pl
</P>
<P>
<HR>
<H2><A NAME="set_size_">set_size()</A></H2>
<P>
<PRE>
Default state: Font size is 10
Default action: Set font size to 1
Valid args: Integer values from 1 to as big as your screen.
</PRE>
</P>
<P>
Set the font size. Excel adjusts the height of a row to accommodate the
largest font size in the row. You can also explicitly specify the height of
a row using the <CODE>set_row()</CODE> worksheet method.
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_size(30);
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_color_">set_color()</A></H2>
<P>
<PRE>
Default state: Excels default color, usually black
Default action: Set the default color
Valid args: Integers from 8..63 or the following strings:
'black'
'blue'
'brown'
'cyan'
'gray'
'green'
'lime'
'magenta'
'navy'
'orange'
'purple'
'red'
'silver'
'white'
'yellow'
</PRE>
</P>
<P>
Set the font colour. The <CODE>set_color()</CODE> method is used as follows:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_color('red');
$worksheet->write(0, 0, "wheelbarrow", $format);
</PRE>
</P>
<P>
Note: The <CODE>set_color()</CODE> method is used to set the colour of the font in a cell. To set the colour
of a cell use the <CODE>set_fg_color()</CODE> and <CODE>set_pattern()</CODE> methods.
</P>
<P>
For additional examples see the 'Named colors' and 'Standard colors'
worksheets created by formats.pl in the examples directory.
</P>
<P>
See also <A HREF="#COLOURS_IN_EXCEL">COLOURS IN EXCEL</A>.
</P>
<P>
<HR>
<H2><A NAME="set_bold_">set_bold()</A></H2>
<P>
<PRE>
Default state: bold is off
Default action: Turn bold on
Valid args: 0, 1 [1]
</PRE>
</P>
<P>
Set the bold property of the font:
</P>
<P>
<PRE>
$format->set_bold(); # Turn bold on
</PRE>
</P>
<P>
[1] Actually, values in the range 100..1000 are also valid. 400 is normal,
700 is bold and 1000 is very bold indeed. It is probably best to set the
value to 1 and use normal bold.
</P>
<P>
<HR>
<H2><A NAME="set_italic_">set_italic()</A></H2>
<P>
<PRE>
Default state: Italic is off
Default action: Turn italic on
Valid args: 0, 1
</PRE>
</P>
<P>
Set the italic property of the font:
</P>
<P>
<PRE>
$format->set_italic(); # Turn italic on
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_underline_">set_underline()</A></H2>
<P>
<PRE>
Default state: Underline is off
Default action: Turn on single underline
Valid args: 0 = No underline
1 = Single underline
2 = Double underline
33 = Single accounting underline
34 = Double accounting underline
</PRE>
</P>
<P>
Set the underline property of the font.
</P>
<P>
<PRE>
$format->set_underline(); # Single underline
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_strikeout_">set_strikeout()</A></H2>
<P>
<PRE>
Default state: Strikeout is off
Default action: Turn strikeout on
Valid args: 0, 1
</PRE>
</P>
<P>
Set the strikeout property of the font.
</P>
<P>
<HR>
<H2><A NAME="set_script_">set_script()</A></H2>
<P>
<PRE>
Default state: Super/Subscript is off
Default action: Turn Superscript on
Valid args: 0 = Normal
1 = Superscript
2 = Subscript
</PRE>
</P>
<P>
Set the superscript/subscript property of the font. This format is
currently not very useful.
</P>
<P>
<HR>
<H2><A NAME="set_outline_">set_outline()</A></H2>
<P>
<PRE>
Default state: Outline is off
Default action: Turn outline on
Valid args: 0, 1
</PRE>
</P>
<P>
Macintosh only.
</P>
<P>
<HR>
<H2><A NAME="set_shadow_">set_shadow()</A></H2>
<P>
<PRE>
Default state: Shadow is off
Default action: Turn shadow on
Valid args: 0, 1
</PRE>
</P>
<P>
Macintosh only.
</P>
<P>
<HR>
<H2><A NAME="set_num_format_">set_num_format()</A></H2>
<P>
<PRE>
Default state: General format
Default action: Format index 1
Valid args: See the following table
</PRE>
</P>
<P>
This method is used to define the numerical format of a number in Excel. It
controls whether a number is displayed as an integer, a floating point
number, a date, a currency value or some other user defined format.
</P>
<P>
The numerical format of a cell can be specified by using a format string or
an index to one of Excel's built-in formats:
</P>
<P>
<PRE>
my $format1 = $workbook->addformat();
my $format2 = $workbook->addformat();
$format1->set_num_format('d mmm yyyy'); # Format string
$format2->set_num_format(0x0f); # Format index
</PRE>
</P>
<P>
<PRE>
$worksheet->write(0, 0, 36892.521, $format1); # 1 Jan 2001
$worksheet->write(0, 0, 36892.521, $format2); # 1-Jan-01
</PRE>
</P>
<P>
Using format strings you can define very sophisticated formatting of
numbers.
</P>
<P>
<PRE>
$format01->set_num_format('0.000');
$worksheet->write(0, 0, 3.1415926, $format01); # 3.142
</PRE>
</P>
<P>
<PRE>
$format02->set_num_format('#,##0');
$worksheet->write(1, 0, 1234.56, $format02); # 1,235
</PRE>
</P>
<P>
<PRE>
$format03->set_num_format('#,##0.00');
$worksheet->write(2, 0, 1234.56, $format03); # 1,234.56
</PRE>
</P>
<P>
<PRE>
$format04->set_num_format('$0.00');
$worksheet->write(3, 0, 49.99, $format04); # $49.99
</PRE>
</P>
<P>
<PRE>
$format05->set_num_format('0.00');
$worksheet->write(4, 0, 49.99, $format05); # 49.99
</PRE>
</P>
<P>
<PRE>
$format06->set_num_format('0.00');
$worksheet->write(5, 0, 49.99, $format06); # 49.99
</PRE>
</P>
<P>
<PRE>
$format07->set_num_format('mm/dd/yy');
$worksheet->write(6, 0, 36892.521, $format07); # 01/01/01
</PRE>
</P>
<P>
<PRE>
$format08->set_num_format('mmm d yyyy');
$worksheet->write(7, 0, 36892.521, $format08); # Jan 1 2001
</PRE>
</P>
<P>
<PRE>
$format09->set_num_format('d mmmm yyyy');
$worksheet->write(8, 0, 36892.521, $format09); # 1 January 2001
</PRE>
</P>
<P>
<PRE>
$format10->set_num_format('dd/mm/yyyy hh:mm AM/PM');
$worksheet->write(9, 0, 36892.521, $format10); # 01/01/2001 12:30 AM
</PRE>
</P>
<P>
<PRE>
$format11->set_num_format('0 "dollar and" .00 "cents"');
$worksheet->write(10, 0, 1.87, $format11); # 1 dollar and .87 cents
</PRE>
</P>
<P>
<PRE>
# Conditional formatting
$format12->set_num_format('[Green]General;[Red]-General;General');
$worksheet->write(11, 0, 123, $format12); # > 0 Green
$worksheet->write(12, 0, -45, $format12); # < 0 Red
$worksheet->write(13, 0, 0, $format12); # = 0 Default colour
</PRE>
</P>
<P>
<PRE>
# Zip code
$format13->set_num_format('00000');
$worksheet->write(14, 0, '01209', $format13);
</PRE>
</P>
<P>
The number system used for dates is described in <A HREF="#Dates_in_Excel">Dates in Excel</A>.
</P>
<P>
The colour format should have one of the following values:
</P>
<P>
<PRE>
[Black] [Blue] [Cyan] [Green] [Magenta] [Red] [White] [Yellow]
</PRE>
</P>
<P>
Alternatively you can specify the colour based on a colour index as
follows: <CODE>[Color n]</CODE>, where n is a standard Excel colour index - 7. See the 'Standard colors'
worksheet created by formats.pl.
</P>
<P>
For more information refer to the documentation on formatting in the <CODE>doc</CODE> directory of the Spreadsheet::WriteExcel distro, the Excel on-line help or
to the tutorial at: <A
HREF="http://support.microsoft.com/support/Excel/Content/Formats/default.asp">http://support.microsoft.com/support/Excel/Content/Formats/default.asp</A>
and <A
HREF="http://support.microsoft.com/support/Excel/Content/Formats/codes.asp">http://support.microsoft.com/support/Excel/Content/Formats/codes.asp</A>
</P>
<P>
You should ensure that the format string is valid in Excel prior to using
it in WriteExcel.
</P>
<P>
Excel's built-in formats are shown in the following table:
</P>
<P>
<PRE>
Index Index Format String
0 0x00 General
1 0x01 0
2 0x02 0.00
3 0x03 #,##0
4 0x04 #,##0.00
5 0x05 ($#,##0_);($#,##0)
6 0x06 ($#,##0_);[Red]($#,##0)
7 0x07 ($#,##0.00_);($#,##0.00)
8 0x08 ($#,##0.00_);[Red]($#,##0.00)
9 0x09 0%
10 0x0a 0.00%
11 0x0b 0.00E+00
12 0x0c # ?/?
13 0x0d # ??/??
14 0x0e m/d/yy
15 0x0f d-mmm-yy
16 0x10 d-mmm
17 0x11 mmm-yy
18 0x12 h:mm AM/PM
19 0x13 h:mm:ss AM/PM
20 0x14 h:mm
21 0x15 h:mm:ss
22 0x16 m/d/yy h:mm
.. .... ...........
37 0x25 (#,##0_);(#,##0)
38 0x26 (#,##0_);[Red](#,##0)
39 0x27 (#,##0.00_);(#,##0.00)
40 0x28 (#,##0.00_);[Red](#,##0.00)
41 0x29 _(* #,##0_);_(* (#,##0);_(* "-"_);_(@_)
42 0x2a _($* #,##0_);_($* (#,##0);_($* "-"_);_(@_)
43 0x2b _(* #,##0.00_);_(* (#,##0.00);_(* "-"??_);_(@_)
44 0x2c _($* #,##0.00_);_($* (#,##0.00);_($* "-"??_);_(@_)
45 0x2d mm:ss
46 0x2e [h]:mm:ss
47 0x2f mm:ss.0
48 0x30 ##0.0E+0
49 0x31 @
</PRE>
</P>
<P>
For examples of these formatting codes see the 'Numerical formats'
worksheet created by formats.pl.
</P>
<P>
Note 1. Numeric formats 23 to 36 are not documented by Microsoft and may
differ in international versions.
</P>
<P>
Note 2. In Excel 5 the dollar sign appears as a dollar sign. In Excel
97-2000 it appears as the defined local currency symbol.
</P>
<P>
Note 3. The red negative numeric formats display slightly differently in
Excel 5 and Excel 97-2000.
</P>
<P>
<HR>
<H2><A NAME="set_locked_">set_locked()</A></H2>
<P>
<PRE>
Default state: Cell locking is on
Default action: Turn locking on
Valid args: 0, 1
</PRE>
</P>
<P>
This property can be used to prevent modification of a cells contents.
Following Excel's convention, cell locking is turned on by default.
However, it only has an effect if the worksheet has been protected, see the
worksheet <CODE>protect()</CODE> method.
</P>
<P>
<PRE>
my $locked = $workbook->addformat();
$locked->set_locked(1); # A non-op
my $unlocked = $workbook->addformat();
$locked->set_locked(0);
# Enable worksheet protection
$worksheet->protect();
# This cell cannot be edited.
$worksheet->write('A1', '=1+2', $locked);
# This cell can be edited.
$worksheet->write('A2', '=1+2', $unlocked);
</PRE>
</P>
<P>
Note: This offers weak protection even with a password, see the note in
relation to the <CODE>protect()</CODE> method.
</P>
<P>
<HR>
<H2><A NAME="set_hidden_">set_hidden()</A></H2>
<P>
<PRE>
Default state: Formula hiding is off
Default action: Turn hiding on
Valid args: 0, 1
</PRE>
</P>
<P>
This property is used to hide a formula while still displaying its result.
This is generally used to hide complex calculations from end users who are
only interested in the result. It only has an effect if the worksheet has
been protected, see the worksheet <CODE>protect()</CODE> method.
</P>
<P>
<PRE>
my $hidden = $workbook->addformat();
$hidden->set_hidden();
# Enable worksheet protection
$worksheet->protect();
# The formula in this cell isn't visible
$worksheet->write('A1', '=1+2', $hidden);
</PRE>
</P>
<P>
Note: This offers weak protection even with a password, see the note in
relation to the <CODE>protect()</CODE> method.
</P>
<P>
<HR>
<H2><A NAME="set_align_">set_align()</A></H2>
<P>
<PRE>
Default state: Alignment is off
Default action: Left alignment
Valid args: 'left' Horizontal
'center'
'right'
'fill'
'justify'
'merge'
</PRE>
</P>
<P>
<PRE>
'top' Vertical
'vcenter'
'bottom'
'vjustify'
</PRE>
</P>
<P>
This method is used to set the horizontal and vertical text alignment
within a cell. Vertical and horizontal alignments can be combined. The
method is used as follows:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_align('center');
$format->set_align('vcenter');
$worksheet->set_row(0, 30);
$worksheet->write(0, 0, "X", $format);
</PRE>
</P>
<P>
Text can be aligned across two or more adjacent cells using the <CODE>merge</CODE> property. See also, the <CODE>set_merge()</CODE> method.
</P>
<P>
The <CODE>vjustify</CODE> (vertical justify) option can be used to provide automatic text wrapping in
a cell. The height of the cell will be adjusted to accommodate the wrapped
text. To specify where the text wraps use the <CODE>set_text_wrap()</CODE> method.
</P>
<P>
For further examples see the 'Alignment' worksheet created by formats.pl.
</P>
<P>
<HR>
<H2><A NAME="set_merge_">set_merge()</A></H2>
<P>
<PRE>
Default state: Cell merging is off
Default action: Turn cell merging on
Valid args: 1
</PRE>
</P>
<P>
Text can be aligned across two or more adjacent cells using the <CODE>set_merge()</CODE> method. This is an alias for the unintuitive <CODE>set_align('merge')</CODE> method call.
</P>
<P>
Only one cell should contain the text, the other cells should be blank:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_merge();
</PRE>
</P>
<P>
<PRE>
$worksheet->write(1, 1, 'Merged cells', $format);
$worksheet->write_blank(1, 2, $format);
</PRE>
</P>
<P>
See also the <CODE>merge1.pl</CODE>, <CODE>merge2.pl</CODE> and <CODE>merge3.pl</CODE> programs in the <CODE>examples</CODE> directory and the <CODE>merge_cells()</CODE> method.
</P>
<P>
<HR>
<H2><A NAME="set_text_wrap_">set_text_wrap()</A></H2>
<P>
<PRE>
Default state: Text wrap is off
Default action: Turn text wrap on
Valid args: 0, 1
</PRE>
</P>
<P>
Here is an example using the text wrap property, the escape character <CODE>\n</CODE> is used to indicate the end of line:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_text_wrap();
$worksheet->write(0, 0, "It's\na bum\nwrap", $format);
</PRE>
</P>
<P>
Excel will adjust the height of the row to accommodate the wrapped text. A
similar effect can be obtained without newlines using the <CODE>set_align('vjustify')</CODE> method. See the <CODE>textwrap.pl</CODE> program in the <CODE>examples</CODE> directory.
</P>
<P>
<HR>
<H2><A NAME="set_rotation_">set_rotation()</A></H2>
<P>
<PRE>
Default state: Text rotation is off
Default action: Rotation style 1
Valid args: 0 No rotation
1 Letters run from top to bottom
2 90 anticlockwise
3 90 clockwise
</PRE>
</P>
<P>
Set the rotation of the text in a cell. See the 'Alignment' worksheet
created by formats.pl. Note, fractional rotations aren't possible with the
Excel 5 format.
</P>
<P>
<HR>
<H2><A NAME="set_text_justlast_">set_text_justlast()</A></H2>
<P>
<PRE>
Default state: Justify last is off
Default action: Turn justify last on
Valid args: 0, 1
</PRE>
</P>
<P>
Only applies to Far Eastern versions of Excel.
</P>
<P>
<HR>
<H2><A NAME="set_pattern_">set_pattern()</A></H2>
<P>
<PRE>
Default state: Pattern is off
Default action: Solid fill is on
Valid args: 0 .. 31
</PRE>
</P>
<P>
Examples of the available patterns are shown in the 'Patterns' worksheet
created by formats.pl. However, it is unlikely that you will ever need
anything other than Pattern 1 which is a solid fill of the foreground
color.
</P>
<P>
<HR>
<H2><A NAME="set_fg_color_">set_fg_color()</A></H2>
<P>
<PRE>
Also applies to: set_bg_color
</PRE>
</P>
<P>
<PRE>
Default state: Color is off
Default action: Undefined
Valid args: See set_color()
</PRE>
</P>
<P>
Note, the foreground and background colours will only have an effect if the
cell pattern has been set. In the most common case you can specify the
solid fill pattern and the foreground colour as follows:
</P>
<P>
<PRE>
my $format = $workbook->addformat();
$format->set_pattern(); # Set pattern to 1, i.e. solid fill
$format->set_fg_color('green'); # Note foreground and not background
$worksheet->write(0, 0, "Ray", $format);
</PRE>
</P>
<P>
<HR>
<H2><A NAME="set_border_">set_border()</A></H2>
<P>
<PRE>
Also applies to: set_bottom()
set_top()
set_left()
set_right()
</PRE>
</P>
<P>
<PRE>
Default state: Border is off
Default action: Set border type 1
Valid args: 0 No border
1 Thin single border
2 Medium single border
3 Dashed border
4 Dotted border
5 Thick single border
6 Double line border
7 Hair border
</PRE>
</P>
<P>
A cell border is comprised of a border on the bottom, top, left and right.
These can be set to the same value using <CODE>set_border()</CODE> or individually using the relevant method calls shown above. Examples of
the available border styles are shown in the 'Borders' worksheet created by
formats.pl.
</P>
<P>
<HR>
<H2><A NAME="set_border_color_">set_border_color()</A></H2>
<P>
<PRE>
Also applies to: set_bottom_color()
set_top_color()
set_left_color()
set_right_color()
</PRE>
</P>
<P>
<PRE>
Default state: Color is off
Default action: Undefined
Valid args: See set_color()
</PRE>
</P>
<P>
Set the colour of the cell borders.
</P>
<P>
<HR>
<H2><A NAME="copy_format_">copy($format)</A></H2>
<P>
This method is used to copy all of the properties from one Format object to
another:
</P>
<P>
<PRE>
my $lorry1 = $workbook->addformat();
$lorry1->set_bold();
$lorry1->set_italic();
$lorry1->set_color('red'); # lorry1 is bold, italic and red
</PRE>
</P>
<P>
<PRE>
my $lorry2 = $workbook->addformat();
$lorry2->copy($lorry1);
$lorry2->set_color('yellow'); # lorry2 is bold, italic and yellow
</PRE>
</P>
<P>
It is only useful if you are using the method interface to Format
properties. It generally isn't required if you are setting Format
properties directly using hashes.
</P>
<P>
Note: this is not a copy constructor, both objects must exist prior to
copying.
</P>
<P>
<HR>
<H1><A NAME="COLOURS_IN_EXCEL">COLOURS IN EXCEL</A></H1>
<P>
Excel provides a colour palette of 56 colours. In Spreadsheet::WriteExcel
these colours are accessed via their palette index in the range 8..63. This
index is used to set the colour of fonts, cell patterns and cell borders.
For example:
</P>
<P>
<PRE>
my $format = $workbook->addformat(
color => 12, # index for blue
font => 'Arial',
size => 12,
bold => 1,
);
</PRE>
</P>
<P>
The most commonly used colours can also be accessed by name. The name acts
as a simple alias for the colour index:
</P>
<P>
<PRE>
black => 8
blue => 12
brown => 16
cyan => 15
gray => 23
green => 17
lime => 11
magenta => 14
navy => 18
orange => 53
purple => 20
red => 10
silver => 22
white => 9
yellow => 13
</PRE>
</P>
<P>
For example:
</P>
<P>
<PRE>
my $font = $workbook->addformat(color => 'red');
</PRE>
</P>
<P>
Users of VBA in Excel should note that the equivalent colour indices are in
the range 1..56 instead of 8..63.
</P>
<P>
If the default palette does not provide a required colour you can override
one of the built-in values. This is achieved by using the <CODE>set_custom_color()</CODE> workbook method to adjust the RGB (red green blue) components of the
colour:
</P>
<P>
<PRE>
my $ferrari = $workbook->set_custom_color(40, 216, 12, 12);
</PRE>
</P>
<P>
<PRE>
my $format = $workbook->addformat(
fg_color => $ferrari,
pattern => 1,
border => 1
);
</PRE>
</P>
<P>
<PRE>
$worksheet->write_blank('A1', $format);
</PRE>
</P>
<P>
Spreadsheet::WriteExcel uses the Excel 97/2000 default colour palette.
However, for backward compatibility the Excel 5 palette can be specified
instead using the <CODE>set_palette_xl5()</CODE> workbook method.
</P>
<P>
The default Excel colour palette is shown in <CODE>palette.html</CODE> in the <CODE>doc</CODE> directory of the distro. You can generate an Excel version of the palette
using <CODE>colors.pl</CODE> in the <CODE>examples</CODE> directory.
</P>
<P>
A comparison of the colour components in the Excel 5 and Excel 97+ colour
palettes is shown in <CODE>rgb5-97.txt</CODE> in the <CODE>doc</CODE> directory.
</P>
<P>
You may also find the following links helpful:
</P>
<P>
A detailed look at Excel's colour palette: <A
HREF="http://www.geocities.com/davemcritchie/excel/colors.htm">http://www.geocities.com/davemcritchie/excel/colors.htm</A>
</P>
<P>
A decimal RGB chart: <A
HREF="http://www.hypersolutions.org/pages/rgbdec.html">http://www.hypersolutions.org/pages/rgbdec.html</A>
</P>
<P>
A hex RGB chart: : <A
HREF="http://www.hypersolutions.org/pages/rgbhex.html">http://www.hypersolutions.org/pages/rgbhex.html</A>
</P>
<P>
<HR>
<H1><A NAME="DATES_IN_EXCEL">DATES IN EXCEL</A></H1>
<P>
Dates and times in Excel are represented by real numbers, for example
"Jan 1 2001 12:30 AM" is represented by the number 36892.521.
</P>
<P>
The integer part of the number stores the number of days since the epoch
and the fractional part stores the percentage of the day.
</P>
<P>
The epoch can be either 1900 or 1904. Excel for Windows uses 1900 and Excel
for Macintosh uses 1904. The epochs are:
</P>
<P>
<PRE>
1900: 0 January 1900 i.e. 31 December 1899
1904: 1 January 1904
</PRE>
</P>
<P>
By default Spreadsheet::WriteExcel uses the Windows/1900 format although it
generally isn't an issue since Excel on Windows and the Macintosh will
convert automatically between one system and the other. To use the 1904
epoch you must use the <CODE>set_1904()</CODE> workbook method.
</P>
<P>
There are two things to note about the 1900 date format. The first is that
the epoch starts on 0 January 1900. The second is that the year 1900 is
erroneously but deliberately treated as a leap year. Therefore you must add
an extra day to dates after 28 February 1900. The reason for this anomaly
is explained at <A
HREF="http://support.microsoft.com/support/kb/articles/Q181/3/70.asp">http://support.microsoft.com/support/kb/articles/Q181/3/70.asp</A>
</P>
<P>
A date or time in Excel is like any other number. To display the number as
a date you must apply a number format to it. Refer to the <CODE>set_num_format()</CODE> method above:
</P>
<P>
<PRE>
$format->set_num_format('mmm d yyyy hh:mm AM/PM');
$worksheet->write('A1', 36892.521 , $format); # Jan 1 2001 12:30 AM
</PRE>
</P>
<P>
The <CODE>Spreadsheet::WriteExcel::Utility</CODE> module that is included in the distro contains helper functions for dealing
with dates and times in Excel, for example:
</P>
<P>
<PRE>
$date = xl_date_list(2002, 1, 1); # 37257
$date = xl_parse_date("11 July 1997"); # 35622
$time = xl_parse_time('3:21:36 PM'); # 0.64
$date = xl_decode_date_EU("13 May 2002"); # 37389
</PRE>
</P>
<P>
These functions deal automatically with the s1900 leap year issue described
above.
</P>
<P>
The date and time functions are based on functions provided by the <CODE>Date::Calc</CODE> and <CODE>Date::Manip</CODE> modules. These modules are very useful if you plan to manipulate dates in
different formats.
</P>
<P>
There is also the <CODE>excel_date1.pl</CODE> program in the <CODE>examples</CODE> directory of the WriteExcel distribution which was written by Andrew
Benham. It contains a detailed description of the problems involved in
calculating dates in Excel. It does not require any external modules.
</P>
<P>
It is also possible to get Excel to calculate dates for you by defining a
function:
</P>
<P>
<PRE>
$worksheet->write('A1', '=DATEVALUE("1-Jan-2001")');
</PRE>
</P>
<P>
However, this carries a performance overhead in Spreadsheet::WriteExcel due
to the parsing of the formula and it shouldn't be used for programs that
deal with a large number of dates.
</P>
<P>
<HR>
<H1><A NAME="FORMULAS_AND_FUNCTIONS_IN_EXCEL">FORMULAS AND FUNCTIONS IN EXCEL</A></H1>
<P>
The first thing to note is that there are still some outstanding issues
with the implementation of formulas and functions:
</P>
<P>
<PRE>
* Writing a formula is much slower than writing the equivalent string.
* Unary minus isn't supported.
* You cannot use arrays constants, i.e. {1;2;3}, in functions.
* You cannot use embedded double quotes in strings.
* Whitespace is not preserved around operators.
</PRE>
</P>
<P>
However, these constraints will be removed in future versions. They are
here because of a trade-off between features and time.
</P>
<P>
The following is a brief introduction to formulas and functions in Excel
and Spreadsheet::WriteExcel.
</P>
<P>
A formula is a string that begins with an equals sign:
</P>
<P>
<PRE>
'=A1+B1'
'=AVERAGE(1, 2, 3)'
</PRE>
</P>
<P>
The formula can contain numbers, strings, boolean values, cell references,
cell ranges and functions. Formulas should be written as they appear in
Excel, that is cells and functions must be in uppercase.
</P>
<P>
Cells in Excel are referenced using the A1 notation system where the column
is designated by a letter and the row by a number. Columns range from A to
IV i.e. 0 to 255, rows range from 1 to 16384. The <CODE>Spreadsheet::WriteExcel::Utility</CODE> module that is included in the distro contains helper functions for dealing
with A1 notation, for example:
</P>
<P>
<PRE>
use Spreadsheet::WriteExcel::Utility;
($row, $col) = xl_cell_to_rowcol('C2'); # (1, 2)
$str = xl_rowcol_to_cell(1, 2); # C2
</PRE>
</P>
<P>
The Excel <CODE>$</CODE> notation in cell references is also supported. This allows you to specify
whether a row or column is relative or absolute. This only has an effect if
the cell is copied. The following examples show relative and absolute
values.
</P>
<P>
<PRE>
'=A1' # Column and row are relative
'=$A1' # Column is absolute and row is relative
'=A$1' # Column is relative and row is absolute
'=$A$1' # Column and row are absolute
</PRE>
</P>
<P>
Formulas can also refer to cells in other worksheets of the current
workbook. For example:
</P>
<P>
<PRE>
'=Sheet2!A1'
'=Sheet2!A1:A5'
'=Sheet2:Sheet3!A1'
'=Sheet2:Sheet3!A1:A5'
q{='Test Data'!A1}
q{='Test Data1:Test Data2'!A1}
</PRE>
</P>
<P>
The sheet reference and the cell reference are separated by <CODE>!</CODE> the exclamation mark symbol. If worksheet names contain spaces then Excel
requires that the name is enclosed in single quotes as shown in the last
two examples above. In this case you will have to use the quote operator <CODE>q{}</CODE> to protect the quotes. See <CODE>perlop</CODE> in the main Perl documentation. Only valid sheet names that have been added
using the <CODE>addworksheet()</CODE> method can be used in formulas. You cannot reference external workbooks.
</P>
<P>
The following table lists the operators that are available in Excel's
formulas. The majority of the operators are the same as Perl's, differences
are indicated:
</P>
<P>
<PRE>
Arithmetic operators:
=====================
Operator Meaning Example
+ Addition 1+2
- Subtraction 2-1
* Multiplication 2*3
/ Division 1/4
^ Exponentiation 2^3 # Equivalent to **
- Unary minus -(1+2) # Not yet supported
% Percent (Not modulus) 13% # Not supported, [1]
</PRE>
</P>
<P>
<PRE>
Comparison operators:
=====================
Operator Meaning Example
= Equal to A1 = B1 # Equivalent to ==
<> Not equal to A1 <> B1 # Equivalent to !=
> Greater than A1 > B1
< Less than A1 < B1
>= Greater than or equal to A1 >= B1
<= Less than or equal to A1 <= B1
</PRE>
</P>
<P>
<PRE>
String operator:
================
Operator Meaning Example
& Concatenation "Hello " & "World!" # [2]
</PRE>
</P>
<P>
<PRE>
Reference operators:
====================
Operator Meaning Example
: Range operator A1:A4 # [3]
, Union operator SUM(1, 2+2, B3) # [4]
</PRE>
</P>
<P>
<PRE>
Notes:
[1]: You can get a percentage with formatting and modulus with MOD().
[2]: Equivalent to ("Hello " . "World!") in Perl.
[3]: This range is equivalent to cells A1, A2, A3 and A4.
[4]: The comma behaves like the list separator in Perl.
</PRE>
</P>
<P>
The range and comma operators can have different symbols in non-English
versions of Excel. These will be supported in a later version of
Spreadsheet::WriteExcel. European users of Excel take note:
</P>
<P>
<PRE>
$worksheet->write('A1', '=SUM(1; 2; 3)'); # Wrong!!
$worksheet->write('A1', '=SUM(1, 2, 3)'); # Okay
</PRE>
</P>
<P>
The following table lists all of the core functions supported by Excel 5
and Spreadsheet::WriteExcel. Any additional functions that are available
through the "Analysis ToolPak" or other add-ins are not
supported. These functions have all been tested to verify that they work.
</P>
<P>
<PRE>
ABS DB INDIRECT NORMINV SLN
ACOS DCOUNT INFO NORMSDIST SLOPE
ACOSH DCOUNTA INT NORMSINV SMALL
ADDRESS DDB INTERCEPT NOT SQRT
AND DEGREES IPMT NOW STANDARDIZE
AREAS DEVSQ IRR NPER STDEV
ASIN DGET ISBLANK NPV STDEVP
ASINH DMAX ISERR ODD STEYX
ATAN DMIN ISERROR OFFSET SUBSTITUTE
ATAN2 DOLLAR ISLOGICAL OR SUBTOTAL
ATANH DPRODUCT ISNA PEARSON SUM
AVEDEV DSTDEV ISNONTEXT PERCENTILE SUMIF
AVERAGE DSTDEVP ISNUMBER PERCENTRANK SUMPRODUCT
BETADIST DSUM ISREF PERMUT SUMSQ
BETAINV DVAR ISTEXT PI SUMX2MY2
BINOMDIST DVARP KURT PMT SUMX2PY2
CALL ERROR.TYPE LARGE POISSON SUMXMY2
CEILING EVEN LEFT POWER SYD
CELL EXACT LEN PPMT T
CHAR EXP LINEST PROB TAN
CHIDIST EXPONDIST LN PRODUCT TANH
CHIINV FACT LOG PROPER TDIST
CHITEST FALSE LOG10 PV TEXT
CHOOSE FDIST LOGEST QUARTILE TIME
CLEAN FIND LOGINV RADIANS TIMEVALUE
CODE FINV LOGNORMDIST RAND TINV
COLUMN FISHER LOOKUP RANK TODAY
COLUMNS FISHERINV LOWER RATE TRANSPOSE
COMBIN FIXED MATCH REGISTER.ID TREND
CONCATENATE FLOOR MAX REPLACE TRIM
CONFIDENCE FORECAST MDETERM REPT TRIMMEAN
CORREL FREQUENCY MEDIAN RIGHT TRUE
COS FTEST MID ROMAN TRUNC
COSH FV MIN ROUND TTEST
COUNT GAMMADIST MINUTE ROUNDDOWN TYPE
COUNTA GAMMAINV MINVERSE ROUNDUP UPPER
COUNTBLANK GAMMALN MIRR ROW VALUE
COUNTIF GEOMEAN MMULT ROWS VAR
COVAR GROWTH MOD RSQ VARP
CRITBINOM HARMEAN MODE SEARCH VDB
DATE HLOOKUP MONTH SECOND VLOOKUP
DATEVALUE HOUR N SIGN WEEKDAY
DAVERAGE HYPGEOMDIST NA SIN WEIBULL
DAY IF NEGBINOMDIST SINH YEAR
DAYS360 INDEX NORMDIST SKEW ZTEST
</PRE>
</P>
<P>
You can also modify the module to support function names in the following
languages: German, French, Spanish, Portuguese, Dutch, Finnish, Italian and
Swedish. See the <CODE>function_locale.pl</CODE> program in the <CODE>examples</CODE> directory of the distro.
</P>
<P>
For a general introduction to Excel's formulas and an explanation of the
syntax of the function refer to the Excel help files or the following
links: <A
HREF="http://msdn.microsoft.com/library/default.asp?URL=/library/officedev/office97/s88f2.htm">http://msdn.microsoft.com/library/default.asp?URL=/library/officedev/office97/s88f2.htm</A>
and <A
HREF="http://msdn.microsoft.com/library/default.asp?URL=/library/officedev/office97/s992f.htm">http://msdn.microsoft.com/library/default.asp?URL=/library/officedev/office97/s992f.htm</A>
</P>
<P>
If your formula doesn't work in Spreadsheet::WriteExcel try the following:
</P>
<P>
<PRE>
1. Verify that the formula works in Excel (or Gnumeric or OpenOffice).
2. Ensure that it isn't on the TODO list at the start of this section.
3. Ensure that cell references and formula names are in uppercase.
4. Ensure that you are using ':' as the range operator, A1:A4.
5. Ensure that you are using ',' as the union operator, SUM(1,2,3).
6. Ensure the function is in the above table.
</PRE>
</P>
<P>
If you go through steps 1-6 and you still have a problem, mail me.
</P>
<P>
<HR>
<H1><A NAME="EXAMPLES">EXAMPLES</A></H1>
<P>
<HR>
<H2><A NAME="Example_1">Example 1</A></H2>
<P>
The following example shows some of the basic features of
Spreadsheet::WriteExcel.
</P>
<P>
<PRE>
#!/usr/bin/perl -w
</PRE>
</P>
<P>
<PRE>
use strict;
use Spreadsheet::WriteExcel;
</PRE>
</P>
<P>
<PRE>
# Create a new workbook called simple.xls and add a worksheet
my $workbook = Spreadsheet::WriteExcel->new("simple.xls");
my $worksheet = $workbook->addworksheet();
</PRE>
</P>
<P>
<PRE>
# The general syntax is write($row, $column, $token). Note that row and
# column are zero indexed
</PRE>
</P>
<P>
<PRE>
# Write some text
$worksheet->write(0, 0, "Hi Excel!");
</PRE>
</P>
<P>
<PRE>
# Write some numbers
$worksheet->write(2, 0, 3); # Writes 3
$worksheet->write(3, 0, 3.00000); # Writes 3
$worksheet->write(4, 0, 3.00001); # Writes 3.00001
$worksheet->write(5, 0, 3.14159); # TeX revision no.?
</PRE>
</P>
<P>
<PRE>
# Write some formulas
$worksheet->write(7, 0, '=A3 + A6');
$worksheet->write(8, 0, '=IF(A5>3,"Yes", "No")');
</PRE>
</P>
<P>
<PRE>
# Write a hyperlink
$worksheet->write(10, 0, '<A HREF="http://www.perl.com/">http://www.perl.com/</A>');
</PRE>
</P>
<br><center><img SRC="simple.gif" ALT="The output from simple.pl"></center>
<P>
<HR>
<H2><A NAME="Example_2">Example 2</A></H2>
<P>
The following is a general example which demonstrates some features of
working with multiple worksheets.
</P>
<P>
<PRE>
#!/usr/bin/perl -w
</PRE>
</P>
<P>
<PRE>
use strict;
use Spreadsheet::WriteExcel;
</PRE>
</P>
<P>
<PRE>
# Create a new Excel workbook
my $workbook = Spreadsheet::WriteExcel->new("regions.xls");
</PRE>
</P>
<P>
<PRE>
# Add some worksheets
my $north = $workbook->addworksheet("North");
my $south = $workbook->addworksheet("South");
my $east = $workbook->addworksheet("East");
my $west = $workbook->addworksheet("West");
</PRE>
</P>
<P>
<PRE>
# Add a Format
my $format = $workbook->addformat();
$format->set_bold();
$format->set_color('blue');
</PRE>
</P>
<P>
<PRE>
# Add a caption to each worksheet
foreach my $worksheet ($workbook->sheets()) {
$worksheet->write(0, 0, "Sales", $format);
}
</PRE>
</P>
<P>
<PRE>
# Write some data
$north->write(0, 1, 200000);
$south->write(0, 1, 100000);
$east->write (0, 1, 150000);
$west->write (0, 1, 100000);
</PRE>
</P>
<P>
<PRE>
# Set the active worksheet
$south->activate();
</PRE>
</P>
<P>
<PRE>
# Set the width of the first column
$south->set_column(0, 0, 20);
</PRE>
</P>
<P>
<PRE>
# Set the active cell
$south->set_selection(0, 1);
</PRE>
</P>
<br><center><img SRC="regions.gif" ALT="The output from regions.pl"></center>
<P>
<HR>
<H2><A NAME="Example_3">Example 3</A></H2>
<P>
This example shows how to use a conditional numerical format with colours
to indicate if a share price has gone up or down.
</P>
<P>
<PRE>
use strict;
use Spreadsheet::WriteExcel;
</PRE>
</P>
<P>
<PRE>
# Create a new workbook and add a worksheet
my $workbook = Spreadsheet::WriteExcel->new("stocks.xls");
my $worksheet = $workbook->addworksheet();
</PRE>
</P>
<P>
<PRE>
# Set the column width for columns 1, 2, 3 and 4
$worksheet->set_column(0, 3, 15);
</PRE>
</P>
<P>
<PRE>
# Create a format for the column headings
my $header = $workbook->addformat();
$header->set_bold();
$header->set_size(12);
$header->set_color('blue');
</PRE>
</P>
<P>
<PRE>
# Create a format for the stock price
my $f_price = $workbook->addformat();
$f_price->set_align('left');
$f_price->set_num_format('$0.00');
</PRE>
</P>
<P>
<PRE>
# Create a format for the stock volume
my $f_volume = $workbook->addformat();
$f_volume->set_align('left');
$f_volume->set_num_format('#,##0');
</PRE>
</P>
<P>
<PRE>
# Create a format for the price change. This is an example of a conditional
# format. The number is formatted as a percentage. If it is positive it is
# formatted in green, if it is negative it is formatted in red and if it is
# zero it is formatted as the default font colour (in this case black).
# Note: the [Green] format produces an unappealing lime green. Try
# [Color 10] instead for a dark green.
#
my $f_change = $workbook->addformat();
$f_change->set_align('left');
$f_change->set_num_format('[Green]0.0%;[Red]-0.0%;0.0%');
</PRE>
</P>
<P>
<PRE>
# Write out the data
$worksheet->write(0, 0, 'Company',$header);
$worksheet->write(0, 1, 'Price', $header);
$worksheet->write(0, 2, 'Volume', $header);
$worksheet->write(0, 3, 'Change', $header);
</PRE>
</P>
<P>
<PRE>
$worksheet->write(1, 0, 'Damage Inc.' );
$worksheet->write(1, 1, 30.25, $f_price ); # $30.25
$worksheet->write(1, 2, 1234567, $f_volume); # 1,234,567
$worksheet->write(1, 3, 0.085, $f_change); # 8.5% in green
</PRE>
</P>
<P>
<PRE>
$worksheet->write(2, 0, 'Dump Corp.' );
$worksheet->write(2, 1, 1.56, $f_price ); # $1.56
$worksheet->write(2, 2, 7564, $f_volume); # 7,564
$worksheet->write(2, 3, -0.015, $f_change); # -1.5% in red
</PRE>
</P>
<P>
<PRE>
$worksheet->write(3, 0, 'Rev Ltd.' );
$worksheet->write(3, 1, 0.13, $f_price ); # $0.13
$worksheet->write(3, 2, 321, $f_volume); # 321
$worksheet->write(3, 3, 0, $f_change); # 0 in the font color (black)
</PRE>
</P>
<br><center><img SRC="stocks.gif" ALT="The output from stocks.pl"></center>
<P>
<HR>
<H2><A NAME="Example_4">Example 4</A></H2>
<P>
The following is a simple example of using functions.
</P>
<P>
<PRE>
#!/usr/bin/perl -w
</PRE>
</P>
<P>
<PRE>
use strict;
use Spreadsheet::WriteExcel;
</PRE>
</P>
<P>
<PRE>
# Create a new workbook and add a worksheet
my $workbook = Spreadsheet::WriteExcel->new("stats.xls");
my $worksheet = $workbook->addworksheet('Test data');
</PRE>
</P>
<P>
<PRE>
# Set the column width for columns 1
$worksheet->set_column(0, 0, 20);
</PRE>
</P>
<P>
<PRE>
# Create a format for the headings
my $format = $workbook->addformat();
$format->set_bold();
</PRE>
</P>
<P>
<PRE>
# Write the sample data
$worksheet->write(0, 0, 'Sample', $format);
$worksheet->write(0, 1, 1);
$worksheet->write(0, 2, 2);
$worksheet->write(0, 3, 3);
$worksheet->write(0, 4, 4);
$worksheet->write(0, 5, 5);
$worksheet->write(0, 6, 6);
$worksheet->write(0, 7, 7);
$worksheet->write(0, 8, 8);
</PRE>
</P>
<P>
<PRE>
$worksheet->write(1, 0, 'Length', $format);
$worksheet->write(1, 1, 25.4);
$worksheet->write(1, 2, 25.4);
$worksheet->write(1, 3, 24.8);
$worksheet->write(1, 4, 25.0);
$worksheet->write(1, 5, 25.3);
$worksheet->write(1, 6, 24.9);
$worksheet->write(1, 7, 25.2);
$worksheet->write(1, 8, 24.8);
</PRE>
</P>
<P>
<PRE>
# Write some statistical functions
$worksheet->write(4, 0, 'Count', $format);
$worksheet->write(4, 1, '=COUNT(B1:I1)');
</PRE>
</P>
<P>
<PRE>
$worksheet->write(5, 0, 'Sum', $format);
$worksheet->write(5, 1, '=SUM(B2:I2)');
</PRE>
</P>
<P>
<PRE>
$worksheet->write(6, 0, 'Average', $format);
$worksheet->write(6, 1, '=AVERAGE(B2:I2)');
</PRE>
</P>
<P>
<PRE>
$worksheet->write(7, 0, 'Min', $format);
$worksheet->write(7, 1, '=MIN(B2:I2)');
</PRE>
</P>
<P>
<PRE>
$worksheet->write(8, 0, 'Max', $format);
$worksheet->write(8, 1, '=MAX(B2:I2)');
</PRE>
</P>
<P>
<PRE>
$worksheet->write(9, 0, 'Standard Deviation', $format);
$worksheet->write(9, 1, '=STDEV(B2:I2)');
</PRE>
</P>
<P>
<PRE>
$worksheet->write(10, 0, 'Kurtosis', $format);
$worksheet->write(10, 1, '=KURT(B2:I2)');
</PRE>
</P>
<br><center><img SRC="stats.gif" ALT="The output from stats.pl"></center>
<P>
<HR>
<H2><A NAME="Example_5">Example 5</A></H2>
<P>
The following example converts a tab separated file called <CODE>tab.txt</CODE> into an Excel file called <CODE>tab.xls</CODE>.
</P>
<P>
<PRE>
#!/usr/bin/perl -w
</PRE>
</P>
<P>
<PRE>
use strict;
use Spreadsheet::WriteExcel;
</PRE>
</P>
<P>
<PRE>
open (TABFILE, "tab.txt") or die "tab.txt: $!";
</PRE>
</P>
<P>
<PRE>
my $workbook = Spreadsheet::WriteExcel->new("tab.xls");
my $worksheet = $workbook->addworksheet();
</PRE>
</P>
<P>
<PRE>
# Row and column are zero indexed
my $row = 0;
</PRE>
</P>
<P>
<PRE>
while (<TABFILE>) {
chomp;
# Split on single tab
my @Fld = split('\t', $_);
</PRE>
</P>
<P>
<PRE>
my $col = 0;
foreach my $token (@Fld) {
$worksheet->write($row, $col, $token);
$col++;
}
$row++;
}
</PRE>
</P>
<P>
<HR>
<H2><A NAME="Additional_Examples">Additional Examples</A></H2>
<P>
If you performed a normal installation the following examples files should
have been copied to your <CODE>~site/Spreadsheet/WriteExcel/examples</CODE> directory:
</P>
<P>
The following is a description of the example files that are provided with
Spreadsheet::WriteExcel. They are intended to demonstrate the different
features and options of the module.
</P>
<P>
<PRE>
Getting started
===============
simple.pl An example of some of the basic features.
regions.pl Demonstrates multiple worksheets.
stats.pl Basic formulas and functions.
formats.pl Creates a demo of the available formatting.
demo.pl Creates a demo of some of the features.
</PRE>
</P>
<P>
<PRE>
Advanced
========
sales.pl An example of a simple sales spreadsheet.
stocks.pl Demonstrates conditional formatting.
headers.pl Examples of worksheet headers and footers.
write_array.pl Example of writing 1D or 2D arrays of data.
chess.pl An example of formatting using properties.
colors.pl Demo of the colour palette and named colours.
images.pl Adding bitmap images to worksheets.
stats_ext.pl Same as stats.pl with external references.
cgi.pl A simple CGI program.
mod_perl.pl A simple mod_perl program.
hyperlink1.pl Shows how to create web hyperlinks.
hyperlink2.pl Examples of internal and external hyperlinks.
merge1.pl A simple example of cell merging.
merge2.pl A more advanced example of cell merging.
merge3.pl Merge hyperlinks and merge vertically.
textwrap.pl Demonstrates text wrapping options.
panes.pl An examples of how to create panes.
protection.pl Example of cell locking and formula hiding.
copyformat.pl Example of copying a cell format.
win32ole.pl A sample Win32::OLE example for comparison.
easter_egg.pl Expose the Excel97 flight simulator. A must see.
</PRE>
</P>
<P>
<PRE>
Utility
=======
convertA1.pl Helper functions for dealing with A1 notation.
lecxe.pl Convert Excel to WriteExcel using Win32::OLE.
csv2xls.pl Program to convert a CSV file to an Excel file.
tab2xls.pl Program to convert a tab separated file to xls.
datecalc1.pl Convert Unix/Perl time to Excel time.
datecalc2.pl Calculate an Excel date using Date::Calc.
writemany.pl Write an 2d array of values in one go.
</PRE>
</P>
<P>
<PRE>
Developer
=========
function_locale.pl Add non-English function names to Formula.pm.
filehandle.pl Examples of working with filehandles.
writeA1.pl Example of how to extend the module.
comments.pl Add cell comments to Excel 5 worksheets.
bigfile.pl Write past the 7MB limit with OLE::Storage_Lite.
</PRE>
</P>
<P>
There are additional examples of a CGI application that uses
Spreadsheet::WriteExcel available at the website of the German Unix/web
journal iX: <A
HREF="ftp://ftp.heise.de/pub/ix/ix_listings/2001_06/perl.tgz">ftp://ftp.heise.de/pub/ix/ix_listings/2001_06/perl.tgz</A>
</P>
<P>
<HR>
<H1><A NAME="LIMITATIONS">LIMITATIONS</A></H1>
<P>
The following limits are imposed by Excel or the version of the BIFF file
that has been implemented:
</P>
<P>
<PRE>
Description Limit Source
----------------------------------- ------ -------
Maximum number of chars in a string 255 Excel 5
Maximum number of columns 256 Excel All versions
Maximum number of rows in Excel 5 16384 Excel 5
Maximum number of rows in Excel 97 65536 Excel 97
Maximum chars in a sheet name 31 Excel All versions
Maximum chars in a header/footer 254 Excel All versions
</PRE>
</P>
<P>
Note: the maximum row reference in a formula is the Excel 5 row limit of
16384.
</P>
<P>
The minimum file size is 6K due to the OLE overhead. The maximum file size
is approximately 7MB (7087104 bytes) of BIFF data. This can be extended by
using Takanori Kawai's OLE::Storage_Lite module <A
HREF="http://search.cpan.org/search?dist=OLE-Storage_Lite">http://search.cpan.org/search?dist=OLE-Storage_Lite</A>
see the <CODE>bigfile.pl</CODE> example in the <CODE>examples</CODE> directory of the distro.
</P>
<P>
<HR>
<H1><A NAME="REQUIREMENTS">REQUIREMENTS</A></H1>
<P>
This module requires Perl 5.005 (or later) and Parse::RecDescent: <A
HREF="http://search.cpan.org/search?dist=Parse-RecDescent">http://search.cpan.org/search?dist=Parse-RecDescent</A>
</P>
<P>
<HR>
<H1><A NAME="PORTABILITY">PORTABILITY</A></H1>
<P>
Spreadsheet::WriteExcel will work on the majority of Windows, UNIX and
Macintosh platforms. Specifically, the module will work on any system where
perl packs floats in the 64 bit IEEE format. The float must also be in
little-endian format but it will be reversed if necessary. Thus:
</P>
<P>
<PRE>
print join(" ", map { sprintf "%#02x", $_ } unpack("C*", pack "d", 1.2345)), "\n";
</PRE>
</P>
<P>
should give (or in reverse order):
</P>
<P>
<PRE>
0x8d 0x97 0x6e 0x12 0x83 0xc0 0xf3 0x3f
</PRE>
</P>
<P>
In general, if you don't know whether your system supports a 64 bit IEEE
float or not, it probably does. If your system doesn't, WriteExcel will <CODE>croak()</CODE> with the message given in the <A HREF="#DIAGNOSTICS">DIAGNOSTICS</A> section. You can check which platforms the module has been tested on at the
CPAN testers site: <A
HREF="http://testers.cpan.org/search?request=dist&dist=Spreadsheet-WriteExcel">http://testers.cpan.org/search?request=dist&dist=Spreadsheet-WriteExcel</A>
</P>
<P>
<HR>
<H1><A NAME="DIAGNOSTICS">DIAGNOSTICS</A></H1>
<DL>
<DT><A NAME="item_Filename">Filename required by Spreadsheet::WriteExcel->new()</A><DD>
<P>
A filename must be given in the constructor.
</P>
<DT><A NAME="item_Can">Can't open filename. It may be in use or protected.</A><DD>
<P>
The file cannot be opened for writing. The directory that you are writing
to may be protected or the file may be in use by another program.
</P>
<DT><A NAME="item_Unable">Unable to create tmp files via IO::File->new_tmpfile().</A><DD>
<P>
This is a <CODE>-w</CODE> warning. You will see it if you are using Spreadsheet::WriteExcel in an
environment where temporary files cannot be created, in which case all data
will be stored in memory. The warning is for information only: it does not
affect execution but it may affect the speed of execution for large files.
</P>
<DT><A NAME="item_Maximum">Maximum file size, 7087104, exceeded.</A><DD>
<P>
The current OLE implementation only supports a maximum BIFF file of this
size. This limit can be extended, see the <A HREF="#LIMITATIONS">LIMITATIONS</A> section.
</P>
<DT>Can't locate Parse/RecDescent.pm in @INC ...<DD>
<P>
Spreadsheet::WriteExcel requires the Parse::RecDescent module. Download it
from CPAN: <A
HREF="http://search.cpan.org/search?dist=Parse-RecDescent">http://search.cpan.org/search?dist=Parse-RecDescent</A>
</P>
<DT><A NAME="item_Couldn">Couldn't parse formula ...</A><DD>
<P>
There are a large number of warnings which relate to badly formed formulas
and functions. See the <A HREF="#FORMULAS_AND_FUNCTIONS_IN_EXCEL">FORMULAS AND FUNCTIONS IN EXCEL</A> section for suggestions on how to avoid these errors.
</P>
<DT><A NAME="item_Required">Required floating point format not supported on this platform.</A><DD>
<P>
Operating system doesn't support 64 bit IEEE float or it is byte-ordered in
a way unknown to WriteExcel.
</P>
</DL>
<P>
<HR>
<H1><A NAME="THE_EXCEL_BINARY_FORMAT">THE EXCEL BINARY FORMAT</A></H1>
<P>
The following is some general information about the Excel binary format for
anyone who may be interested.
</P>
<P>
Excel data is stored in the "Binary Interchange File Format"
(BIFF) file format. Details of this format are given in the Excel SDK, the
"Excel Developer's Kit" from Microsoft Press. It is also included
in the MSDN CD library but is no longer available on the MSDN website. An
older version of the BIFF documentation is available at <A
HREF="http://www.cubic.org/source/archive/fileform/misc/excel.txt">http://www.cubic.org/source/archive/fileform/misc/excel.txt</A>
</P>
<P>
Charles Wybble has collected together almost all of the available
information about the Excel file format. See "The Chicago
Project" at <A
HREF="http://chicago.sourceforge.net/devel/">http://chicago.sourceforge.net/devel/</A>
</P>
<P>
Daniel Rentz of OpenOffice has also written a detailed description of the
Excel workbook records, see <A
HREF="http://sc.openoffice.org/excelfileformat.pdf">http://sc.openoffice.org/excelfileformat.pdf</A>
</P>
<P>
The BIFF portion of the Excel file is comprised of contiguous binary
records that have different functions and that hold different types of
data. Each BIFF record is comprised of the following three parts:
</P>
<P>
<PRE>
Record name; Hex identifier, length = 2 bytes
Record length; Length of following data, length = 2 bytes
Record data; Data, length = variable
</PRE>
</P>
<P>
The BIFF data is stored along with other data in an OLE Compound File. This
is a structured storage which acts like a file system within a file. A
Compound File is comprised of storages and streams which, to follow the
file system analogy, are like directories and files.
</P>
<P>
The documentation for the OLE::Storage module, <A
HREF="http://user.cs.tu-berlin.de/~schwartz/pmh/guide.html">http://user.cs.tu-berlin.de/~schwartz/pmh/guide.html</A>
, contains one of the few descriptions of the OLE Compound File in the
public domain. The Digital Imaging Group have also detailed the OLE format
in the JPEG2000 specification: see Appendix A of <A
HREF="http://www.i3a.org/pdf/wg1n1017.pdf">http://www.i3a.org/pdf/wg1n1017.pdf</A>
</P>
<P>
For a open source implementation of the OLE library see the 'cole' library
at <A HREF="http://atena.com/libole2.php">http://atena.com/libole2.php</A>
</P>
<P>
The source code for the Excel plugin of the Gnumeric spreadsheet also
contains information relevant to the Excel BIFF format and the OLE
container, <A
HREF="http://www.ximian.com/apps/gnumeric.php3">http://www.ximian.com/apps/gnumeric.php3</A>
and <A
HREF="ftp://ftp.ximian.com/pub/ximian-source/">ftp://ftp.ximian.com/pub/ximian-source/</A>
</P>
<P>
In addition the source code for OpenOffice is available at <A
HREF="http://www.openoffice.org/">http://www.openoffice.org/</A>
</P>
<P>
An article describing Spreadsheet::WriteExcel and how it works appears in
Issue #19 of The Perl Journal, <A
HREF="http://www.samag.com/documents/s=1272/sam05030004/">http://www.samag.com/documents/s=1272/sam05030004/</A>
It is reproduced, by kind permission, in the <CODE>doc</CODE> directory of the distro.
</P>
<P>
Please note that the provision of this information does not constitute an
invitation to start hacking at the BIFF or OLE file formats. There are more
interesting ways to waste your time. ;-)
</P>
<P>
<HR>
<H1><A NAME="WRITING_EXCEL_FILES">WRITING EXCEL FILES</A></H1>
<P>
Depending on your requirements, background and general sensibilities you
may prefer one of the following methods of getting data into Excel:
</P>
<P>
* Win32::OLE module and office automation. This requires a Windows platform
and an installed copy of Excel. This is the most powerful and complete
method for interfacing with Excel. See <A
HREF="http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/faq/Windows/ActivePerl-Winfaq12.html">http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/faq/Windows/ActivePerl-Winfaq12.html</A>
and <A
HREF="http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/site/lib/Win32/OLE.html">http://www.activestate.com/ASPN/Reference/Products/ActivePerl-5.6/site/lib/Win32/OLE.html</A>
If your main platform is UNIX but you have the resources to set up a
separate Win32/MSOffice server, you can convert office documents to text,
postscript or PDF using Win32::OLE. For a demonstration of how to do this
using Perl see Docserver: <A
HREF="http://search.cpan.org/search?mode=module&query=docserver">http://search.cpan.org/search?mode=module&query=docserver</A>
</P>
<P>
* CSV, comma separated variables or text. If the file extension is <CODE>csv</CODE>, Excel will open and convert this format automatically. Generating a valid
CSV file isn't as easy as it seems. Have a look at the DBD::RAM, DBD::CSV,
Text::xSV and Text::CSV_XS modules.
</P>
<P>
* DBI with DBD::ADO or DBD::ODBC. Excel files contain an internal index
table that allows them to act like a database file. Using one of the
standard Perl database modules you can connect to an Excel file as a
database.
</P>
<P>
* DBD::Excel, you can also access Spreadsheet::WriteExcel using the
standard DBI interface via Takanori Kawai's DBD::Excel module <A
HREF="http://search.cpan.org/search?dist=DBD-Excel.">http://search.cpan.org/search?dist=DBD-Excel.</A>
</P>
<P>
* Spreadsheet::WriteExcel::Simple for an easier interface to a new Excel
file: <A
HREF="http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-Simple">http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-Simple</A>
</P>
<P>
* Spreadsheet::WriteExcel::FromDB to create an Excel file directly from a
DB table: <A
HREF="http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-FromDB">http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-FromDB</A>
</P>
<P>
* HTML tables. This is an easy way of adding formatting via a text based
format.
</P>
<P>
* XML, the Excel XML and HTML file specification are available from <A
HREF="http://msdn.microsoft.com/library/officedev/ofxml2k/ofxml2k.htm">http://msdn.microsoft.com/library/officedev/ofxml2k/ofxml2k.htm</A>
</P>
<P>
For other Perl-Excel modules try the following search: <A
HREF="http://search.cpan.org/search?mode=module&query=excel">http://search.cpan.org/search?mode=module&query=excel</A>
</P>
<P>
<HR>
<H1><A NAME="READING_EXCEL_FILES">READING EXCEL FILES</A></H1>
<P>
To read data from Excel files try:
</P>
<P>
* Spreadsheet::ParseExcel. This uses the OLE::Storage-Lite module to
extract data from an Excel file. <A
HREF="http://search.cpan.org/search?dist=Spreadsheet-ParseExcel">http://search.cpan.org/search?dist=Spreadsheet-ParseExcel</A>
</P>
<P>
* Spreadsheet::ParseExcel_XLHTML. This module uses
Spreadsheet::ParseExcel's interface but uses xlHtml (see below) to do the
conversion: <A
HREF="http://search.cpan.org/search?dist=Spreadsheet-ParseExcel_XLHTML">http://search.cpan.org/search?dist=Spreadsheet-ParseExcel_XLHTML</A>
Spreadsheet::ParseExcel_XLHTML
</P>
<P>
* There are also open source C/C++ projects. Try the xlHtml "Excel to
HTML Converter" project at <A
HREF="http://www.xlhtml.org/">http://www.xlhtml.org/</A> and the OLE
Filters Project at <A
HREF="http://atena.com/libole2.php.">http://atena.com/libole2.php.</A>
</P>
<P>
* DBD::Excel, you can also access Spreadsheet::ParseExcel using the
standard DBI interface via Takanori Kawai's DBD::Excel module <A
HREF="http://search.cpan.org/search?dist=DBD-Excel.">http://search.cpan.org/search?dist=DBD-Excel.</A>
</P>
<P>
* Win32::OLE module and office automation. See, the section <A HREF="#WRITING_EXCEL_FILES">WRITING EXCEL FILES</A>.
</P>
<P>
* HTML tables. If the files are saved from Excel in a HTML format the data
can be accessed using HTML::TableExtract <A
HREF="http://search.cpan.org/search?dist=HTML-TableExtract">http://search.cpan.org/search?dist=HTML-TableExtract</A>
</P>
<P>
* DBI with DBD::ADO or DBD::ODBC. See, the section <A HREF="#WRITING_EXCEL_FILES">WRITING EXCEL FILES</A>.
</P>
<P>
* XML::Excel converts Excel files to XML using Spreadsheet::ParseExcel <A
HREF="http://search.cpan.org/search?dist=XML-Excel.">http://search.cpan.org/search?dist=XML-Excel.</A>
</P>
<P>
* OLE::Storage, aka LAOLA. This is a Perl interface to OLE file formats. In
particular, the distro contains an Excel to HTML converter called Herbert,
<A
HREF="http://user.cs.tu-berlin.de/~schwartz/pmh/">http://user.cs.tu-berlin.de/~schwartz/pmh/</A>
This has been superseded by the Spreadsheet::ParseExcel module.
</P>
<P>
For other Perl-Excel modules try the following search: <A
HREF="http://search.cpan.org/search?mode=module&query=excel">http://search.cpan.org/search?mode=module&query=excel</A>
</P>
<P>
If you wish to view Excel files on a UNIX/Linux platform check out the
excellent Gnumeric spreadsheet application at <A
HREF="http://www.gnome.org/projects/gnumeric/">http://www.gnome.org/projects/gnumeric/</A>
or OpenOffice at <A
HREF="http://www.openoffice.org/">http://www.openoffice.org/</A>
</P>
<P>
If you wish to view Excel files on a Windows platform which doesn't have
Excel installed you can use the free Microsoft Excel Viewer <A
HREF="http://officeupdate.microsoft.com/2000/downloaddetails/xlviewer.htm">http://officeupdate.microsoft.com/2000/downloaddetails/xlviewer.htm</A>
</P>
<P>
<HR>
<H1><A NAME="BUGS">BUGS</A></H1>
<P>
Formulas are formulae.
</P>
<P>
Nested formulas sometimes aren't parsed correctly and give a result of
"#VALUE". This will be fixed in a later release.
</P>
<P>
Spreadsheet::ParseExcel: All formulas created by Spreadsheet::WriteExcel
are read as having a value of zero. This is because Spreadsheet::WriteExcel
only stores the formula and not the calculated result.
</P>
<P>
OpenOffice: Numerical formats are not displayed due to some missing records
in Spreadsheet::WriteExcel. URLs are not displayed as links.
</P>
<P>
Gnumeric: Some formatting is not displayed correctly. URLs are not
displayed as links.
</P>
<P>
MS Access: The Excel files that are produced by this module are not
compatible with MS Access. Use DBI or ODBC instead.
</P>
<P>
The lack of a portable way of writing a little-endian 64 bit IEEE float.
</P>
<P>
<HR>
<H1><A NAME="TO_DO">TO DO</A></H1>
<P>
The roadmap is as follows:
</P>
<UL>
<LI><A NAME="item_Add">Add formula caching to speed up the writing of formulas.</A>
<LI><A NAME="item_Add">Add a user definable temp file directory for IIS users.</A>
<LI><A NAME="item_Move">Move to Excel97/2000 format as standard. This will allow strings greater than 255 characters and hopefully Unicode. The Excel 5 format will be optional. This is a priority feature.</A>
</UL>
<P>
You can keep up to date with future release by registering as a user with
Freshmeat <A HREF="http://freshmeat.net/">http://freshmeat.net/</A> and
subscribing to Spreadsheet::WriteExcel at the project page <A
HREF="http://freshmeat.net/projects/writeexcel/">http://freshmeat.net/projects/writeexcel/</A>
You will then receive mailed updates when a new version is released.
Alternatively you can keep an eye on <A
HREF="news://comp.lang.perl.announce">news://comp.lang.perl.announce</A>
</P>
<P>
Also, here are some of the most requested features that probably won't get
added:
</P>
<UL>
<LI><A NAME="item_Graphs">Graphs. The format is documented but it would require too much work to implement. It would also require too much work to design a useable interface to the hundreds of features in an Excel graph. So that's two too much works. Nevertheless, I do hope to *try* implement graphs. However, it is a long term goal. It won't be available for at least 6 months, even if you read this in 6 months time.</A>
<LI><A NAME="item_Macros">Macros. This would solve the previous problem neatly. However, the format of Excel macros isn't documented.</A>
<LI><A NAME="item_Some">Some feature that you really need. ;-)</A>
</UL>
<P>
If there is some feature of an Excel file that you really, really need then
you should use Win32::OLE with Excel on Windows.
</P>
<P>
<HR>
<H1><A NAME="SEE_ALSO">SEE ALSO</A></H1>
<P>
Spreadsheet::ParseExcel. <A
HREF="http://search.cpan.org/search?dist=Spreadsheet-ParseExcel">http://search.cpan.org/search?dist=Spreadsheet-ParseExcel</A>
</P>
<P>
Spreadsheet::WriteExcel::Simple. <A
HREF="http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-Simple">http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-Simple</A>
</P>
<P>
Spreadsheet::WriteExcel::FromDB. <A
HREF="http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-FromDB">http://search.cpan.org/search?dist=Spreadsheet-WriteExcel-FromDB</A>
</P>
<P>
"Reading and writing Excel files with Perl" by Teodor Zlatanov,
atIBM developerWorks: <A
HREF="http://www-106.ibm.com/developerworks/library/l-pexcel/">http://www-106.ibm.com/developerworks/library/l-pexcel/</A>
</P>
<P>
"Excel-Dateien mit Perl erstellen - Controller im Glck" by Peter
Dintelmann and Christian Kirsch in the German Unix/web journal iX: <A
HREF="http://www.heise.de/ix/artikel/2001/06/175/">http://www.heise.de/ix/artikel/2001/06/175/</A>
</P>
<P>
"Spreadsheet::WriteExcel" in The Perl Journal: <A
HREF="http://www.samag.com/documents/s=1272/sam05030004/">http://www.samag.com/documents/s=1272/sam05030004/</A>
</P>
<P>
Spreadsheet::WriteExcel documentation in Japanese by Takanori Kawai. <A
HREF="http://member.nifty.ne.jp/hippo2000/perltips/Spreadsheet/WriteExcel.htm">http://member.nifty.ne.jp/hippo2000/perltips/Spreadsheet/WriteExcel.htm</A>
</P>
<P>
Oesterly user brushes with fame: <A
HREF="http://oesterly.com/releases/12102000.html">http://oesterly.com/releases/12102000.html</A>
</P>
<P>
<HR>
<H1><A NAME="ACKNOWLEDGEMENTS">ACKNOWLEDGEMENTS</A></H1>
<P>
The following people contributed to the debugging and testing of
Spreadsheet::WriteExcel:
</P>
<P>
Alexander Farber, Arthur@ais, Artur Silveira da Cunha, Borgar Olsen, Brian
White, Cedric Bouvier, CPAN testers, Daniel Berger, Daniel Gardner, Ernesto
Baschny, Felipe Prez Galiana, Hanc Pavel, Harold Bamford, James Holmes,
Johan Ekenberg, J.C. Wren, Kenneth Stacey, Keith Miller, Kyle Krom, Markus
Schmitz, Michael Buschauer, Mike Blazer, Michael Erickson, Paul J. Falbe,
Paul Medynski, Peter Dintelmann, Reto Badertscher, Rich Sorden, Shane
Ashby, Shenyu Zheng, Steve Sapovits, Sven Passig, Vahe Sarkissian.
</P>
<P>
The following people contributed code, examples or Excel information:
</P>
<P>
Andrew Benham, Bill Young, Cedric Bouvier, Daniel Rentz, Ian Penman,
Pierre-Jean Vouette, Marco Geri, Sam Kington, Takanori Kawai, Tom
O'Sullivan.
</P>
<P>
Additional thanks to Takanori Kawai for translating the documentation into
Japanese.
</P>
<P>
Dirk Eddelbuettel maintains the Debian distro.
</P>
<P>
Thanks to Damian Conway for the excellent Parse::RecDescent.
</P>
<P>
Thanks to Michael Meeks and Jody Goldberg for their work on Gnumeric.
</P>
<P>
<HR>
<H1><A NAME="AUTHOR">AUTHOR</A></H1>
<P>
John McNamara <A HREF="mailto:jmcnamara@cpan.org">jmcnamara@cpan.org</A>
</P>
<P>
<PRE>
Had I the heavens' embroidered cloths,
Enwrought with golden and silver light,
The blue and the dim and the dark cloths
Of night and light and the half-light,
I would spread the cloths under your feet:
But I, being poor, have only my dreams;
I have spread my dreams under your feet;
Tread softly because you tread on my dreams.
-- W. B. Yeats
</PRE>
</P>
<P>
<HR>
<H1><A NAME="COPYRIGHT">COPYRIGHT</A></H1>
<P>
MM-MMII, John McNamara.
</P>
<P>
All Rights Reserved. This module is free software. It may be used,
redistributed and/or modified under the same terms as Perl itself.
</P>
</BODY>
</HTML>
|