Export CSV ou EXCEL

Author Message

Anthony M.

Wednesday 24 September 2008 3:10:35 am

Hello,

i have listed some datas in the backoffice, and i want to make an export csv ou xls of these datas... i have created a new template with this code :

<html>
<head>
<meta http-equiv="Content-Type" content="application/vnd.ms-excel">
</head>
</html>
{def $pages = fetch( 'content', 'tree', hash( 'parent_node_id', '147', 'sort_by', array( 'modified', false() ) ) )}
{foreach $pages as $item}
	{$item.name};{$item.object.modified|l10n( shortdatetime )}\n
{/foreach}

but it doesn't work...
is it possible to make this ? can i modify the header in a template ?

thanks a lot for your help

Anthony

Jorge estévez

Wednesday 24 September 2008 4:29:13 am

Hi!

I recommend you stick to something similar to the pagelayout used for the printed version of the page that comes with ez "print_pagelayout.tpl".

I am working in a similar problem exporting (saving somehow) the content of the information of the basket to an excel format, the only problem is that I have to have images, but images are not constrain into a cell (everybody seems to say the same), so it's getting a little difficult to solve this issue.

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

Anthony M.

Wednesday 24 September 2008 5:14:18 am

i call my page like this : "http://mysite.com/site_admin/layout/set/excel/" and the page is "excel_pagelayout.tpl"

but the problem is the header...
in php i can specify the header like this :

<meta http-equiv="Content-Type" content="application/vnd.ms-excel">

but in the template, i can't do that...

Anthony

Nicolas Lescure

Wednesday 24 September 2008 12:42:23 pm

Hi,

I can see this in the layout.ini :

# Consists of groups which are the layout name
# A layout group can have the followin variables
# - PageLayout  - Uses a different pagelayout for this page
# - ContentType - Sets 'Content-Type' for layout module output
#                 example: ContentType=text/xml

So, you shoud try this :

[excel]
PageLayout=excel_pagelayout.tpl
ContentType=application/vnd.ms-excel

Anthony M.

Thursday 25 September 2008 12:36:13 am

thank you very much, it works fine !! ;-)

Anthony

Jorge estévez

Wednesday 01 October 2008 6:15:50 am

Glad you solved your problem,

You can find mime (Multipurpose Internet Mail Extensions) types here:

http://www.w3schools.com/media/media_mimeref.asp

Check it out...

Diseño Web Cuba
Web Design Cuba
www.elfosdesign.com

SEBBANE Alexandre

Tuesday 09 December 2008 10:25:51 am

hello , i didnot succeed :

my template is ok :

<html>
<body>
<table>
	<tr>
		<td>Nom-Prénom</td>
		<td>Entité</td>
		<td>Téléphone</td>
		<td>E-mail</td>
	</tr>
	<tr>
		<td>Name1</td>
		<td>entity</td>
		<td>phone1</td>
		<td>mail1</td>
	</tr>	<tr>
		<td>Name11</td>
		<td>entity1</td>
		<td>phone11</td>
		<td>mail11</td>
	</tr>
</table>
</body>
</html>

my lyout is just :

{$module_result.content}
<!--<!--DEBUG_REPORT-->-->

my layout.ini is

[xls]
ContentType=application/vnd.ms-excel
PageLayout=xls_pagelayout.tpl

please help me i didn't see what it is wrong

thanks

Paris, France

Nicolas Lescure

Tuesday 09 December 2008 11:26:23 am

Did you try this ?

<meta http-equiv="Content-Type" content="application/vnd.ms-excel">

Which url do you use to call your page ?

Piotrek Karaś

Tuesday 09 December 2008 2:12:36 pm

I don't know what 'ou' means, but I've successfully used this library:
http://www.phpexcel.net (PHPExcel)
This is much better than just trying to force headers...
Good luck,
Piotrek

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 16:17:38
Script start
Timing: Jan 18 2025 16:17:38
Module start 'layout'
Timing: Jan 18 2025 16:17:38
Module start 'content'
Timing: Jan 18 2025 16:17:38
Module end 'content'
Timing: Jan 18 2025 16:17:38
Script end

Main resources:

Total runtime0.0154 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 590.3203152.6094
Module start 'layout' 0.00560.0033 742.929739.4141
Module start 'content' 0.00890.0043 782.3438101.4297
Module end 'content' 0.01330.0020 883.773442.3047
Script end 0.0153  926.0781 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002516.3943140.0002
Check MTime0.00116.8811140.0001
Mysql Total
Database connection0.00074.849710.0007
Mysqli_queries0.002315.185430.0008
Looping result0.00000.071410.0000
Template Total0.001711.410.0017
Template load0.00106.249510.0010
Template processing0.00085.110410.0008
Override
Cache load0.00064.173110.0006
General
dbfile0.00021.379680.0000
String conversion0.00000.045040.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs