/* ====================================================================
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for Additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
==================================================================== */
namespace HH.WMS.Utils.NPOI.SS.UserModel
{
using System;
using HH.WMS.Utils.NPOI.SS.Formula;
using HH.WMS.Utils.NPOI.SS.Util;
public enum CellType : int
{
Unknown = -1,
NUMERIC = 0,
STRING = 1,
FORMULA = 2,
BLANK = 3,
BOOLEAN = 4,
ERROR = 5
}
/**
* High level representation of a cell in a row of a spreadsheet.
*
* Cells can be numeric, formula-based or string-based (text). The cell type
* specifies this. String cells cannot conatin numbers and numeric cells cannot
* contain strings (at least according to our model). Client apps should do the
* conversions themselves. Formula cells have the formula string, as well as
* the formula result, which can be numeric or string.
*
*
* Cells should have their number (0 based) before being Added to a row.
*
*/
public interface ICell
{
///
/// zero-based column index of a column in a sheet.
///
int ColumnIndex
{
get;
}
///
/// zero-based row index of a row in the sheet that contains this cell
///
int RowIndex { get; }
///
/// the sheet this cell belongs to
///
ISheet Sheet { get; }
///
/// the row this cell belongs to
///
IRow Row { get; }
///
/// Set the cells type (numeric, formula or string)
///
CellType CellType
{
get;
}
///
/// Set the cells type (numeric, formula or string)
///
///
void SetCellType(CellType cellType);
///
/// Only valid for formula cells
///
CellType CachedFormulaResultType { get; }
///
/// Set a numeric value for the cell
///
/// the numeric value to set this cell to. For formulas we'll set the
/// precalculated value, for numerics we'll set its value. For other types we will change
/// the cell to a numeric cell and set its value.
///
void SetCellValue(double value);
///
/// Set a error value for the cell
///
/// the error value to set this cell to. For formulas we'll set the
/// precalculated value , for errors we'll set its value. For other types we will change
/// the cell to an error cell and set its value.
///
void SetCellErrorValue(byte value);
///
/// Converts the supplied date to its equivalent Excel numeric value and Sets that into the cell.
///
/// the numeric value to set this cell to. For formulas we'll set the
/// precalculated value, for numerics we'll set its value. For other types we will change
/// the cell to a numerics cell and set its value.
///
void SetCellValue(DateTime value);
///
/// Set a rich string value for the cell.
///
/// value to set the cell to. For formulas we'll set the formula
/// string, 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.
///
void SetCellValue(IRichTextString value);
///
/// Set a string value for the cell.
///
/// value to set the cell to. For formulas we'll set the formula
/// string, 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.
///
void SetCellValue(String value);
///
/// Return a formula for the cell
///
/// if the cell type returned by GetCellType() is not CELL_TYPE_FORMULA
String CellFormula { get; set; }
///
/// Sets formula for this cell.
///
/// the formula to Set, e.g. "SUM(C4:E4)"
.
void SetCellFormula(String formula);
///
/// Get the value of the cell as a number.
///
/// if the cell type returned by GetCellType() is CELL_TYPE_STRING
/// if the cell value isn't a parsable double
double NumericCellValue { get; }
///
/// Get the value of the cell as a date.
///
/// if the cell type returned by GetCellType() is CELL_TYPE_STRING
/// if the cell value isn't a parsable double
DateTime DateCellValue { get; }
///
/// Get the value of the cell RichTextString
///
IRichTextString RichStringCellValue { get; }
///
/// Get the value of the cell as an error code.
///
byte ErrorCellValue { get; }
///
/// Get the value of the cell as a string
///
String StringCellValue { get; }
///
/// Set a bool value for the cell
///
///
void SetCellValue(bool value);
///
/// Get the value of the cell as a bool.
///
bool BooleanCellValue { get; }
///
/// Return the cell's style.
///
ICellStyle CellStyle { get; set; }
///
/// Sets this cell as the active cell for the worksheet
///
void SetAsActiveCell();
///
/// comment associated with this cell
///
IComment CellComment { get; set; }
///
/// Removes the comment for this cell, if there is one.
///
void RemoveCellComment();
///
/// hyperlink associated with this cell
///
IHyperlink Hyperlink { get; set; }
///
/// Only valid for array formula cells
///
/// range of the array formula group that the cell belongs to.
CellRangeAddress GetArrayFormulaRange();
///
/// if this cell is part of group of cells having a common array formula.
///
bool IsPartOfArrayFormulaGroup { get; }
bool IsMergedCell { get; }
}
}