January 13th, 2013, 03:20 AM
Paste from excel
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).
(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:
When copying from excel the export is
var data = $("#import_text").val();
var arr = data.split( /[\r\n]/g );
row = arr[i].split( /\t/ );
col1 = $.trim(row);
col2 = $.trim(row);
//Set values and such
Test1 (tab) Res1 (break)
Test2 (tab) "Res2a (break)
Test3 (tab) Res3 (break)
Test4 (tab) "Res4a (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?
January 13th, 2013, 08:22 AM
What value do you get in your application if the Excel field contains a literal "?
January 13th, 2013, 09:27 AM
That indeed will screw things up, however if I recall correctly only singlequotes are used