Sign In  Sign Up Live-Chat

formatting date format to text(string) format

Last post 07-03-2008, 9:39 AM by Amjad Sahi. 1 replies.
Sort Posts: Previous Next
  •  07-03-2008, 8:17 AM 134188

    formatting date format to text(string) format

    hi,
    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
     
  •  07-03-2008, 9:39 AM 134194 in reply to 134188

    Re: formatting date format to text(string) format

    Hi,

    Could you give us details, which overloaded version of Cells.ImportDataTable() method you are using. Do you use Cells.ImportDataTable( dataTableisFieldNameShown,  firstRow,  firstColumnrowNumbercolumnNumberinsertRows,
      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();

    wb.Open(filepath);
    Worksheet sheet = wb.Worksheets[0];
    sheet.Cells.ImportDataTable(..............);

    ..........

    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);
    wb.Save("d:\\test\\style_column.xls");

     

    Thank you.


    Amjad Sahi
    Support Developer,
    Aspose Nanjing Team
    Contact Us
     
View as RSS news feed in XML