簡體   English   中英

SpreadsheetLight從單元格公式獲取數值

[英]SpreadsheetLight get numeric value from cell formula

有誰知道是否可以在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)");

  }

SpreadsheetLight沒有計算引擎,因此無法評估單元格公式(以當前狀態為准)。 您獲得的值要么是Excel先前計算的值(這意味着到您想要的值時它可能已過時),要么是0(因為SpreadsheetLight沒有計算引擎,因此默認為0或空字符串)。

披露:我寫了SpreadsheetLight。

SpreadsheetLight在其站點上有相當不錯的文檔(以chm下載)。 它不適用於我,因此我將其解壓縮並直接訪問html文件(chm是一種奇特的zip文件)。

您是否嘗試過sl.GetCellValueAsDouble或SLDocument的任何其他方法?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM