Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old April 30th, 2008, 03:34 AM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default Password protect XLS using XML


Chaps,

Essentially what i am trying to father is if in XML you are able to set Excel password protection.

I am currently exporting some SQL data to excel using.

Code:
Response.ContentType = "application/vnd.ms-excel"
I am using basic worksheet protection shown below.

Code:
 <x:ProtectContents>True</x:ProtectContents>
     <x:ProtectObjects>True</x:ProtectObjects>
     <x:ProtectScenarios>True</x:ProtectScenarios>
My understanding of XML is very limited and as yet no searches have produced any XML specific password setting.

If there is a method within XML that would be superb.

Cheers


Aspless

  #2 (permalink)  
Old April 30th, 2008, 03:44 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

This can't be done if you are using the Excel XML format (at least in Excel 2003 that I tried it).

If you set a password on an excel spreadsheet and then try to save it as an XML Spreadsheet it tells you:

"A sheet in the workbook you are trying to save is password protected. Password protected sheets cannot be saved in an XML Spreadsheet. To save this file as an XML Spreadsheet, you must first remove the password".

/- Sam Judson : Wrox Technical Editor -/
  #3 (permalink)  
Old April 30th, 2008, 03:45 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Oh, and also, this shouldn't really be posted to the XML forum, its more of an Excel question.

/- Sam Judson : Wrox Technical Editor -/
  #4 (permalink)  
Old April 30th, 2008, 05:02 AM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default


Thanks samjudson,

looking at your reply i realise i have not explained my function in enough detail.

I am currently using a classic asp page to export SQL data to excel using -

Code:
filename = Date() &  "-Results.xls"
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment; filename="&filename&""
After investigating some simple XML examples i have been able to protect the worksheets within the <x:WorksheetOptions> tags using

Code:
<x:ProtectContents>True</x:ProtectContents>
     <x:ProtectObjects>True</x:ProtectObjects>
     <x:ProtectScenarios>True</x:ProtectScenarios>
What i am trying to get clarification of is if within XML you can set the password for the excel workbook.

If you feel this forum post is still more suited to the Excel forums please let me know.

Thanks

Aspless



  #5 (permalink)  
Old April 30th, 2008, 05:35 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

It doesn't matter what you are calling the document (you could call it "spreadsheet.foo" if you wanted, as long as Excel knows to open .foo files it will open in Excel).

The content of the file appears to be XML, therefore it is an Excel XML Spreadsheet - therefore my previous answer stands.

/- Sam Judson : Wrox Technical Editor -/
  #6 (permalink)  
Old April 30th, 2008, 05:44 AM
Friend of Wrox
Points: 489, Level: 7
Points: 489, Level: 7 Points: 489, Level: 7 Points: 489, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Dec 2006
Location: Berkshire, United Kingdom.
Posts: 104
Thanks: 9
Thanked 1 Time in 1 Post
Default

Thanks for the confirmation.

Aspless

  #7 (permalink)  
Old April 30th, 2008, 06:17 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

This can be done in Excel 2007 I believe.

The easy way to check appears to be to create a simple workbook and save it without a password. Then compare to the same document that is protecetd and passworded.

--

Joe (Microsoft MVP - XML)


Similar Threads
Thread Thread Starter Forum Replies Last Post
Password protect .pdf doc for subscribed reports NatashaL Reporting Services 1 December 2nd, 2008 07:54 PM
Set password in XLS on export aspless Classic ASP Basics 0 April 30th, 2008 03:59 AM
how to create zip file with password protect? mutu C# 2005 2 September 21st, 2007 06:17 AM
password protect a webpage Lois Dreamweaver (all versions) 1 March 6th, 2005 11:24 AM
Password-Protect Certain Scenes Ben Horne Flash (all versions) 5 April 5th, 2004 11:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.