来自c#代码的不可编辑的Excel Sheel文件 [英] Not Editable Excel Sheel File from c# code

查看:163
本文介绍了来自c#代码的不可编辑的Excel Sheel文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

导出到excel文件后,我不想允许编辑excel数据。那么,如何通过C#代码制作Excel表格只读?





谢谢,

ttds

解决方案

您可以尝试以下方法之一:



  1. 将文件设为ReadOnly in视窗。这意味着操作系统将不允许对文件进行更改。用户可以轻松清除ReadOnly标志,因此这可能不是您想要的。如果您确实想要这条路线,请查看 File.SetAttributes [ ^ ]

  2. 使用密码保护Excel工作簿和工作表。这意味着Excel将不允许对工作簿或工作表进行更改,除非用户可以提供正确的密码。如果这是你想要的,请看看 Workbook.Protect [ ^ ]和 Worksheet.Protect [ ^ ]


I don''t want to allow edit the excel data after exporting to the excel file. So, How to make a Excel Sheet ReadOnly by C# code ?


thanks,
ttds

解决方案

You can try one of the following:


  1. Make the file ReadOnly in Windows. This means that the operating system will not allow changes to be made to the file. The user can easily clear the ReadOnly flag, so this is probably not what you want. If you do want to go this route, have a look at File.SetAttributes[^]
  2. Protect the Excel workbook and worksheet with passwords. This means that Excel will not allow changes to be made to the workbook or the worksheet unless the user can provide the correct password. If this is what you want, have a look at Workbook.Protect[^] and Worksheet.Protect[^]


这篇关于来自c#代码的不可编辑的Excel Sheel文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆