原始答案GemBox.Spreadsheet当前仅支持由Excel计算的值(因此,如果文件由MS Excel保存,则我们可以读取公式值). GemBox.Spreadsheet没有自己的计算引擎.要读取 XLS 格式的公式值,请使用接受XlsOptions枚举的ExcelFile.LoadXls重载,并使用XlsOptions.PreserveWorksheetRecords或XlsOptions.PreserveAll.要读取 XLSX 格式的公式值,请使用ExcelFile.LoadXlsx方法和XlsxOptions枚举值XlsxOptions.PreserveKeepOpen或XlsxOptions.PreserveMakeCopy.According to their docs: GemBox.Spreadsheet can read and write formulas, but can not calculate formula results. When you open a XLS file in MS Excel, formula results will be calculated automaticaly.So if i create a spreadsheet with some injected values and save it to disk if i open the file in excel i can see the calculated values..if i open that file in gembox and look up the calculated cell's values i get a result of 0the same functionality exists in flexcel as well.. can't retrieve the calculated value from a given cell.. it returns zero..So what I'm doing is:Open an existing excel filePutting some numbers in to some cellsSaving the file to disk under a different name (tried with the same file too)Opening the file again and looking in the total column which is a calculated cellThe value is always 0.. I open the file in excel.. the value is calculated as expected. 解决方案 EDIT 28-09-2016:We have released a new version of GemBox.Spreadsheet (version 4.1) in which we implemented a support for cell formula calculation, see the version history page.Also, you can find the calculation example here.ORIGINAL ANSWERGemBox.Spreadsheet currently supports only values that are calculated by the Excel (so if file is saved by the MS Excel, we can read formula values). GemBox.Spreadsheet does not have its own calculation engine.To read formula values in XLS format use ExcelFile.LoadXls overload that accepts XlsOptions enumeration and use XlsOptions.PreserveWorksheetRecords or XlsOptions.PreserveAll.To read formula values in XLSX format use ExcelFile.LoadXlsx method with XlsxOptions enumeration values XlsxOptions.PreserveKeepOpen or XlsxOptions.PreserveMakeCopy. 这篇关于GemBox从电子表格或Flexcel检索计算值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 23:25