Closed scandey closed 3 years ago
Thanks for the detailed problem report! I'll take a look at it.
Now when spreadsheets are created, any cell containing a string has its number format set as TEXT. That means anything you type into the cell should be interpreted as text so entering 0603 will result in the string 0603 instead of the number 603. In order to enter an actual number, you'll have to explicitly format the cell with a number format.
It's in the development branch. Let me know if it fixes the problem.
That works for me, thank you!
Another edge case issue that is easily worked around on the user end, just confused me for a bit.
When an Excel spreadsheet is extracted from schematic and then edited to have a cell with any format except Text containing just a number, it causes a TypeError when that spreadsheet is then inserted back into the schematic. Behavior not seen with .csv export.
Seems like Excel forces any edited cell with format of General containing just a number to remain a number, notable in that a cell with just 0805 for footprints is immediately replaced by 805. If the user is careful about resetting every cell with just a number to Text format, there are no issues. Since the Excel spreadsheet exported by KiField seems to have a string in a General formatted cell, inserting an unmodified spreadsheet causes no issues.
If possible, it would be lovely to have KiField do a sanity check or cast to string before importing from Excel cells, though I realize this is perhaps more easily solved by the user before inserting.
Thank you again for your work on this project!
Simplest possible schematic included, with example .xlsx and .csv files for comparison. footprint.zip
footprint.sch
has one resistor with a footprint of 0805. Extracted tofootprint.xlsx
andfootprint.csv
withkifield -x /Users/scottcandey/Desktop/footprint.sch -i ~/Desktop/footprint.csv
Change from 0805 to 0605 footprint in the Excel document causes the cell to container a number, 603. Also changed CSV for consistency, 0805 to 0603.
Attempted Excel insertion with
kifield -x ~/Desktop/footprint.xlsx -i /Users/scottcandey/Desktop/footprint.sch -d 10
results in TypeError: expected string or bytes-like object.Attempted CSV insertion with
kifield -x ~/Desktop/footprint.csv -i /Users/scottcandey/Desktop/footprint.sch -d 10
results in a successful insertion.To isolate the issue, I also tried with the footprint cell of the Excel spreadsheet set to Text format, which also had no problem,
kifield -x ~/Desktop/footprint_text.xlsx -i /Users/scottcandey/Desktop/footprint.sch -d 10