none
Writeprotecting a excel 2003 xml file RRS feed

  • Question

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

    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>

    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.

    Can i add something in the xml-text to make cells uneditable, like in the <Protection/> field, witch is unused now, or is that only for encryption?

    Thanks


    Friday, October 14, 2016 7:16 AM

All replies

  • Hi,

    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.


    Regards,
    Emi Zhang
    TechNet Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Monday, October 17, 2016 3:15 AM
  • Hi okkal,

    >> 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.

    What do you mean by this? As my understanding, set the file as read-only, you could edit the cells, and you could not save the file. It is a feature of file property.

    >> Can i add something in the xml-text to make cells uneditable, like in the <Protection/> field, witch is unused now, or is that only for encryption?

    In my option, you could not achieve making cell un-editable. To make cells un-editable, you will need to protect the worksheet with password, but the Password settings are not supported in Excel 2003 XML format.

    To check it is a product limit, you could manually create a excel worksheet with protecting, if you try to save it to excel 2003 xml format, it will produce error which indicates that “A sheet in the workbook you are trying to save is password protected. Password protected sheets cannot be saved in an XML Spreadsheet.”

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, October 18, 2016 5:55 AM
  • Hi okkal,

    >> 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.

    What do you mean by this? As my understanding, set the file as read-only, you could edit the cells, and you could not save the file. It is a feature of file property.


    Hi Edward,

    i use File.SetAttributes(path, readonly); when i create the file on the harddisk, this is c#.

    As i said, it works in OpenOffice, i can open the file and view -but i can´t edit cells or save - witch is what i want excel behaviour to be also.

    I would be very sad if it isent possible, except with password protection (witch isent supported in this format).

    Tuesday, October 18, 2016 8:09 AM
  • Hi okkal,

    Currently, I am afraid it is impossible in Microsoft Office.

    If this is a new feature you want to include in the future, I would suggest you submit a feedback in the link below:

    Reference:https://excel.uservoice.com/

    Best Regards,

    Edward


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, October 18, 2016 9:19 AM