We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Formatting date format to text(string) format

i am getting date format into dataset. when i am using excel.ImportDataTable that date format is comming to that hole column values. but i want that (total column values) to be string.

how to do that t string format from date format


Could you give us details, which overloaded version of Cells.ImportDataTable() method you are using. Do you use Cells.ImportDataTable( dataTable, isFieldNameShown, firstRow, firstColumn, rowNumber, columnNumber, insertRows,
dateFormatString ). And when you convert a datatime format to string, the datetime values would be converted to numeric values e.g., for datetime....4/2/2008, when you convert it to text, it will be 39540 numeric value.

You can format a complete column for your desired formattings after you have imported data. You may achieve in the way as follows:

Workbook wb = new Workbook();

Worksheet sheet = wb.Worksheets[0];


Style style;
StyleFlag flag;
style = wb.Styles[wb.Styles.Add()];
style.Custom = ......;
flag = new StyleFlag();
flag.NumberFormat = true;
//Apply style to the 5th column.
sheet.Cells.ApplyColumnStyle(4,style, flag);

Thank you.