使用 FileHelper .Net 库,我可以以某种方式跳过源文件中的一些列吗?
根据文档和示例,我必须为所有列添加字段。唉,我有一个包含 216 列的 Excel 表要导入,其中只需 13 列。
最佳答案
我也有同样的情况,还有疑问。在 filehelpers.net 上搜索论坛,我找到了 thread (从 2007 年开始?!)马科斯本人回应:
问题:
In a delimited length layout, is it possible to skip some fields? For example:
ExternalSysId|ExportDate|FirstName|LastName
I only want FirstName and LastName, and don't want to clutter up my code with "dummy" fields?
回复:
The library dont have a built in feature for this.
You can make the fields private, the library will read the values, but you dont see them from your code =) If in the future you need these fields you can meke them public
因此,使用记录类向导来减少所需的输入量,然后将不必要的字段设为私有(private),这似乎是目前最好的选择。
关于.net - 跳过 FileHelper 中的列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/352030/