csv-to-xlsx icon indicating copy to clipboard operation
csv-to-xlsx copied to clipboard

Numbers instead of text

Open betsonserviceportal opened this issue 3 years ago • 4 comments

Sorry, this is more of a question than an issue. This tool fixed my issue where Excel was converting a few pieces of data into dates, like MAR 3 or 06-083456. But I just noticed everything is text. Is there something I can do to get numbers in an obvious number column? Thanks.

betsonserviceportal avatar Feb 05 '21 02:02 betsonserviceportal

Hey @betsonserviceportal , kindly describe the steps required to reproduce the issue, providing any required data files (input and expected output).

If you look at the tests folder, there are a number of tables that have numbers working fine so it's most likely an edge case.

Aternus avatar Feb 13 '21 19:02 Aternus

Hi @Aternus -

Here's my example I posted in the SheetJS issues. I don't think I have an example using your csv-to-xlsx, but I think I just ran it through it and it fixed both the issues, but everything seemed to be "General" and I couldn't autosum number columns. I'll take a look at the tests folder. I'm probably missing something obvious.

Our ERP produces a .csv file containing these two rows.

"EIK","IMP","06-8108","IMP 06-8108","#658T MINI LAMP",6.000,.0860,.0860,.52,"710","IMP 16"
"MAR","MAR","250028162P","MAR 250028162P","BELT 143T MXL",1.000,1.8140,1.7690,1.77,"710","MAR 3"

When I open the the .csv file with Excel the "06-8108" in the first row becomes "Jun-08". In the second row "MAR 3" becomes "3-Mar".

I use js-xlsx for other tasks, so I figured I'd run it through and see if it fixed my issues. I have a very simple script:

var XLSX = require('xlsx'),
    source = '/INVTRY710.csv',
    destination = '/INVTRY710_test.xlsx';

try {
    workbook = XLSX.readFile(source);
    console.log(JSON.stringify(workbook));
    XLSX.writeFile(workbook, destination);
    success = true;
} catch (e) {
    success = false;
    error = e.toString();
}

This fixes the issue with "06-8108", "C12": { "t": "s", "v": "06-8108" }, but not the "MAR 3". "K18": { "t": "n", "v": 36953, "w": "3/3/01" },

betsonserviceportal avatar Feb 17 '21 15:02 betsonserviceportal

I just ran this test.

var convertCsvToXlsx = require('@aternus/csv-to-xlsx'),
    source = '/INVTRY710.csv',
    destination = '/INVTRY710_test.xlsx';

try {
    convertCsvToXlsx(source, destination);
} catch (e) {
    success = false;
    error = e.toString();
}

I'll attach the source and destination files if it lets me. spl2xls.zip

betsonserviceportal avatar Feb 17 '21 15:02 betsonserviceportal

Maybe I'm not understanding the tool. Your numbers.xlsx does show the numbers correctly, but the cell formats appear to be "General" and not real numbers. That's what was going on with my test as well. I wasn't able to AutoSum or treat the data like numbers.

betsonserviceportal avatar Feb 18 '21 17:02 betsonserviceportal