Example #1
0
 /**
  * Set a date value for the cell. Excel treats dates as numeric so you will need to format the
  * cell as a date.
  *
  * <p>This will set the cell value based on the Calendar's timezone. As Excel does not support
  * timezones this means that both 20:00+03:00 and 20:00-03:00 will be reported as the same value
  * (20:00) even that there are 6 hours difference between the two times. This difference can be
  * preserved by using <code>setCellValue(value.getTime())</code> which will automatically shift
  * the times to the default timezone.
  *
  * @param value the date value to set this cell to. For formulas we'll set the precalculated
  *     value, for numerics we'll set its value. For othertypes we will change the cell to a
  *     numeric cell and set its value.
  */
 public void setCellValue(Calendar value) {
   boolean date1904 = getSheet().getWorkbook().isDate1904();
   setCellValue(DateUtil.getExcelDate(value, date1904));
 }
Example #2
0
 /**
  * Set a string value for the cell.
  *
  * @param str value to set the cell to. For formulas we'll set the formula cached string result,
  *     for String cells we'll set its value. For other types we will change the cell to a string
  *     cell and set its value. If value is null then we will change the cell to a Blank cell.
  */
 public void setCellValue(String str) {
   setCellValue(str == null ? null : new XSSFRichTextString(str));
 }