Save JQuery Handsontable to an excel file on server

前端 未结 1 1776
半阙折子戏
半阙折子戏 2021-01-17 01:52

Im looking for a solution in which you can save data entered using this jquery plugin http://handsontable.com/ to a file on the server.

Simply put they type in some

1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-17 02:58

    What your trying to do is certainly possible however there are a number of steps involved.

    • Handsontable seems to have a method called handsontable.getData().

    You can see in the Load & Save example they use this method to 'get the data' from the handsontable and insert it into the ajax function.

    • Use a Ajax function to pass this data to a server side script.

    Once your happy you can get the data, it needs to be passed to a server side script for further processing. This can be achieved using Ajax and POST or GET variables. For this step you can pretty much copy parts of their example. Otherwise Jquery has a nice Ajax function you could use.

    • Write a processing script to format the data in a CSV format and write it to a file.

    Once you can confirm the data is getting to your server side script you need to encode it in a CSV format. Some server side languages have functions to help you do this. Once you have the data in the right format, you can write it to a file.

    Keep in mind this wont produce a .xls file, it will make a .csv which is about as good as you will get with minimal fuss and will certainly be useful for people outside of the plugin. If you want to learn more about this sort of thing then you should take a look at submitting forms with ajax since this is essentially what your doing only more complex.

    0 讨论(0)
提交回复
热议问题