Note that there are some explanatory texts on larger screens.

plurals
  1. POC# Excel.Application - Issue with text field converted to Scientific notation
    primarykey
    data
    text
    <p>I have follwing C# code which opens that tab delimited .txt file and does the saveas to Excel file. Problem what I am running into is some of the text field has value such as "9101010521297461515213" is getting converted to "9.10101E+21". How do I prevent getting converted to scientific notation and leave as text instead using below function ?</p> <pre><code>public void SaveTextFileAsExcel(string filefrompath, string filetopath, string newtabname) { // Excel object references. Excel.Application m_objExcel = new Excel.Application(); Excel.Workbooks m_objBooks = (Excel.Workbooks)m_objExcel.Workbooks; Excel._Workbook m_objBook = null; Excel.Sheets m_objSheets = null; Excel._Worksheet m_objSheet = null; // Frequenty-used variable for optional arguments. object m_objOpt = System.Reflection.Missing.Value; if (filefrompath != "") { m_objBooks.OpenText(filefrompath, Excel.XlPlatform.xlWindows,1, Excel.XlTextParsingType.xlDelimited, Excel.XlTextQualifier.xlTextQualifierDoubleQuote, false, true, false, false, false, false,m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt); m_objBook = m_objExcel.ActiveWorkbook; m_objSheets = m_objBook.Worksheets; m_objSheet = (Excel.Worksheet)m_objSheets.get_Item(1);//Get the reference of second worksheet string strWorksheetName = m_objSheet.Name;//Get the name of worksheet. if (newtabname != "") { m_objSheet.Name = newtabname; } if (filetopath !="") { // Save the text file in the typical workbook format and quit Excel. m_objBook.SaveAs(filetopath, Excel.XlFileFormat.xlWorkbookNormal, m_objOpt, m_objOpt, m_objOpt, m_objOpt, Excel.XlSaveAsAccessMode.xlNoChange, m_objOpt, m_objOpt, m_objOpt, m_objOpt, m_objOpt); } //if (filetopath !="") } //if (filefrompath != "") m_objBook.Close(false, m_objOpt, m_objOpt); m_objExcel.Quit(); } //SaveAsExcel </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload