I
I
Ivan Suroegin2016-02-16 19:01:32
Django
Ivan Suroegin, 2016-02-16 19:01:32

Pasting Excel data from the clipboard into a site powered by Django - how?

Good evening!
I have been writing in Python for a long time, with Django at the stage of acquaintance, but I do not experience any difficulties.
However, I encountered such a difficulty - I still can’t figure out how to organize the transfer of information from Excel to a site that also has cells and can perform operations on data.
1. In Excel, I select the desired cells, copy, the data appears in the clipboard.
2. What should be used to read data from the clipboard? buffer protocol?
3. Suppose you have retrieved data from the clipboard, in what form should they be stored in order to then carry out all sorts of operations on them? And what module makes it possible to display cells like in excel?
4. After operations on the data, you will need to issue an Excel format - the openpyxl module - I think it will do. Or which one do you recommend?
I still have little idea how to implement this, but I'm trying to figure it out. Maybe someone has already done this?
I'll be glad for tips.
Sincerely,
Ivan.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shcherbakov, 2016-02-16
@ivan_suroegin

var data = $('textarea').val();

$.each(data.split(/\n/), function(l, line) {
  // сплитуем по строкам
  $.each(line.split(/\t/), function(r, rows) {
    // сплитуем по столбцам
      console.log(rows[r]);
  });
});

And that's it, you can process the data as you wish. At least collect the object, send it to the server to generate *.XLS; though from object build table.../table for visual delivery on the client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question