c#导出CSV文件隐藏列(c# Export CSV File Hide Columns)

编程入门 行业动态 更新时间:2024-10-09 11:17:08
c#导出CSV文件隐藏列(c# Export CSV File Hide Columns)

我正在使用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.

更多推荐

本文发布于:2023-04-29 08:44:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1335605.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件   Export   CSV   Columns   Hide

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!