简体   繁体   中英

SpreadsheetLight get numeric value from cell formula

Does anyone know if it possible to retrieve the numeric value of a formula in SpreadsheetLight? if not is possible to read the formula in OpenXml as numeric?

I need to return 7.07 for cellValue(8,1)

  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 doesn't have a calculation engine, so there's no evaluation of cell formulas (as of current status). The values you get are either what Excel has calculated previously (which means it's probably outdated by the time you want the value) or 0 (because SpreadsheetLight has no calculation engine, so it defaults to either 0 or empty string).

Disclosure: I wrote SpreadsheetLight.

SpreadsheetLight has pretty good documentation on their site (as a chm download). It did not work right for me, so I unzipped it and accessed the html files directly (a chm is a fancy type of zip file).

Have you tried sl.GetCellValueAsDouble or any other method of SLDocument?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM