excel - Missing value when export listview to xls file in c# -


the problem can export listview excel file successfully, when try open it. said can read only. , value in file change '0'

example:

10379743021704072015 -> 10379743021704000000

10379743021704072015 -> 1.0379743021704e+019

note: use microsoft excel 2016 open it.

using (savefiledialog sfd = new savefiledialog() { filter = "excel  workbook|*.xlsx", validatenames = true })                 {                     if (sfd.showdialog() == dialogresult.ok)                     {                         microsoft.office.interop.excel.application app = new microsoft.office.interop.excel.application();                     workbook wb =  app.workbooks.add(xlsheettype.xlworksheet);                     worksheet ws = (worksheet)app.activesheet;                     app.visible = false;                      ws.cells[1, 1] = "date";                     ws.cells[1, 2] = "time";                     ws.cells[1, 3] = "harness";                     ws.cells[1, 4] = "modulehtr";                     ws.cells[1, 5] = "mainip";                     ws.cells[1, 6] = "antenna";                     ws.cells[1, 7] = "airbag";                     ws.cells[1, 8] = "screw torque 1";                     ws.cells[1, 9] = "screw torque 2";                     ws.cells[1, 10] = "screw torque 3";                     ws.cells[1, 11] = "scan switch";                     ws.cells[1, 12] = "cluster";                     ws.cells[1, 13] = "e-test airbag";                     ws.cells[1, 14] = "e-test cluster";                     ws.cells[1, 15] = "e-test column";                     ws.cells[1, 16] = "e-test sensor";                     ws.cells[1, 17] = "e-test result";                     ws.cells[1, 18] = "qc (ok or nok)";                     ws.cells[1, 19] = "serial number";                     int = 2;                     foreach (listviewitem item in listview1.items)                     {                         ws.cells[i, 1] = item.subitems[0].text;                         ws.cells[i, 2] = item.subitems[1].text;                         ws.cells[i, 3] = item.subitems[2].text;                         ws.cells[i, 4] = item.subitems[3].text;                         ws.cells[i, 5] = item.subitems[4].text;                         ws.cells[i, 6] = item.subitems[5].text;                         ws.cells[i, 7] = item.subitems[6].text;                         ws.cells[i, 8] = item.subitems[7].text;                         ws.cells[i, 9] = item.subitems[8].text;                         ws.cells[i, 10] = item.subitems[9].text;                         ws.cells[i, 11] = item.subitems[10].text;                         ws.cells[i, 12] = item.subitems[11].text;                         ws.cells[i, 13] = item.subitems[12].text;                         ws.cells[i, 14] = item.subitems[13].text;                         ws.cells[i, 15] = item.subitems[14].text;                         ws.cells[i, 16] = item.subitems[15].text;                         ws.cells[i, 17] = item.subitems[16].text;                         ws.cells[i, 18] = item.subitems[17].text;                         ws.cells[i, 19] = item.subitems[18].text;                          i++;                     }                     wb.saveas(sfd.filename, xlfileformat.xlworkbookdefault, type.missing, type.missing, true, false, xlsaveasaccessmode.xlnochange, xlsaveconflictresolution.xllocalsessionchanges, type.missing, type.missing);                     messagebox.show("exported");                 }             } 


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -