本文整理汇总了C#中Sheet.SetArrayFormula方法的典型用法代码示例。如果您正苦于以下问题:C# Sheet.SetArrayFormula方法的具体用法?C# Sheet.SetArrayFormula怎么用?C# Sheet.SetArrayFormula使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sheet
的用法示例。
在下文中一共展示了Sheet.SetArrayFormula方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseRow
private int ParseRow(XmlReader rowreader,
Workbook wb,
Sheet sheet,
int row,
IDictionary<string, Cell> cellParsingCache) {
/* XMLSS has origin at (1,1) = (A,1) whereas Corecalc internal
* representation has origin at (0,0) = (A,1). Hence the col
* and row indices are 1 higher in this method.
*/
int cellCount = 0;
int col = 0;
XmlReader cellreader = rowreader.ReadSubtree();
while (cellreader.ReadToFollowing("Cell")) {
String colindexstr = cellreader.GetAttribute("ss:Index");
String arrayrangestr = cellreader.GetAttribute("ss:ArrayRange");
String formulastr = cellreader.GetAttribute("ss:Formula");
String typestr = "";
String dataval = "";
if (colindexstr != null) {
if (!int.TryParse(colindexstr, out col)) {
col = 0; // Looks wrong, should be 1?
}
}
else {
col++;
}
cellCount++;
// If an array result occupies cells, do not overwrite
// the formula with precomputed and cached data from
// the XMLSS file. Instead skip the parsing and sheet update.
if (sheet[col - 1, row - 1] != null) {
continue;
}
using (XmlReader datareader = cellreader.ReadSubtree()) {
if (datareader.ReadToFollowing("Data")) {
typestr = datareader.GetAttribute("ss:Type");
datareader.MoveToContent();
dataval = datareader.ReadElementContentAsString();
}
}
String cellString;
if (formulastr != null) {
cellString = formulastr;
}
else {
// Anything else than formulas are values.
// If XMLSS tells us it is a String we believe it
if (typestr == "String") {
dataval = "'" + dataval;
}
cellString = dataval;
}
// Skip blank cells
if (cellString == "") {
continue;
}
Cell cell;
if (cellParsingCache.TryGetValue(cellString, out cell)) {
// Copy the cell (both for mutable Formula cells and for cell-specific
// metadata) and but share any sharable contents.
cell = cell.CloneCell(col - 1, row - 1);
}
else {
// Cell contents not seen before: scan, parse and cache
cell = Cell.Parse(cellString, wb, col, row);
if (cell == null) {
Console.WriteLine("BAD: Null cell from \"{0}\"", cellString);
}
else {
cellParsingCache.Add(cellString, cell);
}
}
if (arrayrangestr != null && cell is Formula) { // Array formula
string[] split = arrayrangestr.Split(":".ToCharArray());
RARef raref1 = new RARef(split[0]);
RARef raref2;
if (split.Length == 1) {
// FIXME: single cell result, but still array
raref2 = new RARef(split[0]);
}
else {
raref2 = new RARef(split[1]);
}
CellAddr ulCa = raref1.Addr(col - 1, row - 1);
CellAddr lrCa = raref2.Addr(col - 1, row - 1);
// This also updates support sets, but that's useless, because
// they will subsequently be reset by RebuildSupportGraph
sheet.SetArrayFormula(cell, col - 1, row - 1, ulCa, lrCa);
}
else { // One-cell formula, or constant
sheet[col - 1, row - 1] = cell;
//.........这里部分代码省略.........