Comments (7)
What is your versions of pyexcel-webio, pyexce-io and pyexcel-xls?
What about a break point at the following location? You can try print(sheet) to see if it has any content.
https://github.com/pyexcel/django-excel/blob/master/django_excel/__init__.py#L154
from django-excel.
Thanks for getting back so soon!
pyexcel==0.4.3
pyexcel-io==0.3.2
pyexcel-webio==0.0.10
pyexcel-xls==0.3.1
pyexcel-xlsx==0.3.0
I set a breakpoint just before the line you specified and got this for args:
(Pdb) args
model = <class 'apps.cities.models.City'>
file_type = 'xlsx'
status = 200
file_name = 'sheet'
keywords = {}
When I do runserver and put a print(sheet) just below line 154, like this:
sheet = pe.get_sheet(model=model, **keywords)
print(sheet)
I get an error saying
file_type 'xlsx'
keywords {}
status 200
sheet Error in formatting: KeyError: <class 'decimal.Decimal'>
file_name 'sheet'
model <class 'apps.cities.models.City'>
from django-excel.
I set a break point just after line 154 and tried print(sheet) and got:
-> return make_response(sheet, file_type, status,
(Pdb) print(sheet)
*** KeyError: <class 'decimal.Decimal'>
Btw, I am running PY3.4.3
from django-excel.
Your library are compatible with each other. The KeyError is not the cause though. The default renderer to console failed to handle Decimal type.
What about putting a break point here and change file_type to 'csv', then you could do print(file_content.getvalue()):
https://github.com/pyexcel/pyexcel-webio/blob/master/pyexcel_webio/__init__.py#L261
I am trying to see if there are content obtained from your data table.
from django-excel.
I tried the print(file_content.getvalue()) and it printed tons and tons of text. However, I do have a site with multiple-languages using django-parler.
So I tweaked the custom bit a little, like this:
elif atype == "custom":
query_sets = City.objects.language('en').all()
column_names = ['id', 'title', 'country']
return excel.make_response_from_query_sets(
query_sets,
column_names,
'xls',
file_name="custom"
)
And that output exactly what I wanted into the xls file. So it seems that make_response_from_a_table and make_response_from_tables may not work with django-parler.
So I guess everything is sort of fine with django-excel. I presume it's not feasible to make those functions above work with special django setups providing multilingual features.
Thanks for getting back to me!
from django-excel.
pyexcel-io uses model._meta.concrete_fields to find out all columns. I think django-parler has modified model's behavior so pyexcel-io could not inspect all its fields. I will look at parler further when I have time.
from django-excel.
@chfw Cheers!
from django-excel.
Related Issues (20)
- Save to model.FileField a generated xls
- How dow I format individual fields from a queryset in a make_response_from_querysets HOT 1
- How do I ignore a row or column when import data use save_to_database? HOT 2
- Incorrect message on file not found HOT 2
- Doc in Chinese HOT 1
- Unable save table after making changes in the model.py file HOT 1
- Question: How to overwrite the default encoding HOT 3
- Exception Type: IntegrityError Exception Value: UNIQUE constraint failed: myapp_question.slug HOT 2
- Not able to upload large excel or CSV file with the size 10Mb
- Urgent Help: Trying to Import data from two sheets(xlsx) into two different models(Foreign Key Related) - Not able to lead the Data HOT 5
- build failed with django 3.1.1 HOT 8
- jump column HOT 3
- Unable to support XLS and XLSX uploads in Python 3.9 HOT 3
- start test got wrong HOT 2
- Can't get XLSX support working HOT 4
- Import related models without static foreign keys HOT 4
- How to create an import for whole document without defining 'choice' and 'question'?
- Realy? Object of type UUID is not JSON serializable HOT 2
- Django 4.0 forward compatibility Error HOT 1
- <ul class="errorlist"><li>This field is required.</li></ul>
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from django-excel.