Is it possible to ensure all cell values are in String format, representing exactly how they are in a CSV file?
11 Answers, 1 is accepted
Thank you for contacting us!
Unfortunately, my attempts to replicate the issue you describe were not successful. Could you please try to import your file in our click-once examples and see if you reproduce the issue there? Also, please verify Q3 2013 (2013.3 1016) is the version of RadControls for WPF you are using.
In order to analyze the roots of the problem we would need to replicate it on our side. For this reason if the issue persists please send us your project. Once we are able to reproduce the behavior locally, we will do our best to assist you further.
We are looking forward to hearing from you again!
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
I have exactly the same problem as reported by Ed James, except in Silverlight.
var cell = ws.Cells[row, c]; // ws is Worksheet
var val = cell.GetValue();
var v = val.Value.RawValue; // v is now some strange number instead of for instance: 1.1.2014 - what is a value from excel's cell
Could you please do something with that?
The date values are stored in the Worksheet as number values with specific number format. This is the reason why when you get the value of the cell the result is number. If you want to get the formatted result, you could use the following code snippet:
CellSelection cellSelection =
ICellValue value = cellSelection.GetValue().Value;
CellValueFormat format = cellSelection.GetFormat().Value;
CellValueFormatResult formatResult = format.GetFormatResult(value);
result = formatResult.InfosText;
Thank you, great, this works nicely!
Hi, im using XlsxFormatProvider and CsvFormatProvider to import file into a Workbook. My date format are good when i use an XLSX file (they keep the cell format). But when i import a CSV file, i would like to keep the original format.For example, if i have a CSV:
I would like that telerik import all the date without changing the format. Is it possible ? Because now, it all change them to 2017-01-31.
Saving spreadsheet data to CSV file ensures preserving only the cell values and all information from other cell formatting features is lost. If you require preserving the date format you should either use XLSX file format or implement custom logic that sets CellValueFormat to specific cells right after the CSV import as mentioned in previous answer by Nikolay Demirev.
Telerik by Progress
I have the same issue for Date cell in Telerik Web Workbook.
can you please suggest how can I do that for Web workbook cell.
May I ask you to provide a bit more details about the scenario in which you use the Telerik.Web.Spreadsheet.dll? Do you have it in ASP.NET Web Forms application with RadSpreadsheet, or you use it in an ASP.NET MVC application? Also, please explain a bit more in detail the actual use case in which you observe this issue.
Telerik by Progress
I am using Telerik.Web.Spreadsheet.dll with ASP.NET MVC application. I used it to import CSV or TXT file. I am transferring data from Imported file to DataTable, so while retrieving data through worksheet I got (22532) such value from a cell for Date Field and Now I want to convert it to DateFormat and set it to the DataTable.
Thank you for the additional information provided.
In order to retrieve the correct date, you will need to convert the OLE Date format to DateTime object:
var cell = workbook.Sheets.Rows.Cells;
var value = Double.Parse(cell.Value.ToString());
var date = DateTime.FromOADate(value);
Telerik by Progress
I have just tested importing the attached CSV file containing dates in the format "MM/DD/YYYY" while my OS has the same setting for date format, and the RadSpreadsheet shows the values as dates which are also formatted as dated. Could you try it on your end and share the result?