Home > front end >  ActiveXObject export to excel at how to specify the cell format
ActiveXObject export to excel at how to specify the cell format

Time:10-07

Ie browser to export the HTML form data to excel, for some long as digital, import excel, digital into scientific notation, data table is more complex, so with the copy is as follows:
The content of the HTML table:


Results: after the export
5.82201582202582 e+23 lead to inconsistent data

Js code:
Var curTbl=document. GetElementById (tableid);
Var oXL=new ActiveXObject (" Excel. Application ");//create the AX object excel
Var oWB=oXL. Workbooks. The Add ();
Var xlsheet=oWB. Worksheets (1);
Var sel=document. Body. CreateTextRange ();
Sel. MoveToElementText (curTbl);
//sel. The collapse (true);
//sel. The select ();
Sel. Select;
Sel. ExecCommand (" Copy ");
Sel. Columns. Nu
Xlsheet. Paste ();
OXL. Visible=true;

Try {
Var fname=oXL. Application. GetSaveAsFilename (" data detail. XLS ", "Excel Spreadsheets (*. XLS), *. XLS");
} the catch (e) {
The console. The log (" Nested catch caught "+ e);
} the finally {
OWB. SaveAs (fname);
OWB. Close (savechanges=false);
OXL. Quit ();
OXL=null;
IdTmr=window. SetInterval (" the Cleanup ();" , 1);
}


The Internet is so set in a different way, but my form merge listed each is different, can't read the way to set the: oSheet. Cells (I + 1, j + 1) NumberFormatLocal="@";

Look at what a great god guide how to setup the text,,

CodePudding user response:

Or support ie 10, 11 export HTML table form to Excel in other ways
  • Related