Hi
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).
Example:
Code:
Col1 Col2
Test1 Res1
Test2 Res2a
Res2b
Test3 Res3
Test4 Res4a
Res4b
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.
jQuery code used:
Code:
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)
Test4 (tab) "Res4a (break)
Res4b (break)
Res4c"(break)
I think I will need a regex that can convert the breaks within the quoted text, however I don't know how. Can you help out?