We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Export to Excel from GDBG, problem with date types...

Thread ID:

Created:

Updated:

Platform:

Replies:

67847 Aug 31,2007 07:39 PM UTC Sep 3,2007 11:29 PM UTC Windows Forms 4
loading
Tags: GridControl
Pratima
Asked On August 31, 2007 07:39 PM UTC

Hi,
I am using GDBG version 4.4.xxx
One of my columns in the grid is of type Date

I am exporting the rows from the grid to excel using GridExcelConvertorControl

GridDataBoundGrid exportGrid = new GridDataBoundGrid();
exportGrid.DataSource = dt //my data table;


GridExcelConverterControl gecc = new GridExcelConverterControl();
gecc.GridToExcel(exportGrid.Model, sFileName, ConverterOptions.RowHeaders | ConverterOptions.Visible);

For most part it works ok. However the Date type is getting exported into some numbers.

Looks like the Excel column format that is suppose to show date is not getting set correctly.

Is there a way programattically, such that I can specify the format for each cell programatically prior to export?

J.Nagarajan [Syncfusion]
Replied On September 1, 2007 01:34 AM UTC

Hi Pratima,

If you set the GridStyleInfo.StyleInfo.Format property for your DateTime column, then the export should work ok. Here is the sample we ship created to show this idea.

http://www.syncfusion.com/Support/user/uploads/GDBGExport_2b9d6b4f.zip

Let us know if this is not what you wanted.

Regards,
Nagaraj

Pratima
Replied On September 1, 2007 02:55 AM UTC

My Grid's datasource is a SQL DataTable which already has the field of type DateTime

Which means grid is automatically creating a column of type DateTime isn't it?

Do I need to explicitly reset the exact same format again?

Thanks,
Pratima

Pratima
Replied On September 1, 2007 03:11 AM UTC

OK, so looks like the problem is how I set the format.

For example.

1) If I set the format = "mm/dd/yyyy"

Grid displays it properly
Exported file shows it properly

2) If I set the format = "d" ( which is syncfusion's format for short date )

Grid Displays it properly
Exported file DOES NOT show it correctly. I see the 39325.80 in the excel spreadsheet

Looks like a bug in Grid convertor which doesn't recognize the coded format from GDBG



Rajagopal [Syncfusion]
Replied On September 3, 2007 11:29 PM UTC

Hi Pratima,

Thanks for your patience.

We are not able to see this issue in the latest version 5.1.x.x. This has been internally fixed in the latest version of Essential Studio 5.1.

As a workaround, you can handle the QueryCellInfo event and apply the FormattedText to the datetime cells in grid. Please refer the below sample that shows this working fine.

http://www.syncfusion.com/Support/user/uploads/GDBG_ExcelExport_6d5da8a4.zip

Let me know if you have any other questions.

Have a nice time.
Regards,
Rajagopal

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;