Go4Expert (http://www.go4expert.com/)
-   C# (http://www.go4expert.com/forums/c-sharp/)
-   -   Update Excel Cell Value to "2009.03" but it become "2009.3" (http://www.go4expert.com/forums/update-excel-cell-value-200903-20093-t21186/)

pankaj.calm 3Mar2010 14:49

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

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)];
TPCellRange.set_Value(Microsoft.Office.Interop.Exc el.XlRangeValueDataType.xlRangeValueDefault,"2009. 03");

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

All times are GMT +5.5. The time now is 09:17.