Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
aa.gusti
/
opensipkd-base
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit d73cc916
authored
May 30, 2026
by
aa.gustiana@gmail.com
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Add XLS export functionality and update CSV handling in DeTable
1 parent
db417a93
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
5 deletions
opensipkd/base/views/base_views.py
opensipkd/detable/detable.py
opensipkd/base/views/base_views.py
View file @
d73cc91
...
@@ -19,7 +19,7 @@ from opensipkd.tools import dmy, get_settings, get_ext, \
...
@@ -19,7 +19,7 @@ from opensipkd.tools import dmy, get_settings, get_ext, \
date_from_str
,
get_random_string
,
Upload
,
InvalidExtension
,
mem_tmp_store
date_from_str
,
get_random_string
,
Upload
,
InvalidExtension
,
mem_tmp_store
from
opensipkd.tools.buttons
import
(
from
opensipkd.tools.buttons
import
(
btn_save
,
btn_cancel
,
btn_close
,
btn_delete
,
btn_add
,
btn_csv
,
btn_edit
,
btn_save
,
btn_cancel
,
btn_close
,
btn_delete
,
btn_add
,
btn_csv
,
btn_edit
,
btn_pdf
,
btn_upload
)
btn_pdf
,
btn_upload
,
btn_xls
)
# from opensipkd.tools.captcha import get_captcha
# from opensipkd.tools.captcha import get_captcha
from
opensipkd.tools.report
import
csv_response
,
file_response
,
xls_response
from
opensipkd.tools.report
import
csv_response
,
file_response
,
xls_response
...
@@ -104,7 +104,9 @@ class BaseView(object):
...
@@ -104,7 +104,9 @@ class BaseView(object):
self
.
list_route
=
'home'
self
.
list_route
=
'home'
# self.list_col_defs = ""
# self.list_col_defs = ""
# self.list_cols = ""
# self.list_cols = ""
self
.
list_report
=
(
btn_csv
,
btn_pdf
)
self
.
list_report
=
(
btn_csv
,
btn_xls
)
self
.
list_csvpdf
=
(
btn_csv
,
btn_pdf
)
self
.
list_pdf
=
(
btn_pdf
,)
self
.
list_buttons
=
(
btn_add
,)
self
.
list_buttons
=
(
btn_add
,)
self
.
list_upload
=
(
btn_upload
,)
self
.
list_upload
=
(
btn_upload
,)
self
.
list_view_field
=
None
self
.
list_view_field
=
None
...
@@ -553,7 +555,8 @@ class BaseView(object):
...
@@ -553,7 +555,8 @@ class BaseView(object):
elif
url_dict
[
'act'
]
==
'csv'
:
elif
url_dict
[
'act'
]
==
'csv'
:
return
self
.
csv_response
(
**
kwargs
)
return
self
.
csv_response
(
**
kwargs
)
elif
url_dict
[
'act'
]
==
'csv1'
:
return
self
.
csv1_response
(
**
kwargs
)
elif
url_dict
[
'act'
]
==
'pdf'
:
elif
url_dict
[
'act'
]
==
'pdf'
:
return
self
.
pdf_response
(
**
kwargs
)
return
self
.
pdf_response
(
**
kwargs
)
...
@@ -668,7 +671,7 @@ class BaseView(object):
...
@@ -668,7 +671,7 @@ class BaseView(object):
filename
=
jasper_export
(
self
.
report_file
)
filename
=
jasper_export
(
self
.
report_file
)
return
file_response
(
self
.
req
,
filename
=
filename
[
0
])
return
file_response
(
self
.
req
,
filename
=
filename
[
0
])
def
csv_response
(
self
,
**
kwargs
):
def
csv
1
_response
(
self
,
**
kwargs
):
query
=
self
.
table
.
query_register
()
query
=
self
.
table
.
query_register
()
row
=
query
.
first
()
row
=
query
.
first
()
header
=
row
.
_mapping
.
keys
()
header
=
row
.
_mapping
.
keys
()
...
@@ -722,6 +725,12 @@ class BaseView(object):
...
@@ -722,6 +725,12 @@ class BaseView(object):
for
i
,
value
in
enumerate
(
row
):
for
i
,
value
in
enumerate
(
row
):
if
isinstance
(
value
,
str
):
if
isinstance
(
value
,
str
):
row
[
i
]
=
self
.
remove_tags
(
value
)
row
[
i
]
=
self
.
remove_tags
(
value
)
elif
isinstance
(
value
,
datetime
):
is_aware_utc
=
value
.
tzinfo
is
not
None
\
and
value
.
tzinfo
.
utcoffset
(
value
)
is
not
None
if
is_aware_utc
:
value
=
value
.
astimezone
()
.
replace
(
tzinfo
=
None
)
row
[
i
]
=
value
value
=
{
value
=
{
'header'
:
header
,
'header'
:
header
,
...
@@ -729,11 +738,14 @@ class BaseView(object):
...
@@ -729,11 +738,14 @@ class BaseView(object):
}
}
return
value
return
value
def
xls_response
(
self
,
**
kwargs
):
def
xls_response
(
self
,
**
kwargs
):
value
=
self
.
xls_data
()
value
=
self
.
xls_data
()
return
xls_response
(
self
.
req
,
value
)
return
xls_response
(
self
.
req
,
value
)
def
csv_response
(
self
,
**
kwargs
):
value
=
self
.
xls_data
()
return
csv_response
(
self
.
req
,
value
)
def
get_bindings
(
self
,
row
=
None
):
def
get_bindings
(
self
,
row
=
None
):
return
{
"row"
:
row
}
return
{
"row"
:
row
}
...
...
opensipkd/detable/detable.py
View file @
d73cc91
...
@@ -190,6 +190,14 @@ class DeTable(field.Field):
...
@@ -190,6 +190,14 @@ class DeTable(field.Field):
window.location = o
%
sUri+'/csv/act
%
s&'+paramString;}
window.location = o
%
sUri+'/csv/act
%
s&'+paramString;}
"""
%
(
"""
%
(
tableid
,
tableid
,
params
),
tableid
,
tableid
,
params
),
"csv2"
:
"""{
params = o
%
s.ajax.params();
paramString = $.param(params);
console.log(params);
window.location = o
%
sUri+'/csv2/act
%
s&'+paramString;}
"""
%
(
tableid
,
tableid
,
params
),
"xls"
:
"""{
"xls"
:
"""{
params = o
%
s.ajax.params();
params = o
%
s.ajax.params();
paramString = $.param(params);
paramString = $.param(params);
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment