Trouble editing excel file using XLSX.jl package.


#1

Greetings,

I’m writing code for a function whose output is an edited .xlsx file. I’m using package XLSX.jl for the purpose, but I’m getting the following error message:

Thank you in advance for everyone’s help. Cheers.


#2

Can you post a minimum working example that reproduces the error?


#3

I think my problem has more to do with the usage of the function. Maybe a bug or something. I used the function just to read the file without doing anything to it and I got the same error message:

The line on the source code that appears to generate the problem is the following:

Sorry if my question is too vague or obscure, I’m new at Julia.

Cheers.


#4

You should write the code instead of posting screenshots


#5

I think this is https://github.com/felipenoris/XLSX.jl/issues/71 . I’ll debug this in a few days.


#6

That’s exactly it. Thanks a lot.


#7

@rna1990, I just merged a fix to branch master.

Can you check if it fixes your issue?

Cheers!


#8

@felipenoris I tried again and now it throws an AssertionError :


#9

I can’t tell what’s happening based on your print screen. Can you paste code?


#10

@felipenoris I can try later to paste some adapted code that replicates the error. I’m just trying to write some values calculated in Julia on an Excel template using XLSX.openxlsx(…, mode=“rw”) Meanwhile, from the error message I can understand that the function openxlsx uses a SheetRowIterator to read sheet content, but it returns nothing because of “@assert !isopen(state)” on line 122 of stream.jl

Thank you for trying to help me.


#11

I just tagged a new version for XLSX.jl. Use Pkg.update() to get the latest version. If your issue persists, try deleting your packages and install them again. If it still persists, let me know.


#12

Hello, Felipe.

I tried what you told me, but I’m still having the same problem. I also tried constructing a simplified version of my datasets, of my excel template and of the code I’m working on, but (sadly) I’m not able to reproduce the error message I’m getting (somehow, the writing I need to do on my excel template works just fine on the simplified version).

The error message I’m getting is because of the row iterator that openxlsx uses. It reads: “AssertionError: !(isopen(state))”. What does that mean? Is the function failing to close the xlsx file after editing, which causes an error or something like that?


#13

Sorry, I can’t do much to help you if I can’t reproduce the error.

Yes, you’re hitting an inconsistent state: the stream should be already closed when you’re at the last row of the worksheet. This might be a bug in the package XLSX.jl, or a malformed excel file.

I would be very interested to debug your case, since this is a core function in the whole package.