SpreadsheetLight从单元格公式中获取数值

Rya*_*yan 2 c# excel openxml

有谁知道是否可以在SpreadsheetLight中检索公式的数值?如果没有可以在OpenXml中读取公式为数字?

我需要为cellValue(8,1)返回7.07

  public static void TestSlWorkbook()
  {
     SLDocument sl = new SLDocument();
     sl.SetCellValue(1, 1, 1.01);
     sl.SetCellValue(2, 1, 1.01);
     sl.SetCellValue(3, 1, 1.01);
     sl.SetCellValue(4, 1, 1.01);
     sl.SetCellValue(5, 1, 1.01);
     sl.SetCellValue(6, 1, 1.01);
     sl.SetCellValue(7, 1, 1.01);

     sl.SetCellValue(8, 1, "=Sum(A1:A7)");

  }
Run Code Online (Sandbox Code Playgroud)

Vin*_*Tan 6

SpreadsheetLight没有计算引擎,因此没有评估单元格公式(截至当前状态).您获得的值是Excel之前计算的值(这意味着它可能在您想要值的时间过期)或0(因为SpreadsheetLight没有计算引擎,因此它默认为0或空字符串).

披露:我写了SpreadsheetLight.

  • 感谢您撰写SpreadsheetLight.这很棒.:) (2认同)