Code Monkey home page Code Monkey logo

Comments (7)

chfw avatar chfw commented on September 24, 2024

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.

maltebeckmann avatar maltebeckmann commented on September 24, 2024

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.

maltebeckmann avatar maltebeckmann commented on September 24, 2024

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.

chfw avatar chfw commented on September 24, 2024

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.

maltebeckmann avatar maltebeckmann commented on September 24, 2024

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.

chfw avatar chfw commented on September 24, 2024

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.

maltebeckmann avatar maltebeckmann commented on September 24, 2024

@chfw Cheers!

from django-excel.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.