Entering large amounts of text data in HTML form
I have a web page that has a requirement to allow users to paste large amounts of text data from an Excel spreadsheet directly into the input controls of the page. Typically the user would be pasting anywhere between 150 to 300 spreadsheet c开发者_开发知识库ells that are all in one column.
What are some good ways i could use to capture this data on the web page?
thanks
I have played with a few ways of doing this but the best way I have found is to start with a single multi-line text box and to have the user past the data into that box. It will come in with a multi-line tab separated format which you can then have javascript parse and place in the appropriate form fields and or generate form fields.
This way you will risk that the cell formatting and separation get lost and you'll likely end up with a heap of unparseable data. I'd rather add a file upload field so that the user can browse and upload an Excel or even a CSV file. In the server side code you need to read and parse the uploaded Excel or CSV file into useable data elements/variables/objects and then process them the way you want, e.g. saving in database and/or redisplaying in a HTML table.
It's unclear which server side programming language/framework you're using, but based on your question history here, I'll guess that it's ASP.NET, so here are some hints how you could handle it in the server side.
Update as per comment:
problem is the spreadsheets come from various sources and have no standard format, so would be impossible to parse
Well, your best bet is then to have a large <textarea>
and guess the cell format based on presence of linebreaks (\n
) and tabs (\t
) and that sort of things. However, keep in mind that the format may depend on the Excel version and the webbrowser make/version used. In some cases it might end up to be in HTML format! You could consider to simply display an error message when the format is undeterminable.
Whether issues due to large data may raise depends on the client and server used. Some clients may choke when the data goes into megabytes, especially MSIE. Servers may error when the submitted data exceeds a certain limit which is however pretty high, think of a gigabyte or two, which should however be configureable in the server settings. You should in any way use the HTTP POST
method since the data you can send in a GET
querystring is limited between 255 and 8K bytes depending on the client used.
精彩评论