Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

Datetimes download to ooxml use server's timzezone, not the browser's

$
0
0
I am running "SmartClient Version: v9.1p_2014-03-10/PowerEdition Deployment (built 2014-03-10)" and accessing via Chrome 37.0.2062.120

I am having an issue when exporting data to a spreadsheet (ooxml). My server is in a different timezone, and while the UI displays the data in the timezone of the browser, the export to spreadsheet translates the dates into the timezone of the server. When opened, on the same machine as the browser, the times are exactly an hour earlier than they appear in the UI.
e.g.
UI: Partern1 09/08/2014 15:28
Excel Partner1 2014-09-08 14:28:26

The export samples provided on smartclient.com do not export with times, and provided no guidance for this issue.

The initial solution was to modify the dataSource to have a string version of the dates that gets created using the timezone passed from the browser. This fixes the display, but removes the datatype of the fields and with it the ability to treat the dates as anything other than random strings. Excel ignores any attempt to format the columns as a datetime using either the date time formatting or a custom format.

To make this work as the customer wants it, I need real times exported with the correct timezone.

I found an old (2006) post in the forums that referenced using isc.Time.setDefaultDisplayTimezone() in conjunction with this issue. I tried using it, but it made no difference.

Is there something I can do to get the export to use the browser's timezone when creating the excel sheet?

code:======================================

this.workflowAssignments = isc.TreeGrid.create({
ID: "workflowCompletedTree_workflowAssignments",
dataSource: "workflowDS",
width: 1238,
showRecordComponents: true,
showRecordComponentsByCell: true,
alternateRecordStyles: true,
emptyMessage: "Empty.",
showFilterEditor: true,
showAllRecords: true,
autoFetchData: false,
filterEditorSubmit: function(criteria) {
criteria.fetchType = "byTask";
workflowCompletedTree_workflowAssignments.invalidateCache();
criteria.customerGroup = workflowCompletedTree_queryForm.getField("customerGroup").getValue();
criteria.timezone = jstz.determine().name();
return true;
},
fields: [{name: "PartnerName", title: "partner", width: 80, canEdit: false, canFilter: true,
filterEditorProperties: {
optionDataSource: "BusinessPartnerDS",
displayField: "name",
valueField: "id"
},
},
{name: "dateReceived", title: "date received", width: 90, canEdit: false, canFilter: true, type: "datetime",
filterEditorProperties: {
allowRelativeDates: false
}
}
],

});
var exportFullBtn = isc.Button.create({
ID: "workflowCompletedTree_exportAllMappingsButton",
title: "export all",
width: 130,
click: function() {
// isc.Time.setDefaultDisplayTimezone(jstz.determine().name());
// isc.Time.setDefaultDisplayTimezone("-04:00");
// isc.Time.setDefaultDisplayTimezone("-4:00");
workflowCompletedTree_workflowAssignments.exportData({ exportAs: "ooxml",
exportFields: ["PartnerName", "dateReceived"],
exportDisplay: "download", exportDatesAsFormattedString: false, exportFilename: "allResults.xlsx"
});
}
});



<DataSource
ID="workflowDS"
serverType="generic"
>
<fields>
<field name="id" title="id" type="text" hidden="true" primaryKey="true" />
<field name="PartnerName" title="business partner" type="text" />
<field name="dateReceived" title="date received" type="datetime" />
<field name="dateReceivedString" title="date received" type="text" />
...
</fields>
<serverObject ID="workflowHandler" lookupStyle="new" className="com.nofone.mm.dmi.WorkflowDMI"/>
</DataSource>

Viewing all articles
Browse latest Browse all 4756

Trending Articles