我正在使用HttpContext将数据表导出到CSV文件,该文件将在excel中用于人们查看。 稍后将导入和解析此相同的文件以获取插入的值等。 但是,有些列需要在最终的Excel导出中隐藏,但在导入文件时仍需要识别。 因此,当通过excel查看文件时,人们不应该看到隐藏的列,但是在解析文件时它们应该在那里并且可读。 我需要设置一个属性才能实现这一目标吗?
I am using HttpContext to export a data table to a CSV file which will be used in excel for people to look at. This very same file will later be imported and parsed to get values inserted and such. However there are some columns that need to be hidden in the final excel export but still need to be recognized when importing the file. So essentially when looking at the file through excel, people should not see the hidden columns, but they should be there and readable when parsing the file back. Is there a property that I need to set to make this happen?
最满意答案
使用.CSV文件格式无法做到这一点。 它不支持将列标记为不可见,默认情况下,当您使用它打开.csv文件时,excel不会隐藏任何列。
您需要一个自定义的Excel模板/插件和自定义逻辑来检测和隐藏某些列。
我的推荐是你不要这样做。 选择其他导出/编辑策略。 如果必须使用excel,请切换到导出完整的Excel文档,然后您可以自定义列并定义如何以及何时编辑它们。
This is not possible with the .CSV file format. It does not support flagging columns as invisible and excel will not, by default, hide any columns when you open a .csv file with it.
You would need a custom excel template/plugin and custom logic to detect and hide certain columns.
My recomendation is that you do not go this way. Choose a different export / edit strategy. If excel is a must, switch to exporting full excel documents where you can then customize the columns and define how and when they can be edited.
更多推荐
发布评论