Excel-dna 获取百分比值

Excel-dna getting percentage values

我 运行 在尝试使用 ExcelReference.getValues() 从 excel 获取百分比值时遇到了问题。对于 300%,它会返回 3.0 等等。

有什么方法可以区分这个值是百分比还是数字格式?

问题和这个问题类似how to convert user input to string in Excel-DNA虽然格式问题多于计算公式

您可以使用 C API GET.CELL 信息函数获取单元格的格式化值,使用信息类型 53。它 returns: "Contents of the cell as it is currently displayed, as text, including any additional numbers or symbols resulting from the cell's formatting."

object contents = XlCall.Excel(XlCall.xlfGetCell, 53, theReference);