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

Missing column in row if column value is empty string #75

Open
noumanbhatti opened this issue Oct 30, 2018 · 1 comment
Open

Missing column in row if column value is empty string #75

noumanbhatti opened this issue Oct 30, 2018 · 1 comment

Comments

@noumanbhatti
Copy link

I'm exporting data to CSV in Angular Reactive Forms.

My code in the .ts file is like

let data: BatchListCSV[]=[];
let obj: BatchListCSV = new BatchListCSV();
                    obj.created_date = new Date(b.created_date).toLocaleDateString();
                    obj.batch_type = b.batch_type;
                    obj.client_reference = b.client_reference;
                    obj.device_uid = b.device_uid;
                    obj.user_id =  b.user_id;
                    obj.ticket_count = b.ticket_count;

                    data[this.index] = obj;

this.csvData = data;
                
                this.csvOptions = {
                    headers: ['Date Created', 'Batch Type', 'Client Reference', 'Device UID','User', 'Ticket Count'], filename: 'Batches', fieldSeparator: ','
                    , quoteStrings: '"', decimalseparator: '.', showLabels: false, keys: [], removeNewLines: false, showTitle: false, title: '', useBom:false
                };

The sample data looks like

BatchListCSV {created_date: "10/31/2018", batch_type: "Tickets Created", client_reference: "5735", device_uid: "ipas_00e0c535be00", user_id: "", ticket_count: 1}
BatchListCSV {created_date: "10/31/2018", batch_type: "Tickets Created", client_reference: "Jayco Bendigo Cup (Featuring Mental As Anything)_311018.csv", device_uid: "", user_id: "[email protected]",ticket_count: 400}
BatchListCSV {created_date: "10/31/2018", batch_type: "Tickets Created", client_reference: "5748", device_uid: "ipas_00e0c535be00", user_id: "",ticket_count: 5}

When exported to CSV, for empty strings data like for user_id & device_uid in the data above. It ignores the empty string and uses the next column data instead. I want to show the empty string as it is for that column.

@noumanbhatti noumanbhatti changed the title Missing column in row if column value in empty string Missing column in row if column value is empty string Oct 30, 2018
@webkhushboo
Copy link

I am facing the same issue . It should not ignore empty field and move to next column value .
Please help to fix it

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

2 participants