Skip to main content
Known Participant
October 15, 2021
Question

How <cfspreadsheet> to read a password protected excel file?

  • October 15, 2021
  • 3 replies
  • 886 views

Hello All:

I tried to read password protected excel file by using this line of code

<cfspreadsheet action="read" query="MyControlPanelQuery" src="D:/LocalDocuments/FileName.xlsx">

I gave me this error "

An error occurred while reading the Excel: org.apache.poi.EncryptedDocumentException: The supplied spreadsheet is protected, but no password was supplied
"

I got this kind of error because the FileName.xlsx is password protected

The thing is "<cfspreadsheet action="read"....> doesn't any attribute to read a password protected excel file.

Any advice please?

 

Thank you

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    October 23, 2021
    EddieLotter
    Inspiring
    October 25, 2021

    Voted.

    BKBK
    Community Expert
    October 25, 2021

    Thanks, @EddieLotter .

    BKBK
    Community Expert
    October 16, 2021

     

    The thing is "<cfspreadsheet action="read"....> doesn't any attribute to read a password protected excel file.


    By @pham_mn

     

    Why do you say that? As @EddieLotter has said, cfspreadsheet has a password attribute. But, suppose Filename.xlsx is itself not password-protected. Then use as the value of the password attribute the password that offers read permissions D:/LocalDocuments.

    EddieLotter
    Inspiring
    October 15, 2021

    Use the "password" attribute to provide the password.

    See the documentation for details.

    pham_mnAuthor
    Known Participant
    October 17, 2021

    The <cfspreadsheet action="read"....> doesn't have password attribute...but the <cfspreadsheet action="write"..> does.

    This line 

    <cfspreadsheet action="read" query="MyControlPanelQuery" src="D:/LocalDocuments/MyControlPanelData.xlsx" headerrow="1" password="123">

     give me this error:

    Attribute validation error for tag CFSPREADSHEET.

    It does not allow the attribute(s) PASSWORD. The valid attribute(s) are ACTION,COLUMNNAMES,COLUMNS,EXCLUDEHEADERROW,FORMAT,HEADERROW,NAME,QUERY,ROWS,SHEET,SHEETNAME,SRC.
    BKBK
    Community Expert
    October 18, 2021

    You are right, @pham_mn . I cannot get the password attribute to work with any of the actions <cfspreadsheet action="read">, <cfspreadsheet action="update"> and <cfspreadsheet action="write">. 😞

     

    I have been testing on ColdFusion 2021 Update 2. What is your ColdFusion version?