2

I am currently using XLSX library to read an Excel sheet as follows.

using DataFrames
using XLSX

df = DataFrame(XLSX.readtable(excel_path, "sheet_name")...)

Now, I would like to read a password-protected Excel file, is there any way to do this? Currently in Python, I use the following solution. Is there any equivalent way in Julia, or is it just not doable at this stage?

import io
import pandas as pd
import msoffcrypto

passwd = 'xyz'

decrypted_workbook = io.BytesIO()
with open(path_to_your_file, 'rb') as file:
    office_file = msoffcrypto.OfficeFile(file)
    office_file.load_key(password=passwd)
    office_file.decrypt(decrypted_workbook)

df = pd.read_excel(decrypted_workbook, sheet_name='abc')
1
  • I would load msoffcrypto via PythonCall.jl, decrypt the file using Python's API, save it a a temporary file and than load the decrypted temporary file with XLXS.jl. Not exactly perfect but this should be quite robust and work well in production. Commented Feb 15, 2024 at 14:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.