jQWidgets Forums
jQuery UI Widgets › Forums › Grid › Export into excel file from grid
Tagged: datagrid localization, export excel, grid, localization
This topic contains 24 replies, has 6 voices, and was last updated by Peter Stoev 9 years, 8 months ago.
-
Author
-
Hi Neelam,
I’m afraid that I’m not sure what may be the cause for the behavior you have described. Therefore, providing a small sample in which this can be observed locally will be appreciated. Please, send the sample to support@jqwidgets.com. Thank you in advance!
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi!
I have implemented the export data function of grid to excel file.
the grid shows correct data but when i export data to excel file,all data fields are not exported correctly and some fields have data like this “1/1/1970”.
i dont know why excel shows this data(date) instead of original that has to export.Hi mudessar_se,
Looks like you missed to set the type of your datafields in the definition of the Grid’s source object.
Example:
var source = { datatype: "xml", datafields: [ { name: 'ShippedDate', map: 'm\\:properties>d\\:ShippedDate', type: 'date' }, { name: 'Freight', map: 'm\\:properties>d\\:Freight', type: 'float' }, { name: 'ShipName', map: 'm\\:properties>d\\:ShipName' }, { name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress' }, { name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity' }, { name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry' } ], root: "entry", record: "content", id: 'm\\:properties>d\\:OrderID', url: url, pager: function (pagenum, pagesize, oldpagenum) { // callback called when a page or page size is changed. } };
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comThanks for such a quick reply.
it works and saves my lot of time.master, please help me to fix it. why the export file cant work when i click doenload button?
my grid view :
<link rel="stylesheet" href="config->item(‘base_url’); ?>/plugins/jqwidgets/styles/jqx.simple.css” type=”text/css” /><script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxdata.export.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.export.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxscrollbar.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.selection.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.columnsresize.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxdata.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.grouping.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.pager.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxpanel.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxlistbox.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxdropdownlist.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.sort.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.filter.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxcore.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxbuttons.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxmenu.js”>$(document).ready(function () {
var theme = ;
var url = “”;
// prepare the data
var source =
{
datatype: “json”,
datafields: [],
id: ‘id’,
url: url,
$v) {
if(!$first) echo “,”;
$first = false;
echo $k.”:'”.$v.”‘”;
}
echo “},”;
}
?>
root: ‘data’
};
var dataAdapter = new $.jqx.dataAdapter(source);
$(“#”).jqxGrid(
{sortable: true,
filterable: ,
columnsmenu: ,
source: dataAdapter,
theme: theme,
columnsresize: true,groupable: ,
columns: []
});$(“#excelExport”).jqxButton({ theme: theme });
$(“#excelExport”).click(function () {
$(“#datagrid”).jqxGrid(‘exportdata’, ‘xls’, ‘datagrid’);
});});
<?php if (isset($caption)) {
$w = isset($width)?"style='width:".$width.";'":"";
echo "“.$caption.”“;
}?>
<div id="”><?php
if ( ! empty($link))
{
echo '’;
foreach($link as $links)
{
echo $links . ‘ ‘;
}
echo ”;
}
?><link rel="stylesheet" href="config->item(‘base_url’); ?>/plugins/jqwidgets/styles/jqx.simple.css” type=”text/css” /><script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxdata.export.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.export.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxscrollbar.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.selection.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.columnsresize.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxdata.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.grouping.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.pager.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxpanel.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxlistbox.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxdropdownlist.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.sort.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxgrid.filter.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxcore.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxbuttons.js”>
<script type="text/javascript" src="config->item(‘base_url’); ?>/plugins/jqwidgets/jqxmenu.js”>$(document).ready(function () {
var theme = ;
var url = “”;
// prepare the data
var source =
{
datatype: “json”,
datafields: [],
id: ‘id’,
url: url,
$v) {
if(!$first) echo “,”;
$first = false;
echo $k.”:'”.$v.”‘”;
}
echo “},”;
}
?>
root: ‘data’
};
var dataAdapter = new $.jqx.dataAdapter(source);
$(“#”).jqxGrid(
{sortable: true,
filterable: ,
columnsmenu: ,
source: dataAdapter,
theme: theme,
columnsresize: true,groupable: ,
columns: []
});$(“#excelExport”).jqxButton({ theme: theme });
$(“#excelExport”).click(function () {
$(“#datagrid”).jqxGrid(‘exportdata’, ‘xls’, ‘datagrid’);
});});
<?php if (isset($caption)) {
$w = isset($width)?"style='width:".$width.";'":"";
echo "“.$caption.”“;
}?>
<div id="”><?php
if ( ! empty($link))
{
echo '’;
foreach($link as $links)
{
echo $links . ‘ ‘;
}
echo ”;
}
?>Hi fahriamirullah,
Unfortunately, we don’t have an idea why your browser’s download button does not work. May be the data you export is still downloading. In addition, the export file’s size is limited to ~8MB as the server script is hosted on http://www.jqwidgets.com.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.comHi,
I’m using JQGride(jquery 1.9.1) in my application, I want to add export to Excel functionality to my grid,
As I see from your article in “http://www.jqwidgets.com/jquery-grid-export-to-excel/” it can be done only in the server side
by using “jqxGrid”, I want to ask how can I implement this in my grid? I’m using this syntax when trigger something in the grid:
$(‘#ddTNGrid’).jqGrid(‘setGridParam’, { data: gridData }).trigger(“reloadGrid”);grid definition:
caption: “”,
gridId:”ddTNGrid”,
colNames: [‘Please Select’, ‘TN’,”],
colModel: [
{name: ‘id’, index: ‘id’, align: ‘center’, hidden: true},
{name: ‘tn’, index: ‘tn’, align: ‘center’, sortable: true},
{name: ‘view’, index: ‘view’ ,formatter: this._viewTNList, align: ‘center’}
],
multiselect: options.multiselect,
cellEdit: false,Thanks in advance
Peter,
Regarding your last response to this issue, do this approach works as well with the NETExport solution? (Meaning that I have to host the Default.aspx file on my server)
I tried to implement the code from Default.aspx into my code to call it using ajax and it worked for IE but didn’t on FF.
My web app uses Net 4.5 and I’m using the Dev licenseAny thoughts?
Hi mfernandez,
My last response which is from Oct 2012 is about the user’s download button. With a license, you will find tutorial which describes how to export in .NET.
Best Regards,
Peter StoevjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.