本文整理汇总了C#中Sheet.CreateCell方法的典型用法代码示例。如果您正苦于以下问题:C# Sheet.CreateCell方法的具体用法?C# Sheet.CreateCell怎么用?C# Sheet.CreateCell使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sheet
的用法示例。
在下文中一共展示了Sheet.CreateCell方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadSheetData
void LoadSheetData (Sheet sheet, XElement xsheetData)
{
// <row>
foreach (XElement xrow in xsheetData.Elements ()){
int row = Int32.Parse ((string) xrow.Attribute ("r"));
// <c>
foreach (XElement xcell in xrow.Elements ()){
int cell_col, cell_row;
// r=
OOXML.ParseReference ((string) xcell.Attribute (OOXML.r), out cell_col, out cell_row);
if (row != cell_row){
// this should not happen
Error = "Document contains cell references outside of their row";
throw new Exception ();
}
Cell cell = sheet.CreateCell (cell_col, cell_row);
//CellType type = OOXML.GetCellType (xcell, CellType.Number);
string type = (string) xcell.Attribute (OOXML.t);
foreach (XElement cval in xcell.Elements ()){
if (type == "inlineStr"){
if (cval.Name == OOXML.is_)
cell.Value = new RichStringValue (cval);
else
throw new LoadException ("Cell type is InlineString, but found other values");
}
if (cval.Name == OOXML.f){
cell.Formula = new Formula (cval.Value);
continue;
}
if (cval.Name == OOXML.v){
string s = cval.Value;
bool v;
switch (type){
case "b":
if (bool.TryParse (s, out v))
cell.Value = new BoolValue (v);
else
cell.Value = new BoolValue (int.Parse (s) == 1);
break;
case "e":
cell.Value = new ErrorValue (s);
break;
case "n":
cell.Value = new NumberValue (double.Parse (s));
break;
case "s":
// Lookup the string in the share string table
cell.Value = sharedstrings [Int32.Parse (s)];
break;
case "str":
cell.Value = new StringValue (cval.Value);
break;
}
}
}
}
}
}