4

im currently working on a project that reads data from excel using closedXML but im having errors with my code because the excel cells have vlookup formulas in it. is there a way for closedxml to read row values with vlookup formulas? Thanks!

this is where i get the "Syntax Error" error:

if (rowValue.Cell(colnum).HasFormula)
{
    ((IDictionary<String, Object>)item)[field] = rowValue.Cell(colnum).Value.ToString();
}
4

4 回答 4

2

http://github.com/ClosedXML/ClosedXMLdevelop分支现在支持和.VLOOKUPHLOOKUP

于 2016-09-19T12:01:12.767 回答
1

刚刚发现ValueCached给出了正确的文本。(关闭XML_v0.76.0.0)

IXLCell JobCell = row.Cells().Where(item => item.Address.ColumnLetter == "B").FirstOrDefault(); }
string Job = JobCell.RichText.Text;
if (string.IsNullOrEmpty(Job))
{
   Job = JobCell.ValueCached;
}
于 2018-12-19T03:31:10.397 回答
0

ClosedXML 不支持VLOOKUPHLOOKUP公式。如果您需要它们,则必须通过读取单元格范围并搜索具有给定值的行或列来手动实现它们。

于 2015-08-07T11:16:06.977 回答
0

正如 Raidri 提到的,封闭式 XML 不支持 VLOOKUPS。

有关封闭 xml 中 VLOOKUP 支持的更新,请参阅封闭 XML 代码库论坛上的此讨论

https://closedxml.codeplex.com/discussions/569497

建议的解决方法是为您的模板文件编写一个 VBA 宏以挂钩到保存前的事件,并将特殊值粘贴到隐藏的工作表中,然后从那里上传。请参阅这些链接以获取有关此操作的入门信息。

在 VBA 中以编程方式粘贴特殊值 -如何从工作表中删除公式但保留其计算值 挂钩到保存前的事件 - http://www.mrexcel.com/forum/excel-questions/374035-visual-basic-applications-保存事件.html

于 2015-12-01T11:16:17.223 回答