0

How can I read a protected XLSX with JavaScript in the serve? I am using a sheets library, the xlsx-populate library doesn't works in the serve.

<html>
      <label for="file-selector">Select a file</label>
      <input type="file" id ="file-selector" required="">
</html>

<script>
const file = document.getElementById("file-selector").files[0];
file.arrayBuffer().then((res) =>{
      let data = new Uint8Array(res); 
      let workbook = XLSX.read(data,{password:"",type:"array"}); 
    
      let first_sheet_name = workbook.SheetNames[0];  
      let worksheet = workbook.Sheets[first_sheet_name]
      let jsonData = XLSX.utils.sheet_to_json(worksheet,{raw:true});
</script>

Error: File is password-protected

User1738
  • 18
  • 7
  • So did you try to supply the actual password, instead of just an empty string, already ...? – CBroe Sep 13 '21 at 08:33
  • Yes I try to supply with my actual password : let workbook = XLSX.read(data,{password:"aaa",type:"array"}); and also I try to write null: let workbook = XLSX.read(data,{password:null ,type:"array"}) – User1738 Sep 13 '21 at 08:35

0 Answers0