mashingan / excelin

Create and read Excel file purely in Nim
MIT License
51 stars 1 forks source link

Wrong column addressing when reading cells #3

Closed nick133 closed 2 years ago

nick133 commented 2 years ago

Hi, it looks like new issue is coming. I try to parse excel column in a loop but I get a results from other columns

To reproduce I created minimal xlsx file with no formatting at all and run this code:

echo "-" & sheet.row(2)["E", string] &
    "-" & sheet.row(2)["F", string] &
    "-" & sheet.row(2)["G", string]

it prints: -ddd-aaa-bbb

and that's the file's content: 20220514_20h12m53s_grim

mashingan commented 2 years ago

Could you provide the excel sample for you case? Here's our result with simplified excel and code sample. issue-3 2

You can also check the version installed with

import excelin

doAssert excelinVersion == "0.4.7"

to make sure whether it's the latest version. If it runs with no error then it's the latest.

nick133 commented 2 years ago

Upgraded to 0.4.7 with no luck. Try this code on attached file:

import
    std/strutils,
    std/strformat,
    excelin

proc main =
let
    fn = "Finances.xlsx"
    xl = readExcel fn
    sheet = xl.getSheet "Portfolio"

    echo "---: " & sheet.row(2)["E", string]
    echo "Aaa: " & sheet.row(2)["F", string]
    echo "Bbb: " & sheet.row(2)["G", string]
    echo "Ccc: " & sheet.row(2)["H", string]

when isMainModule:
    main()

It produces:

---: Bbb
Aaa: Ccc
Bbb: Ddd
Ccc:

If I delete some formatting or whole cells from the A-D columns - at some point it behaves as expected. Otherwise, data is always shifted by column(s) or sometimes is shifted and mixed

Finances.xlsx

mashingan commented 2 years ago

Feel free to re-open if the problem persists.

nick133 commented 2 years ago

I have SEGFAULT with v0.4.8 after every call to .row()[] at runtime like this:

Traceback (most recent call last)
/home/nick/Projects/Code/xlstest/src/xlstest.nim(53) xlstest
/home/nick/Projects/Code/xlstest/src/xlstest.nim(41) main
/home/nick/.nimble/pkgs/excelin-0.4.8/excelin/internal_rows.nim(7) row
SIGSEGV: Illegal storage access. (Attempt to read from nil?)

even on empty xlsx file

mashingan commented 2 years ago

The issue continuation is now tracked at #4 .