This is a migrated thread and some comments may be shown as answers.

How to format column in export to excel

3 Answers 156 Views
GridView
This is a migrated thread and some comments may be shown as answers.
hvduc
Top achievements
Rank 1
hvduc asked on 20 May 2011, 08:31 AM
I'm implementing export to excel by using RadGridView's export function.
If type of my data is string and its value is "0123", when exported to excel, it automatically change to number 123.
How can I format column in excel file to keep value from changing like that?

3 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 20 May 2011, 11:03 AM
Hello hvduc,

I presume you are exporting your data in html format. When exporting to html cells in the spreadsheet use the default cell format that corresponds to this input. For example, if you open an Excel spreadsheet and write "0123" in a cell, it will display "123" after editing is finished. If you check its format you will see that it is set to General. Changing cell's format to Text and writing editing it by inserting "0123" will  display "0123". But on the other hand, if you utilize ExcelML format, the value types will be respected. For instance, a "0123" cell in the RadGridView will be exported as:
<Cell  ss:Index="1"><Data ss:Type="String">0123</Data></Cell>
You may notice that data type is specified. So use ExcelML instead.  Please, let me know if this approach meets your requirements.

All the best,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
hvduc
Top achievements
Rank 1
answered on 23 May 2011, 09:14 AM
I tried your solution and it works great. Thank for your quick reply
But I met problem with excelML. after export to excelml, I want to import it and have a hard time with querying content in excelML file to update to database.
I tried query like xml but it don't work. Can you help me?
0
Ivan Ivanov
Telerik team
answered on 25 May 2011, 07:51 AM
Hi hvduc,

Unfortunately this is an issue related rather to the framework itself than to our controls, so it is out of our support scope. But since it sounds like a common one, I believe that there would be a lot of solutions around the Internet.

Greetings,
Ivan Ivanov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
hvduc
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
hvduc
Top achievements
Rank 1
Share this question
or