Writeprotecting excel 2003 xml文件 [英] Writeprotecting a excel 2003 xml file

查看:73
本文介绍了Writeprotecting excel 2003 xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试确保我的用户无法在Excel工作表中编辑单元格。

Hello, i´m trying to make sure my users can´t edit cells in a excel sheet.

我正在通过c#中的代码创建文件,并且它看起来像这样:

I´m creating the file through code in c#, and it look something like this:

<?xml version="1.0"?>
<?"Excel.Sheet"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:o="urn:schemas-microsoft-com:office:office"
 xmlns:x="urn:schemas-microsoft-com:office:excel"
 xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
 xmlns:html="http://www.w3.org/TR/REC-html40">
 <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
  <Created>2015-06-05T18:19:34Z</Created>
  <LastSaved>2015-06-05T18:19:39Z</LastSaved>
  <Version>16.00</Version>
 </DocumentProperties>
 <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
  <AllowPNG/>
  <RemovePersonalInformation/>
 </OfficeDocumentSettings>
 <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
  <WindowHeight>12645</WindowHeight>
  <WindowWidth>22260</WindowWidth>
  <WindowTopX>0</WindowTopX>
  <WindowTopY>0</WindowTopY>
  <ProtectStructure>False</ProtectStructure>
  <ProtectWindows>False</ProtectWindows>
 </ExcelWorkbook>
 <Styles>
  <Style ss:ID="Default" ss:Name="Normal">
   <Alignment ss:Vertical="Bottom"/>
   <Borders/>
   <Font ss:FontName="Calibri" x:Family="Swiss" ss:Size="11" ss:Color="#000000"/>
   <Interior/>
   <NumberFormat/>
   <Protection/>
  </Style>
 </Styles>
 <Worksheet ss:Name="Ark1">
  <Table ss:ExpandedColumnCount="3" ss:ExpandedRowCount="2" x:FullColumns="1"
   x:FullRows="1" ss:DefaultColumnWidth="54" ss:DefaultRowHeight="15">
   <Row>
    <Cell><Data ss:Type="String">a1</Data></Cell>
    <Cell><Data ss:Type="String">b1</Data></Cell>
    <Cell><Data ss:Type="String">c1</Data></Cell>
   </Row>
   <Row>
    <Cell><Data ss:Type="String">a2</Data></Cell>
    <Cell><Data ss:Type="String">b2</Data></Cell>
    <Cell><Data ss:Type="String">c2</Data></Cell>
   </Row>
  </Table>
  <WorksheetOptions xmlns="urn:schemas-microsoft-com:office:excel">
   <PageSetup>
    <Header x:Margin="0.3"/>
    <Footer x:Margin="0.3"/>
    <PageMargins x:Bottom="0.75" x:Left="0.7" x:Right="0.7" x:Top="0.75"/>
   </PageSetup>
   <Selected/>
   <ProtectObjects>False</ProtectObjects>
   <ProtectScenarios>False</ProtectScenarios>
  </WorksheetOptions>
 </Worksheet>
</Workbook>

我正在使用  File.SetAttributes(path,readonly);在文件上,女巫在OppenOffice中运行良好(即我无法编辑单元格),但在excel 2016中我仍然可以编辑单元格。

I´m using File.SetAttributes(path, readonly); on the file, witch works fine in OppenOffice(ie. i can´t edit cells), but in excel 2016 I can still edit the cells.

可以我在xml文本中添加了一些内容以使单元格无法使用,例如  < Protection />现在,女巫现在还没用,或者仅用于加密?

谢谢

推荐答案

这是讨论问题的论坛和Microsoft Excel的反馈,我会将您的问题转移到Excel的MSDN论坛

This is the forum to discuss questions and feedback for Microsoft Excel, I'll move your question to the MSDN forum for Excel

https://social.msdn.microsoft.com/Forums/en-US/home?forum=exceldev

之所以如此我们建议适当地发布您是否会获得最合格的受访者群体,而定期阅读论坛的其他合作伙伴可以分享他们的知识或从您与我们的互动中学习。感谢您的理解。

The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


这篇关于Writeprotecting excel 2003 xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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