All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hfg.xml.msoffice2003.spreadsheetml.ExcelCell Maven / Gradle / Ivy

There is a newer version: 20240423
Show newest version
package com.hfg.xml.msoffice2003.spreadsheetml;

import com.hfg.xml.XMLTag;


//------------------------------------------------------------------------------
/**
 Cell tag for use with Microsoft's Office 2003 SpreadsheetML.

 @author J. Alex Taylor, hairyfatguy.com
 */
//------------------------------------------------------------------------------
// com.hfg Library
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
// [email protected]
//------------------------------------------------------------------------------

public class ExcelCell extends XMLTag
{
   private ExcelData mStringDataTag;  // To allow easier addData() functionality

   //---------------------------------------------------------------------------
   public ExcelCell()
   {
      super(SpreadsheetML.CELL);
   }

   //---------------------------------------------------------------------------
   public void setComment(String inValue)
   {
      addSubtag(new ExcelComment(inValue));
   }

   //---------------------------------------------------------------------------
   public void setData(String inValue)
   {
      removeSubtagsByName(SpreadsheetML.DATA);
      mStringDataTag = new ExcelData(inValue);
      addSubtag(mStringDataTag);
   }

   //---------------------------------------------------------------------------
   public void addData(String inValue)
   {
      if (null == mStringDataTag)
      {
         setData(inValue);
      }
      else
      {
         mStringDataTag.addContent(inValue);
      }
   }

   //---------------------------------------------------------------------------
   public void setData(int inValue)
   {
      removeSubtagsByName(SpreadsheetML.DATA);
      addSubtag(new ExcelData(inValue));
   }

   //---------------------------------------------------------------------------
   public void setData(float inValue)
   {
      removeSubtagsByName(SpreadsheetML.DATA);
      addSubtag(new ExcelData(inValue));
   }

   //---------------------------------------------------------------------------
   public void setData(double inValue)
   {
      removeSubtagsByName(SpreadsheetML.DATA);
      addSubtag(new ExcelData(inValue));
   }

   //---------------------------------------------------------------------------
   /**
    Specifies a URL to use to make the Cell a hyperlink.
    */
   public ExcelCell setHRef(String inValue)
   {
      setAttribute(SpreadsheetML.HREF_ATT, inValue);
      return this;
   }

   //---------------------------------------------------------------------------
   /**
    The Formula attribute of a Cell element contains the formula associated with
    the cell. A formula consists of an equals sign (=) followed by calls to Excel
    functions, operators, values, and references to other cells (in R1C1 format).
    Ex: '=AVERAGE(R2C2:R10C2)'
    */
   public ExcelCell setFormula(String inValue)
   {
      setAttribute(SpreadsheetML.FORMULA_ATT, inValue);
      return this;
   }

   //---------------------------------------------------------------------------
   public ExcelCell setIndex(int inValue)
   {
      setAttribute(SpreadsheetML.INDEX_ATT, inValue);
      return this;
   }

   //---------------------------------------------------------------------------
   /**
    Specifies the number of horizontally adjacent cells to merge with this cell.
    */
   public ExcelCell setMergeAcross(int inValue)
   {
      setAttribute(SpreadsheetML.MERGE_ACROSS_ATT, inValue);
      return this;
   }

   //---------------------------------------------------------------------------
   /**
    Specifies the number of vertically adjacent cells to merge with this cell.
    */
   public ExcelCell setMergeDown(int inValue)
   {
      setAttribute(SpreadsheetML.MERGE_DOWN_ATT, inValue);
      return this;
   }

   //---------------------------------------------------------------------------
   public ExcelCell setStyleId(String inValue)
   {
      setAttribute(SpreadsheetML.STYLE_ID_ATT, inValue);
      return this;
   }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy