how to output excel to textfile?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nithinpes
    Recognized Expert Contributor
    • Dec 2007
    • 410

    #16
    Originally posted by poolboi
    ok i figured out found it somewhere
    basically it's to print arrays into columns

    so say @array1, @array2, @array3 into column
    the below code works,
    but can someone explain to me the principle behind this code how it works?

    [CODE=perl]

    while(@array1 || @array2 || @array3) {
    printf FILE ("%-10s %-10s %-10s\n",
    shift(@array1) || ' ',
    shift(@array2) || ' ',
    shift(@array3) || ' ',
    );
    } [/CODE]

    The logic of this is code is like this:
    - The code block in while loop as long as any of the three arrays exist i.e. if the arrays are of unequal size, the loop iterates until the last element in the largest array is processed.
    - The printf() statement will format the output. In this case, a ten characters' space is left between the first characters of consecutive words.
    - The three parameters to be printed are the elements of the 3 arrays.
    - shift() statement keeps on removing the first element from the array. If any of the arrays is emptied, the shift() fails and the space character after OR(||) will be printed.

    Comment

    • poolboi
      New Member
      • Jan 2008
      • 170

      #17
      i see..ok
      thanks for the enlightenment
      cheers, :)

      Comment

      Working...