gt: 				for (int i=0;i<meta.getOutputFields().length;i++)
context:  /* Copyright (c) 2007 Pentaho Corporation.  All rights reserved. 
   * This software was developed by Pentaho Corporation and is provided under the terms 
   * of the GNU Lesser General Public License, Version 2.1. You may not use 
   * this file except in compliance with the license. If you need a copy of the license, 
   * please go to http://www.gnu.org/licenses/lgpl-2.1.txt. The Original Code is Pentaho 
   * Data Integration.  The Initial Developer is Pentaho Corporation.
   *
   * Software distributed under the GNU Lesser Public License is distributed on an "AS IS" 
   * basis, WITHOUT WARRANTY OF ANY KIND, either express or  implied. Please refer to 
   * the license for the specific language governing your rights and limitations.*/
   
  
  package org.pentaho.di.trans.steps.exceloutput;
  
  import java.io.File;
  import java.util.Locale;
  
  import jxl.Workbook;
  import jxl.WorkbookSettings;
  import jxl.write.DateFormat;
  import jxl.write.DateFormats;
  import jxl.write.DateTime;
  import jxl.write.Label;
  import jxl.write.NumberFormat;
  import jxl.write.WritableCellFormat;
  import jxl.write.WritableFont;
  
  import org.apache.commons.vfs.FileObject;
  import org.pentaho.di.core.Const;
  import org.pentaho.di.core.ResultFile;
  import org.pentaho.di.core.exception.KettleException;
  import org.pentaho.di.core.row.ValueMeta;
  import org.pentaho.di.core.row.ValueMetaInterface;
  import org.pentaho.di.core.vfs.KettleVFS;
  import org.pentaho.di.trans.Trans;
  import org.pentaho.di.trans.TransMeta;
  import org.pentaho.di.trans.step.BaseStep;
  import org.pentaho.di.trans.step.StepDataInterface;
  import org.pentaho.di.trans.step.StepInterface;
  import org.pentaho.di.trans.step.StepMeta;
  import org.pentaho.di.trans.step.StepMetaInterface;
  
  
  /**
   * Converts input rows to excel cells and then writes this information to one or more files.
   * 
   * @author Matt
   * @since 7-sep-2006
   */
  public class ExcelOutput extends BaseStep implements StepInterface
  {
  	private ExcelOutputMeta meta;
  	private ExcelOutputData data;
  
  	public ExcelOutput(StepMeta stepMeta, StepDataInterface stepDataInterface, int copyNr, TransMeta transMeta, Trans trans)
  	{
  		super(stepMeta, stepDataInterface, copyNr, transMeta, trans);
  	}
      
  	public boolean processRow(StepMetaInterface smi, StepDataInterface sdi) throws KettleException
  	{
  		meta=(ExcelOutputMeta)smi;
  		data=(ExcelOutputData)sdi;
  
  		Object[] r=getRow();       // This also waits for a row to be finished.
  		if (first && r != null) {
  			// get the RowMeta, rowMeta is only set when a row is read
  			data.previousMeta = getInputRowMeta().clone();
  			//do not set first=false, below is another part that uses first
  			
  			if (meta.isAutoSizeColums())
  			{
  				if(meta.getOutputFields()!=null && meta.getOutputFields().length>0)
  					data.fieldsWidth = new int[meta.getOutputFields().length];
  				else
  					data.fieldsWidth = new int[data.previousMeta.size()];
  			}
  			
  			
  			if(meta.isDoNotOpenNewFileInit())
  			{
  				data.oneFileOpened=true;
  			
  		         if (!openNewFile())
  				 {
  					 logError("Couldn't open file "+buildFilename());
  					 return false;
  				 }
  		          // If we need to write a header, do so...
  		          //
  		         if(meta.isHeaderEnabled() && !data.headerWrote)
  				 {
  		        	 writeHeader();
  		        	 data.headerWrote=true;
  				 }
  			}else
  			{
  				  // If we need to write a header, do so...
  		          //
  		         if(meta.isHeaderEnabled() && !data.headerWrote)
  				 {
  		        	 writeHeader();
  		        	 data.headerWrote=true;
  				 }
  			}
  		}
  		
  		// If we split the data stream in small XLS files, we need to do this here...
  		//
  		if ( r!=null && getLinesOutput()>0 && meta.getSplitEvery()>0 && ((getLinesOutput()+1)%meta.getSplitEvery())==0)
  		{
  			// Not finished: open another file...
  			if (r!=null)
  			{
  				closeFile();
  				if (!openNewFile())
  				{
  					logError("Unable to open new file (split #"+data.splitnr+"...");
  					setErrors(1);
  					return false;
  				}
  		          // If we need to write a header, do so...
  		          //
  		         if(meta.isHeaderEnabled() && !data.headerWrote)
  				 {
  		        	 writeHeader();
  		        	 data.headerWrote=true;
  				 }
  			}
  		}
  		
  		if (r==null)  // no more input to be expected...
  		{
  			setOutputDone();
  			return false;
  		}
  		
  		boolean result=writeRowToFile(r);
  		if (!result)
  		{
  			setErrors(1);
  			stopAll();
  			return false;
  		}
  		
  		putRow(data.previousMeta, r);       // in case we want it to go further...
  		
          if (checkFeedback(getLinesOutput())) 
          {
          	if(log.isBasic()) logBasic("linenr "+getLinesOutput());
          }
  		
  		return result;
  	}
  
  	private boolean writeRowToFile(Object[] r)
  	{
  		Object v;
  		
  		try
  		{	
  			if (first)
  			{
  				first=false;
  				
  				data.fieldnrs=new int[meta.getOutputFields().length];
  				for (int i=0;i<meta.getOutputFields().length;i++)
  				{
  					data.fieldnrs[i]=data.previousMeta.indexOfValue(meta.getOutputFields()[i].getName());
  					if (data.fieldnrs[i]<0)
  					{
  						logError("Field ["+meta.getOutputFields()[i].getName()+"] couldn't be found in the input stream!");
  						setErrors(1);
  						stopAll();
  						return false;
  					}
  				}
  			}
  
  			if (meta.getOutputFields()==null || meta.getOutputFields().length==0)
  			{	
  				/*
  				 * Write all values in stream to text file.
  				 */
  				for (int i=0;i<data.previousMeta.size();i++)
  				{
  					v=r[i];
  					if(!writeField(v, data.previousMeta.getValueMeta(i), null, i)) return false;
  					
  				}
                  // go to the next line
                  data.positionX = 0;
                  data.positionY++;
                  
                  
  			}
  			else
  			{
  				/*
  				 * Only write the fields specified!
  				 */
  