If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > Protect Excel sheet, after creating/opening thru the .asp/Java script.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-16-04, 16:06
vsshah vsshah is offline
Registered User
 
Join Date: Oct 2002
Posts: 48
Protect Excel sheet, after creating/opening thru the .asp/Java script.

Hi,

I am generating Excel Report output using .asp.

I am opening one existing .xls template. I am inserting data and picture in to cells. At last, I am using 'Saveas' other name.

So, all content of .xls sheet will be stored under new .xls file name. Now, I am showing this new .xls filereport in another window of .asp.

But this .xls file under browser is not protected. One can delete content or copy content(picture of signature).

So, I want to do one of this things.
1. Protect .xls sheet for delete/copy content of any cell in it.
2. I want to stop 'Right click event' and 'certain menu option' in excel sheet opened in new Window.
3. I want to open .xls in window in such a mode so, user can not copy any content from it.


I have done following ton create .xls file report. I used VB script and JavaScript also.
------------
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Application.Visible = True

' Close all pending books
ExcelApp.Workbooks.Close

'Open the template
Set ExcelBook = ExcelApp.Workbooks.Open("C:\Inetpub\iissamples\te\ TE_Supplement_Template.XLS", , True)
lsFullFileName = "C:\Inetpub\iissamples\te\TE_Supplement_Template2. XLS"

Set oFS = CreateObject("Scripting.FileSystemObject")
if (oFs.FileExists(lsFullFileName) = TRUE) then
oFS.DeleteFile(lsFullFileName)
End if

''''''assiging data stuff to cells.

ExcelBook.SaveAs lsFullFileName

ExcelApp.WorkBooks.Close

ExcelApp.Application.Quit
Set ExcelApp = Nothing
----------

I have used following to open this file from Java script.

====
window.open('c:/inetpub/iissamples/te/TE_supplement_template2.xls','CapitalExpenditure', 'menubar=yes,scrollbars=yes,resizable=yes,width=80 0,height=500')
====

Thanks in advance.....
Reply With Quote
  #2 (permalink)  
Old 02-17-04, 11:15
vsshah vsshah is offline
Registered User
 
Join Date: Oct 2002
Posts: 48
Got solution.

I used following way.

ExcelBook.Sheets(1).Protect DrawingObjects=False, Contents=False, Scenarios=False, Password="Chicago"

and it works. My .xls sheet is protected. But, if I want to unprotect using 'chicago' password. It is not. But, I am okay as long as .xls sheet gets protected.

So, my corrected code is as below in .asp.

------------
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Application.Visible = True

' Close all pending books
ExcelApp.Workbooks.Close

'Open the template
Set ExcelBook = ExcelApp.Workbooks.Open("C:\Inetpub\iissamples\te\ TE_Supplement_Template.XLS", , True)

lsFullFileName = "C:\Inetpub\iissamples\te\TE_Supplement_Template2. XLS"

Set oFS = CreateObject("Scripting.FileSystemObject")
if (oFs.FileExists(lsFullFileName) = TRUE) then
oFS.DeleteFile(lsFullFileName)
End if

''''''assiging data stuff to cells.

ExcelBook.Sheets(1).Protect DrawingObjects=False, Contents=False, Scenarios=False, Password="Chicago"

ExcelBook.SaveAs lsFullFileName

ExcelApp.WorkBooks.Close

ExcelApp.Application.Quit
Set ExcelApp = Nothing

------------
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On