I am trying to provide an easy import from excel feature to the user. They can copy paste some values from the excel template to the webinterface. However when excel has a multiline cell (I mean a cell with a break (or multiple) in it, not merged cells).
Res4c
(The multiline can be an unknown amount of lines)
I want to import these and add them to a form with a textarea per field so 2 fields per row.
Now i can do this for the singleline cells, however how can I use this for the multiline?
I am thinking for something in the split, however I can not figure out what. I tried some regexpressions, but I', not so well known with these.
code used:
- var data = $("#import_text").val();
- var arr = data.split( /[\r\n]/g );
- $.each(arr, function(i){
- row = arr[i].split( /\t/ );
- col1 = $.trim(row[0]);
- col2 = $.trim(row[1]);
- //Set values and such
- }
- });
When copying from excel the export is
Test1 (tab) Res1 (break)
Test2 (tab) "Res2a (break)
Res2b"(break)
Test3 (tab) "Res3 (break)