Click here to Skip to main content
15,897,187 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

Need help to solve one issue.
I am working on existing asp.net application where in I have to extract data from the table and stored in an excel.
This is done by putting the result into grid and then grid data is written to the excel.

We are getting data from dataset and adding to the grid like;

foreach (DataColumn cCol in dsReports.Tables[0].Columns)
{
	dgReport.Columns.Add(CreateBoundColumn(cCol));                            
}

private BoundColumn CreateBoundColumn(DataColumn dcol)
 {
            BoundColumn bcol = new BoundColumn(); 
            bcol.DataField = dcol.ColumnName;
            bcol.HeaderText = resource.GetString(dcol.ColumnName); 
            bcol.DataFormatString = "{0}";
              
            return bcol;
 }



But my one of the columns has values like:
1-4
5-10
11-20


Which are getting displayed as:
4-Jan
10-May
20-Nov


The text automatically converted into date format when extracted to excel.

Please help. Thanks in advance.

Regards,
Swati
Posted
Updated 4-Jun-14 0:05am
v2

1 solution

Add ' at the value beginning like

'1-4
'5-10
'11-20
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900