i need it too … plz help
davelaser do you get your answer ?
i need it too … plz help
davelaser do you get your answer ?
hi again
i find the way to do this … it’s simple… … if you want i can help u dear davelaser
@aliabzad I think it would be helpful for anyone please post your solution, or if you blog about it somewhere, it would be really nice that you post the link to your post.
Cheers!
Hi,
I got two problem:
a. I set the value of the column to a float by calling floatval(). However, the column does not formatted to xxx,xxx,xxx.00. If I am using result from number_format, it will be treated as string not a number. How should I fix this? My final objective is not just return the value but also show the value in red and within parentheses when negative.
Thank you in advance.
ok … i’ll post it in this topic in this week my friend
hi all again
i have new question
please help me to do this my friends
i want to get excel file from my informtion after i had searched it … when i submit the button the exported excel file has all of the information but i want just searched result information , as you know search is enabled in CGridView … tanx in advance
Daniel … your problem will solve if you use template for your excel … now i’m very busy … i try to post the way to use templates very soon
Hello aliabdzad,
The sample code in the extension page already does what you need (it’s for apps with urlFormat = ‘path’):
<?php Yii::app()->clientScript->registerScript('search', "
$('#exportToExcel').click(function(){
window.location = '". $this->createUrl('admin') . "?' + $(this).parents('form').serialize() + '&export=true';
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('some-grid', {
data: $(this).serialize()
});
return false;
});
"); ?>
…
<div class="search-form" style="display:block">
<?php $this->renderPartial('_search', array(
'model' => $model,
)); ?>
</div><!-- search-form -->
…
<?php $form = $this->beginWidget('GxActiveForm', array(
'action' => Yii::app()->createUrl($this->route),
'method' => 'get',
)); ?>
…
<div class="row buttons">
<?php echo GxHtml::submitButton(Yii::t('app', 'Search')); ?>
<?php echo GxHtml::button(Yii::t('app', 'Export to Excel (xls)'), array(
'id' => 'exportToExcel',
)); ?>
</div>
<?php $this->endWidget(); ?>
hi my friends … how we can save excel as excel2010 or upper like 2013 ? tanx
Hi bennouna,
thanks for this great extension, i just wandering is it possible for us to export the excel outside the search form (in the bottom of the grid for example)? i mean, user can export the grid to excel with already filtered dataprovider (if they do the filter or search.)
because, for now, we use form.serialize() so we need to put it inside the search_form right (CMIIW)?
and another question is about, is it possible to modify the header of the file? i mean, can we add a title before render the column header?
Thanks,
Rangganovsky
Hi Rangganovsky,
<?php Yii::app()->clientScript->registerScript('search', "
$('#exportToExcel').click(function(){
// Edit: specify the field controls since there's no form wrapper in the grid filter header.
// Reminder: jQuery’s .serialize() method applies only on a form or its child controls / nodes
window.location = '". $this->createUrl('admin') . "?' + $('table.items tr.filters input, table.items tr.filters select').serialize() + '&export=true';
return false;
});
$('.search-form form').submit(function(){
$.fn.yiiGridView.update('some-grid', {
data: $(this).serialize()
});
return false;
});
"); ?>
Cheers!
Bennouna
Hi again Bennouna,
thanks for the fast response, but i have a difficulties here. do you mind to explain to me (again) about this code :
window.location = '". $this->createUrl('admin') . "?' + $('table.items tr.filters input, table.items tr.filters select').serialize() + '&export=true';
return false;
ok then, i’ve tried to figure it out. what is table.items? tr.filters input? did you mean we have to change the ‘table’ to ‘our_grid_id’? how the mechanism to wire up the request which is triggered by clicked the export button to our filtered dataprovider in the grid?
sorry if you think that was a silly question coz i’m a bit lost there, as i don’t really familiar with jquery things .
and also, i’ve raised an issue in github repository as you suggest, do you mind to take a look it? as it would be a nice feature if we can implemented it and i’m looking forward to it.
edit post :
i have just upload my code to the shared host server. but then, every time i clicked the export button, the error “web page can not be found” always shows up. it is weird, coz i’m able to do this on my localhost. and also the error isn’t came from yii (yii not rendering the standard 404 page not found). so i guess it might be something wrong with my shared host config. but i’m not a hundred percent sure, it would be great if anyone here had experienced the same problem and hopefully lead me to the solutions.
many thanks,
Rangganovsky
Hello Rangganovsky,
$(this).parents('form').serialize()
applies when the user click on the “Export” button inside the “Advanced search” form. So we just catch that event and we reload the page using the current URL, which we add the serialized search form to. So when you inspect the page in Chrome e.g. you’d get really the resulting JS code:
$('#exportToExcel').click(function(){
window.location = '/yourController/admin?' + $(this).parents('form').serialize() + '&export=true';
return false;
});
Now, maybe I misunderstood, but I thought you wanted to place the Export button elsewhere, and filter using the grid’s filter fields, not the search form. Am I right?
In that case, the parent form doesn’t technically exist, unless you extend the search form to wrap the grid… Well, anyway, using the standard CRUD, it is not wrapping it. So we’re directly targeting the filter fields, which can be inputs (text / radio / checkbox) or selects, in the header (a “tr” row of class “filters”) of the grid, which is a “table” in fact of “items” class.
$('table.items tr.filters input, table.items tr.filters select').serialize()
Well to see what I mean, just inspect a quite standard "admin" output on Yii Playground
I saw the issue on gh. Will look into it!
Can you post the url of the failing page? You can DM if you prefer.
Bennouna
Hi All,
i just want to share the problem and the solution to solve it. i ran to an issue (that i’ve shared it to bennouna through Private Message) that i can’t export to excel on the Shared Hosting even though all is running well on my local machine. i always get the “Page Not Found” that thrown by the browser.
so. firstly i assume, it should be cause by this lovely extensions (that is why i ask bennouna intensively), but later on, i found that this kind of issue is nothing to do with the tlbexcelview. after do some research, i found that this is issue ‘most likely’ found at the Shared Hosting using *nix system (My shared hosting using a CentOS though), the root of all the trouble is on the phpexcel/Classes/PHPExcel/Shared/File.php on the sys_get_temp_dir() function to be precise.
the function realpath() is broken in my case, if you take a look on the realpath($pFilename) function there’s logic to determine “the path” and for some reasons it can’t work on my shared hosting. so i found another solutions and i think it should be more safe to do.
just change the sys_get_temp_dir() function to something like this :
if (self::$_useUploadTempDirectory) {
// use upload-directory when defined to allow running on environments having very restricted
// open_basedir configs
//use this instead
return ini_get('upload_tmp_dir');
}
and voila, it works like a charm on my shared host
i hope it’ll help others that get the similar issue to me.
for bennouna : thanks for the all answers that you gave to me mate, and the last thing is any update on my inquiry on github repo (enhancment to add some title before render the header)?
Regards,
Rangganovsky
Hello Rangganovsky,
I’ve been very busy lately but it’s really in my task list, and as I told you it’s doable, and an interesting feature indeed.
In the meantime, don’t hesitate to submit a pull request if you feel like it!
Cheers
Bennouna
Still can’t get working with PDF. All other options are working fine. Can you please explain the exact steps to be followed to download as pdf
error:Alias "protected.components.widgets.tlbExcelView" is invalid. Make sure it points to an existing directory or file.
Followed the same procedure but getting an error.i downloaded tlbexcelview file and placed it in protected/components/widgets folder but getting the error.Not able to identify what is wrong.
Please help me as soon as possible…
Hi folks.
Please post your codes (controller and view) when you report a problem.
Thanks!
Sample admin view update in the extension page
Hello all,
The urlFormat property is left to ‘get’ by several members, so I thought the sample admin view code should reflect that.
I updated the PHP code that outputs the JS script, which listens to the grid export requests (Export button clicks) : the PHP code now checks the urlFormat’s property value in order to correctly construct the url passed to the JS script.
Hope that makes things clearer.
Hi, thank you for the great extension.
Is it possible to have only the "Export" button in admin view?
Because for me, in the admin view I can see both widgets (cgridview and tlbexcelview)…