In Excel, if the content of a cell is a number and is long, by default, it becomes a scientific count, for example: 123456789123456000 is represented as 1.2345E+17, in order to be able to fully represent the number in a normal format, You need to set the cell's properties, and here's the example code:
Excel.Application m_objexcel = null;
Excel._workbook m_objbook = null;
Excel.Sheets m_objsheets = null;
Excel._worksheet m_objsheet = null;
Excel.Range m_objrange = null;
Object m_objopt = System.Reflection.Missing.Value;
Try
{
M_objexcel = new Excel.Application ();
M_objbook = M_objExcel.Workbooks.Open ("E:\\1.xls", m_objopt , m_objopt, m_objopt,
m_objopt, m_objopt, m_objopt, m_objopt, m_objopt, m_objopt, m_objopt,
m_objopt, m_objOpt, m_ Objopt, m_objopt);
M_objsheets = (excel.sheets) m_objbook.worksheets;
M_objsheet = (excel._worksheet) (M_objsheets.get_item (1));
M_objrange = M_objsheet.get_range ("A1", m_objopt);
m_objrange.numberformatlocal = "#";
m_objBook.SaveAs ("E:\\22.xls", m_objopt, m_objopt,
m_objopt, m_objopt, m_objopt, Excel.XlSaveAsAccessMode.xlNoChange,
m_objopt, m_objopt, m_objopt, m_objopt, m_objopt);
}
catch (Exception ex)
{
MessageBox.Show (ex. message);
}
finally
{
M_objbook.close (m_objopt, m_objopt, m_objopt);
M_objExcel.Workbooks.Close ();
M_objexcel.quit ();
System.Runtime.InteropServices.Marshal.ReleaseComObject (m_objbook);
System.Runtime.InteropServices.Marshal.ReleaseComObject (m_objexcel);
M_objbook = null;
M_objexcel = null;
GC. Collect ();
}