Пример #1
0
 /**
  * Adds a new FormatBase to the available formats.
  * 
  * The value that will be passed to the FormatBase's FormatBase method (specified
  * by <c>java.text.FormatBase#FormatBase</c>) will be a double value from a
  * numeric cell. Therefore the code in the FormatBase method should expect a
  * <c>Number</c> value.
  * 
  * @param excelformatStr The data FormatBase string
  * @param FormatBase A FormatBase instance
  */
 public void AddFormat(String excelformatStr, FormatBase format)
 {
     formats[excelformatStr] = format;
 }
Пример #2
0
    /**
 * Performs Excel-style date formatting, using the
 *  supplied Date and format
 */
    private String PerformDateFormatting(DateTime d, FormatBase dateFormat)
    {
        if (dateFormat != null)
        {
            return dateFormat.Format(d);
        }
        return d.ToString();
    }
Пример #3
0
 /**
  * 
  * Sets a default number FormatBase to be used when the Excel FormatBase cannot be
  * Parsed successfully. <b>Note:</b> This is a fall back for when an error
  * occurs while parsing an Excel number FormatBase pattern. This will not
  * affect cells with the <em>General</em> FormatBase.
  * 
  * 
  * The value that will be passed to the FormatBase's FormatBase method (specified
  * by <c>java.text.FormatBase#FormatBase</c>) will be a double value from a
  * numeric cell. Therefore the code in the FormatBase method should expect a
  * <c>Number</c> value.
  * 
  *
  * @param FormatBase A FormatBase instance to be used as a default
  * @see java.text.FormatBase#FormatBase
  */
 public void SetDefaultNumberFormat(FormatBase format)
 {
     IEnumerator itr = formats.Keys.GetEnumerator();
     while (itr.MoveNext())
     {
         string key = (string)itr.Current;
         if (formats[key] == generalDecimalNumFormat
                 || formats[key] == generalWholeNumFormat)
         {
             formats[key] = format;
         }
     }
     defaultNumFormat = format;
 }
Пример #4
0
 /**
  * Creates a new date formatter with the given specification.
  *
  * @param format The format.
  */
 public CellDateFormatter(String format)
     : base(format)
 {
     ;
     DatePartHandler partHandler = new DatePartHandler(this);
     StringBuilder descBuf = CellFormatPart.ParseFormat(format,
             CellFormatType.DATE, partHandler);
     partHandler.Finish(descBuf);
     dateFmt = new SimpleDateFormat(descBuf.ToString());
 }