0

1.I am working in a project,were i am storing student name and phone number in a spreadsheet(.xls).

2.I am using django framework,in my app which have a button namely import from spreadsheet.So if i press this button i should able to upload a .xls file,and by pressing the save button the details namely name and phone number should be saved in database using parsing.

So how to achieve this.

My models.py is

class Contactlist
    report = models.ForeignKey(Report, null=True)
    cname = models.CharField(max_length=100)
    pnumber = models.IntegerField()  

Thanks

Monk L
  • 3,358
  • 9
  • 26
  • 41

1 Answers1

0

Use xlrd and write a method in your class that receives an Excel spreadsheet as input and imports the data. This site gives an example of how to use it in general, here is an example of using it in Django to accomplish this task.

You could also try the existing django-excel-import module.

Community
  • 1
  • 1
Dan
  • 4,488
  • 5
  • 48
  • 75
  • https://github.com/foreveryh/django-excel-import that link is not working.So were should i write the parseing code ,in views.py or in forms.py – Monk L May 12 '13 at 14:24
  • I would write it as a method in the model itself so all the form has to do is pass the Excel spreadsheet to the method and receive the output – Dan May 12 '13 at 17:51