本文整理汇总了C#中IRow类的典型用法代码示例。如果您正苦于以下问题:C# IRow类的具体用法?C# IRow怎么用?C# IRow使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IRow类属于命名空间,在下文中一共展示了IRow类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadRow
private Dictionary<string, object> ReadRow(IRow row, KeyValuePair<int, string>[] titles)
{
var data = new Dictionary<string, object>();
foreach (var title in titles)
{
var cell = row.GetCell(title.Key);
if (cell == null)
{
data.Add(title.Value, string.Empty);
continue;
}
switch (cell.CellType)
{
case CellType.Numeric:
data.Add(title.Value, cell.NumericCellValue);
break;
case CellType.String:
data.Add(title.Value, cell.StringCellValue);
break;
case CellType.Blank:
data.Add(title.Value, string.Empty);
break;
default:
throw new Exception(string.Format("Invalid excel cell type: {0} ({1}.{2}.{3})", cell.CellType, cell.Row.Sheet.SheetName, cell.RowIndex, cell.ColumnIndex));
}
}
return data;
}
示例2: GetCell
private DataCell GetCell(IRow row, int index)
{
DataCell retCell = new DataCell();
ICell cell = row.Cells[index];
switch (cell.CellType)
{
case CellType.String :
retCell.Type = DataCellType.String;
retCell.Value = cell.StringCellValue;
break;
case CellType.Numeric :
retCell.Type = DataCellType.Numeric;
retCell.Value = cell.NumericCellValue;
break;
case CellType.Formula :
retCell.Type = DataCellType.Formula;
retCell.Value = cell.CellFormula;
break;
case CellType.Boolean :
retCell.Type = DataCellType.Boolean;
retCell.Value = cell.BooleanCellValue;
break;
case CellType.Blank :
retCell.Type = DataCellType.Blank;
retCell.Value = cell.StringCellValue;
break;
}
retCell.ColumnIndex = cell.ColumnIndex;
return retCell;
}
示例3: Process
private static void Process(IRow row, HSSFFormulaEvaluator eval)
{
IEnumerator it = row.GetEnumerator();
while (it.MoveNext())
{
ICell cell = (ICell)it.Current;
if (cell.CellType != NPOI.SS.UserModel.CellType.FORMULA)
{
continue;
}
FormulaRecordAggregate record = (FormulaRecordAggregate)((HSSFCell)cell).CellValueRecord;
FormulaRecord r = record.FormulaRecord;
Ptg[] ptgs = r.ParsedExpression;
String cellRef = new CellReference(row.RowNum, cell.ColumnIndex, false, false).FormatAsString();
#if !HIDE_UNREACHABLE_CODE
if (false && cellRef.Equals("BP24"))
{
Console.Write(cellRef);
Console.WriteLine(" - has " + ptgs.Length + " ptgs:");
for (int i = 0; i < ptgs.Length; i++)
{
String c = ptgs[i].GetType().ToString();
Console.WriteLine("\t" + c.Substring(c.LastIndexOf('.') + 1));
}
Console.WriteLine("-> " + cell.CellFormula);
}
#endif
NPOI.SS.UserModel.CellValue evalResult = eval.Evaluate(cell);
Assert.IsNotNull(evalResult);
}
}
示例4: WriteRow
/// <summary/>
private static void WriteRow(IRow row, JsonTextWriter writer)
{
// Row
// => { c1:v1, c2:v2, ...}
// Header
writer.WriteStartObject();
// Fields
var columns = row.Schema;
for(int i=0; i<columns.Count; i++)
{
// Note: We simply delegate to Json.Net for all data conversions
// For data conversions beyond what Json.Net supports, do an explicit projection:
// ie: SELECT datetime.ToString(...) AS datetime, ...
object value = row.Get<object>(i);
// Note: We don't bloat the JSON with sparse (null) properties
if(value != null)
{
writer.WritePropertyName(columns[i].Name, escape:true);
writer.WriteValue(value);
}
}
// Footer
writer.WriteEndObject();
}
示例5: IsGood
public bool IsGood(IRow row, ITable table)
{
var keystring = table.GetKeystring(row);
var inf = _lookup[keystring];
System.Threading.Thread.Sleep(inf.Duration);
return inf.Result;
}
示例6: GetValueByColumn
public static object GetValueByColumn(this ITable table, string colName, IRow row)
{
var colId = table.Columns.Where(c => c.Name == colName).Select((c, i) => (int?)i).FirstOrDefault();
if (colId == null)
throw new ArgumentOutOfRangeException(String.Format("Column '{0}' not found.", colName));
return GetValue(table, colId.Value, row);
}
示例7: buildWorkbook
private void buildWorkbook(IWorkbook wb)
{
ISheet sh = wb.CreateSheet();
IRow row1 = sh.CreateRow(0);
IRow row2 = sh.CreateRow(1);
row3 = sh.CreateRow(2);
row1.CreateCell(0, CellType.Numeric);
row1.CreateCell(1, CellType.Numeric);
row2.CreateCell(0, CellType.Numeric);
row2.CreateCell(1, CellType.Numeric);
row3.CreateCell(0);
row3.CreateCell(1);
CellReference a1 = new CellReference("A1");
CellReference a2 = new CellReference("A2");
CellReference b1 = new CellReference("B1");
CellReference b2 = new CellReference("B2");
sh.GetRow(a1.Row).GetCell(a1.Col).SetCellValue(35);
sh.GetRow(a2.Row).GetCell(a2.Col).SetCellValue(0);
sh.GetRow(b1.Row).GetCell(b1.Col).CellFormula = (/*setter*/"A1/A2");
sh.GetRow(b2.Row).GetCell(b2.Col).CellFormula = (/*setter*/"NA()");
Evaluator = wb.GetCreationHelper().CreateFormulaEvaluator();
}
示例8: GetCellNumic
public static double GetCellNumic(IRow row, int y)
{
double _r = double.MinValue;
ICell cell = row.Cells[y - 1];
if (cell != null)
switch (cell.CellType)
{
case CellType.String:
{
_r = double.Parse(cell.StringCellValue.Trim());
}
break;
case CellType.Numeric:
{
_r = cell.NumericCellValue;
}
break;
default:
{
_r = 0;
}
break;
}
return _r;
}
示例9: CreateCell
internal static ICell CreateCell(IWorkbook workbook, IRow row, int column, decimal? content, bool isCentered)
{
ICellStyle style = workbook.CreateCellStyle();
ICell cell = row.CreateCell(column);
if (content == null)
{
cell.SetCellValue("");
}
else
{
cell.SetCellValue(Convert.ToDouble(content.Value));
}
if (isCentered)
{
style.Alignment = HorizontalAlignment.Center;
}
style.BorderBottom = BorderStyle.Thin;
style.BorderTop = BorderStyle.Thin;
style.BorderLeft = BorderStyle.Thin;
style.BorderRight = BorderStyle.Thin;
cell.CellStyle = style;
return cell;
}
示例10: Output
// Output
//
// Outputs the names of the rowset columns in a column separated row and optionally adds their types in a second row.
//
public override void Output(IRow row, IUnstructuredWriter output)
{
if (_first_row_written) { return; }
using (StreamWriter streamWriter = new StreamWriter(output.BaseStream, this._encoding))
{
streamWriter.NewLine = this._row_delim;
ISchema schema = row.Schema;
for (int i = 0; i < schema.Count(); i++)
{
var col = schema[i];
if (i > 0)
{
streamWriter.Write(this._col_delim);
}
var val = _quoting ? AddQuotes(col.Name) : col.Name;
streamWriter.Write(val);
}
streamWriter.WriteLine();
if (_with_types)
{
for (int i = 0; i < schema.Count(); i++)
{
var col = schema[i];
if (i > 0)
{
streamWriter.Write(this._col_delim);
}
var val = _quoting ? AddQuotes(col.Type.FullName) : col.Type.FullName;
streamWriter.Write(val);
}
streamWriter.WriteLine();
}
}
_first_row_written = true;
}
示例11: QAException
public QAException(IRow exception)
{
if (exception == null)
throw new ArgumentNullException("exception", "Cannot pass null row to QAException");
this._objectID = exception.OID;
int idx;
idx = exception.Fields.FindField("ATTACHMENT");
this._attachment = exception.get_Value(idx).ToString();
idx = exception.Fields.FindField("DATA_EXCEPTION_POINT_ID");
this._exceptionID = Convert.ToInt32(exception.get_Value(idx));
idx = exception.Fields.FindField("DATA_EXCEPTION_STATUS");
this._status = exception.get_Value(idx).ToString();
idx = exception.Fields.FindField("EXCEPTION_DESCRIPTION");
this._description = exception.get_Value(idx).ToString();
idx = exception.Fields.FindField("LATITUDE");
this._latitude = Convert.ToDouble(exception.get_Value(idx));
idx = exception.Fields.FindField("LONGITUDE");
this._longitude = Convert.ToDouble(exception.get_Value(idx));
idx = exception.Fields.FindField("OPERATIONAL_DATASET_NAME");
this._operationDSName = exception.get_Value(idx).ToString();
idx = exception.Fields.FindField("QA_TEST_NAME");
this._testName = exception.get_Value(idx).ToString();
}
示例12: Apply
/// <summary>Apply is called at least once per instance</summary>
/// <param name="input">A SQLIP row</param>
/// <param name="output">A SQLIP updatable row.</param>
/// <returns>IEnumerable of IRow, one IRow per SQLIP row.</returns>
/// <remarks>Because applier constructor arguments cannot depend on
/// column references, the name of the column to parse is given as a string. Then
/// the actual column value is obtained by calling IRow.Get. The rest of the code
/// is the same as XmlDomExtractor.</remarks>
public override IEnumerable<IRow> Apply(IRow input, IUpdatableRow output)
{
// Make sure that all requested columns are of type string
IColumn column = output.Schema.FirstOrDefault(col => col.Type != typeof(string));
if (column != null)
{
throw new ArgumentException(string.Format("Column '{0}' must be of type 'string', not '{1}'", column.Name, column.Type.Name));
}
XmlDocument xmlDocument = new XmlDocument();
xmlDocument.LoadXml(input.Get<string>(this.xmlColumnName));
foreach (XmlNode xmlNode in xmlDocument.DocumentElement.SelectNodes(this.rowPath))
{
// IUpdatableRow implements a builder pattern to save memory allocations,
// so call output.Set in a loop
foreach(IColumn col in output.Schema)
{
var explicitColumnMapping = this.columnPaths.FirstOrDefault(columnPath => columnPath.Value == col.Name);
XmlNode xml = xmlNode.SelectSingleNode(explicitColumnMapping.Key ?? col.Name);
output.Set(explicitColumnMapping.Value ?? col.Name, xml == null ? null : xml.InnerXml);
}
// then call output.AsReadOnly to build an immutable IRow.
yield return output.AsReadOnly();
}
}
示例13: GetDefaultValueForField
public static object GetDefaultValueForField(IRow row, IField fld)
{
object defaultValue = DBNull.Value;
if (!fld.IsNullable)
defaultValue = string.Empty;
if (row != null && fld != null)
{
IClass cls = row.Table;
if (HasSubtype(cls))
{
ISubtypes subTypes = (ISubtypes)cls;
string subTypeFieldName = GetSubTypeFieldName(cls);
if (string.IsNullOrEmpty(subTypeFieldName) == false)
{
object o = GetFieldValue(row, subTypeFieldName);
int subTypeCode = ToInteger(o, -1);
if (subTypeCode != -1)
defaultValue = subTypes.get_DefaultValue(subTypeCode, fld.Name);
}
}
if (defaultValue == DBNull.Value && fld.Type == esriFieldType.esriFieldTypeDate)
defaultValue = fld.DefaultValue;
}
return defaultValue;
}
示例14: DunaGridRowSelector
public DunaGridRowSelector(IRow row)
: base()
{
this.Row = row;
InitializeComponent();
this.HoverAreaPadding = new Padding(0, 3, 0, 3);
DoubleBuffered = true;
}
示例15: InsertCell
private static int InsertCell(IRow row, int cellIndex, string value, ICellStyle cellStyle)
{
var cell = row.CreateCell(cellIndex);
cell.SetCellValue(value);
cell.CellStyle = cellStyle;
cellIndex++;
return cellIndex;
}