Update Excel Cell Value to "2009.03" but it become "2009.3"

Discussion in 'C#' started by pankaj.calm, Mar 3, 2010.

  1. pankaj.calm

    pankaj.calm New Member

    Mar 3, 2010
    Likes Received:
    Trophy Points:

    I am updating a Excel Worksheet cell value to 2009.03 and it become change to 2009.3.

    I tried may ways to solve the issue but value always changed to "2009.3" instead of "2009.03" on Server. It is working on my system but not on Win XP 2003 Server System.

    I used to set excel cell NumberFormat to "@", "0.00", "####.##"
    and even tried to concatenated "'" before value but result not come.
    The excel file is of 2007 format(.xlsx).
    <u>>My Code is</u>
    Microsoft.Office.Interop.Excel.Workbook WorkBook = null;
    Microsoft.Office.Interop.Excel.Worksheet Sheet = null;
    WorkBook = Utility.GetWorkbook2007(templateFileWPath);
    Sheet = (Microsoft.Office.Interop.Excel.Worksheet)WorkBook.Worksheets[1];
    Microsoft.Office.Interop.Excel.Range TPCellRange = (Microsoft.Office.Interop.Excel.Range)Sheet.Cells[this.GetRowIndex(Sheet, this.CellAddress), this.GetColumnIndex(Sheet, this.CellAddress)];

    or also tried
    CellValueRange.NumberFormat = "@";
    CellValueRange.set_Value(Microsoft.Office.Interop.Excel.XlRangeValueDataType.xlRangeValueDefault, "2009.03");

    plz reply me if any solution is possible

    Thanks @ regards

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice