Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR: Styles not found for this workbook. #233

Open
StefanPofahl opened this issue Jun 23, 2023 · 4 comments
Open

ERROR: Styles not found for this workbook. #233

StefanPofahl opened this issue Jun 23, 2023 · 4 comments

Comments

@StefanPofahl
Copy link

In my Excel file is one cell in column "C" with the following value:
-5,01085245571595E-09
And this results in the error message:
ERROR: Styles not found for this workbook.

foo.xlsx

@nilshg
Copy link

nilshg commented Jun 26, 2023

How do you know it's this value that causes the error? And how did you get this error? When trying to read your file I get:

julia> XLSX.readxlsx("foo.xlsx")
ERROR: ArgumentError: no node name

which I think is the same error as #170 - you have a sheet with only a chart in it. Trying to get the table data directly:

julia> XLSX.readtable("foo.xlsx", 1)
ERROR: Shared Strings Table not found for this workbook.

after deleting the chart-only tab, I can read the file:

julia> XLSX.readxlsx("C:/Users/ngudat/Desktop/foo.xlsx")
XLSXFile("foo.xlsx") containing 1 Worksheet
            sheetname size          range
-------------------------------------------------
             Tabelle1 13x4          A2:D14

but I still get the same error as above when trying to read the workbook. Changing the -5.01e09 value also doesn't help, so at least on my machine (Julia 1.9.1, XLSX.jl 0.9.0) this has nothing to do with that value. Indeed copying the data over into a blank new worksheet works just fine:

julia> DataFrame(XLSX.readtable("footest.xlsx", 1))
12×3 DataFrame
 Row │ Mass Flow H2  PCS Power    FCS Voltage
     │ Any           Any          Any
─────┼────────────────────────────────────────
   1 │ kg/h          kW           V
   2 │ 0             0.00702436   0.980267
   3 │ 0             -0.00283964  0.974933
   4 │ 0             0.0121058    0.913333
   5 │ 0             0.0827978    0.8576
   6 │ 0             0.151248     0.8216
   7 │ 0             0.23016      0.794667
   8 │ 0             0.289194     0.773333
   9 │ 0             0.332088     0.750667
  10 │ 0.01088       0.385891     0.734667
  11 │ 0.0576        0.427888     0.722933
  12 │ 0             -5.01085e-9  0.987733

So it seems to me that your file is somehow corrupted.

@StefanPofahl
Copy link
Author

I work with try-catch and the error occured on the cell that contains: -5,01085245571595E-09
If I replace the value by "0,00015" everything works fine (on my machine comma , is the digital delimiter)

                try
                    push!(P_FCS, i_sr["C"])
                catch
                    println("rownum: ", rownum, ", t: ", i_sr["A"])
                    display(i_sr);
                end

For completness the full snippet:
Note:
In my example the problematic cell is in column "C":

    t_vec = Vector{Float64}(undef, 0)
    ΦH2   = Vector{Float64}(undef, 0)
    P_FCS = Vector{Float64}(undef, 0)
    XLSX.openxlsx(fn_sel, enable_cache = false) do xf
        name_sheet1 = XLSX.sheetnames(xf)[1]
        sheet = xf[name_sheet1]
        for i_sr in XLSX.eachrow(sheet) # sr = sheet raw
            rownum = XLSX.row_number(i_sr)
            if rownum > 3 # && rownum < 10
                if ~isempty(i_sr["A"]) && ~isempty(i_sr["B"])  
                # if ~isempty(i_sr["A"]) && ~isempty(i_sr["B"]) && ~isempty(i_sr["C"]) # does not work, because the issue is in column "C"
                # if ~isempty(i_sr[3]) 
                    push!(t_vec, i_sr["A"])
                    push!(ΦH2,   i_sr["B"])
                    try
                        push!(P_FCS, i_sr["C"])
                    catch
                        println("rownum: ", rownum, ", t: ", i_sr["A"])
                        display(i_sr);
                    end
                end
            end
        end
    end

@felipenoris
Copy link
Owner

I couldn't reproduce this.

julia> fn_sel = "foo.xlsx"
"foo.xlsx"

julia> t_vec = Vector{Float64}(undef, 0)
Float64[]

julia> ΦH2   = Vector{Float64}(undef, 0)
Float64[]

julia> P_FCS = Vector{Float64}(undef, 0)
Float64[]

julia> XLSX.openxlsx(fn_sel, enable_cache = false) do xf
           name_sheet1 = XLSX.sheetnames(xf)[1]
           sheet = xf[name_sheet1]
           for i_sr in XLSX.eachrow(sheet) # sr = sheet raw
               rownum = XLSX.row_number(i_sr)
               if rownum > 3 # && rownum < 10
                   if ~isempty(i_sr["A"]) && ~isempty(i_sr["B"])
                   # if ~isempty(i_sr["A"]) && ~isempty(i_sr["B"]) && ~isempty(i_sr["C"]) # does not work, because the issue is in column "C"
                   # if ~isempty(i_sr[3])
                       push!(t_vec, i_sr["A"])
                       push!(ΦH2,   i_sr["B"])
                       try
                           push!(P_FCS, i_sr["C"])
                       catch
                           println("rownum: ", rownum, ", t: ", i_sr["A"])
                           display(i_sr);
                       end
                   end
               end
           end
       end
rownum: 14, t: 1.0999999999999999
XLSX.SheetRow(13×4 XLSX.Worksheet: ["Tabelle1"](A2:D14) , 14, Dict{Int64, XLSX.Cell}(4 => XLSX.Cell(D14, "", "", "0.98773333333333424", ""), 2 => XLSX.Cell(B14, "", "", "0", ""), 3 => XLSX.Cell(C14, "", "1", "-5.0108524557159498E-9", ""), 1 => XLSX.Cell(A14, "", "", "1.0999999999999999", "")))

@StefanPofahl
Copy link
Author

Could it be that it is related to the so called "localisation"?
On my machine the decimal delimiter is the comma "," instead of dot "."?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants