简体   繁体   English

如何使用带有c#的openxml(不是整个行/列)隐藏和保护excel文件中一个Cell的文本?

[英]How can I hide and protect the text of one Cell in an excel file using openxml with c# (not the entire row/ column)?

I'm not sure if it is possible to hide and protect the data of a specific cell in excel file using openxml(not the entire row or column). 我不确定是否可以使用openxml(而不是整个行或列)隐藏和保护excel文件中特定单元格的数据。 Anyone have an idea about that please? 有人对此有所了解吗?

Try using the Protection Class: 尝试使用保护类:

public class Protection : OpenXmlLeafElement

18.8.33 protection (Protection Properties) 18.8.33保护(保护属性)

Contains protection properties associated with the cell. 包含与单元格关联的保护属性。 Each cell has protection properties that can be set. 每个单元都具有可以设置的保护属性。 The cell protection properties do not take effect unless the sheet has been protected. 除非纸张受到保护,否则单元格保护属性不会生效。

hidden (Hidden Cell) 隐藏(隐藏的细胞)

A boolean value indicating if the cell is hidden. 一个布尔值,指示单元格是否隐藏。 When the cell is hidden and the sheet on which the cell resides is protected, then the cell value is displayed in the cell grid location, but the contents of the cell will not be displayed in the formula bar. 当单元格被隐藏并且单元格所在的工作表受到保护时,单元格值将显示在单元格网格位置中,但单元格的内容将不会显示在公式栏中。 This is true for all types of cell content, including formula, text, or numbers. 对于所有类型的单元格内容都是如此,包括公式,文本或数字。

Therefore the cell A4 can contain a formula "=SUM(A1:A3)", but if the cell protection property of A4 is marked as hidden, and the sheet is protected, then the cell should display the calculated result [Example: "6" end example], but will not display the formula used to calculate the result. 因此,单元格A4可以包含公式“= SUM(A1:A3)”,但如果A4的单元格保护属性被标记为隐藏,并且图纸受到保护,则单元格应显示计算结果[示例:“6 “结束示例”,但不会显示用于计算结果的公式。

The possible values for this attribute are defined by the W3C XML Schema boolean datatype. 此属性的可能值由W3C XML Schema布尔数据类型定义。

locked (Cell Locked) 锁定(单元格锁定)

A boolean value indicating if the cell is locked. 一个布尔值,指示单元格是否已锁定。 When cells are marked as "locked" and the sheet is protected, then the options specified in the Sheet Part's sheetProtection element (§18.3.1.85) are prohibited for these cells. 当单元格被标记为“已锁定”且工作表受到保护时,这些单元格将禁止在Sheet Part的sheetProtection元素(第18.3.1.85节)中指定的选项。

The possible values for this attribute are defined by the W3C XML Schema boolean datatype. 此属性的可能值由W3C XML Schema布尔数据类型定义。

https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/cc798966%28v%3Doffice.14%29 https://docs.microsoft.com/en-us/previous-versions/office/developer/office-2010/cc798966%28v%3Doffice.14%29

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Excel C#OpenXML:添加新行后,如何在Excel中获取单元格的位置,(Row row = new Row()); 不使用Excel Interpol或Macro - Excel C# OpenXML : how can i get the position of the cell in excel after adding new row,(Row row=new Row()); without using excel Interpol or Macro C#如何使用OpenXmlWriter(OpenXML SDK 2.5)将单元格附加到Excel工作表中的每一行 - C# How do I append a Cell to every Row in a Excel Sheet using OpenXmlWriter (OpenXML SDK 2.5) 如何使用DocumentFormat.OpenXml C#获取excel工作表中的特定列? - How can I get the specific column in excel worksheet using DocumentFormat.OpenXml C#? 使用 OpenXML C# 获取 Excel 中单元格的列索引 - Get the Column Index of a Cell in Excel using OpenXML C# 使用C#和OpenXML写入xlsx文件时,会修剪Excel单元格文本 - Excel cell text is trimmed when writen in xlsx file when using C# & OpenXML 如何使用OpenXML和C#在Excel中添加带有单元格数据和样式的新行 - How to add new row with cell data and styles in Excel using OpenXML and C# 如何在C#中使用OpenXML读取Excel的空白单元格列值 - How to read blank cell column value of excel using OpenXML in C# 如何在C#中使用OpenXML在Excel中隐藏行? - How to hide rows in Excel using OpenXML in C#? 如何使用 OpenXML C# 在 Excel 中隐藏工作表? - How to hide a sheet in Excel using OpenXML C#? 如何在 C# 中使用 OpenXML 将 RTF/HTML 放入 Excel 单元格 - How to put RTF/HTML into Excel cell using OpenXML in C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM