• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

CF9 password protect xls file

New Here ,
May 08, 2016 May 08, 2016

Copy link to clipboard

Copied

Hello,

Is it possible to password protect a .xls file generated with CFspreadsheet, such that when the file is opened a password is required to VIEW the spreadsheet?

I realise you can password protect a file to request a password to make modifications (e.g protect the worksheet), but I'd like to prevent the file from viewing\opening without a password.

Using CF9.

Thanks,

TOPICS
Advanced techniques

Views

798

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 19, 2016 Jun 19, 2016

Copy link to clipboard

Copied

You are right: the password attribute in the cfspreadsheet tag only protects against modifications to the content. There is, to my knowledge, no cfspreadsheet setting to prevent the user from opening the Excel file.

Nevertheless, there is a workaround. You may, after creating the Excel file, zip it and, in doing so, impose a password which will be required before the user can view or open it.

But there is an obstacle to using cfzip for this in Coldfusion 9. The password attribute was introduced in cfzip only from ColdFusion 11. In coldFusion 9, you could install 7-Zip and use the cfexecute tag to run it, setting the password switch.

Here follows an example, on Windows. It creates testArchive.zip and requires the password AbracadaBra to open the zipped file.

<cfset args = "a C:\Users\BKBK\Desktop\excelPW\testArchive.zip -pAbracadaBra C:\Users\BKBK\Desktop\excelPW\testFile.xls" >

<cfexecute name="C:\Program Files\7-Zip\7z.exe" arguments="#args#"  timeout="10" variable="status"/>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 19, 2016 Jun 19, 2016

Copy link to clipboard

Copied

LATEST

HI,

Thanks for your reply.

I ended up creating a password protected pdf file.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation