Adicione a página visitada ao site confiável
Copie o código do código da seguinte forma:
// exportar para o Excel, observe que não deve haver comentários na marca da tabela, porque os Childnodes contarão as anotações em
// Se houver um erro, você precisará fechar o Excel, caso contrário, o processo do Excel continuará sendo executado
// TD só pode ter um valor de entrada
// Não deve haver formação entre não -TD, caso contrário, o relatório está ausente ";
// Página de cotação Adicionar <script type = "text/javascript" src = "Execl.js"> </sCript>
// Botão Adicionar <input style = "altura: 26px" type = "button" name = "btnexcel" value = "export excel" onclick = "exportexcel (this, 'tablenr', '' '')";
// Defina o ID e a classe da tabela de tabela como tablenr
Função ExportExcel (BTN, Tabid, Strcols, Stitle, Sheader, Sfooter) {
// alert ('ssss');
btn.style.cursor = "wait";
event.returnValue = false;
//tentar{
var tab = document.getElementById (tabid);
// if (tab == null) guia = document.getElementById ("dg")
// if (tab == null) tab = document.getElementById ("db")
// if (tab == null) guia = document.getElementById (tabid)
if (tab == null) {
Alerta ("falta de objetos de tabela");
btn.style.cursor = "hand";
Retornar;
}
var t = tab.firstchild;
var linhas = t.childnodes.length;
// alertas (T.Nodename);
var tds = t.childnodes [0] .childnodes.length;
var cols = 0;
for (var i = 0; i <tds; i ++) {
var td = t.childnodes [0] .childnodes [i];
if (parseint (td.colspan)> 1) {
Cols += parseint (td.colspan);
}
outro {
Cols ++;
}
}
tentar {
var oxl = new ActiveXObject ("Excel.Application");
} catch (e) {
alerta ("Verifique se o Excel está instalado e permita que o Excel seja executado!");
Alert ("Não é possível começar o Excel, verifique se o Excel está instalado no seu computador!/N/n. Se o Excel já estiver instalado,"+", adicione o endereço IP ao site confiável e ajuste o nível de segurança do IE Site confiável. OK );
btn.style.cursor = "hand";
Retornar;
}
oxl.workbooks.add ();
var Lay = Oxl.ActiveWorkbook;
var osheets = obook.worksheets;
var heet = obook.Sheets (1);
var xlrow = 1;
// Adicione o título
if ((stiction == "") || (typeof (stital) == "indefinido") || (stital == null)) {
var t_tdheadc = document.getElementById ("tdheadc");
if (t_tdheadc! = null) {
Stitle = t_tdheadc.innerText;
var sk = stital.LastIndexOf ("->") +3;
stitle = stitle.substring (sk);
}
}
osheet.Cells (1, 1) = Stitle;
Osheet.Range (OSHEET.CELLS (XLROW, 1), OSHEET.CELLS (XLROW, cor)).
Oxl.Selection.horizontalignment = 3;
Oxl.Selection.MergeCells = True;
xlrow ++;
// Legenda
Ifader (Sheader == "") || (Typeof (Sheader) ==
Sheader = "" ;;
}
if (Sheader! = "") {{
osheet.Cells (2, 1) = Sheader;
Osheet.Range (OSHEET.CELLS (XLROW, 1), OSHEET.CELLS (XLROW, cor)).
//oxl.selection.horizontalallyign = 3;
Oxl.Selection.MergeCells = True;
xlrow ++;
}
var winx = (screen.width -300) / 2;
var winy = (Screen.Height - 120) / 2;
var win = window.open ("", "", "diretórios = 0, localização = 0, memubar = 0, scrollbars = 0, status = 0, barra de ferramentas = 0, largura = 230, altura = 75, esquerda =" + winx + ", top =" + vencedor);
win.document.write ('<html> <title>' + estitle + 'Exportar Excel </title> <body> <div id = "m_pub_wzs_progress_x" style = "Background: White; Overflow: Hidden; Padding-top: 0 Display: Nenhuma; Posição: Absoluto; Esquerda: 10px; Top: 25px; "> <tabela id =" m_pub_wzs_progress_tab "Border = 0 Cellpacing = 1 BGCOLOR ="#CCCCCC "style =" Display: Inline; Border-width: 1px ;
Win.document.write ('<trding = 17> <td width = 4 bgcolor = "#000088"> </td> <td width = 4 bgcolor = "#000088"> </td> <td width = 4 bgcolor = "#000088"> </td> <td width = 4 bgcolor = "#000088"> </td> <td width = 4 bgcolor = "#000088"> </td> <td width = 4 bgcolor = " #000088 "> </td> <td width = 4 bgcolor ="#000088 "> </td> <td width = 4 bgcolor ="#000088 "> </td> <td width = 4 bgcolor ="#00008888 "> </td> <td width = 4 bgcolor ="#000088 "> </td> <td width = 4 bgcolor ="#000088 "> </td> <td width = 4 bgcolor ="#000088 "> </td> <td width = 4 bgcolor = "#000088"> </td> <td width = 4 bgcolor = "#000088"> </td> <td width = 4 bgcolor = "#ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc Bds td> <td width = 4 bgcolor = "#cccccccc"> </td> <td width = 4 bgcolor = "#cccccc"> </td> <td width = 4 bgcolor = "#cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc Bds <td width = 4 bgcolor = "#cccccccc"> </td> <td width = 4 bgcolor = "#ccccccc"> </td> <td width = 4 bgcolor = "#ccccc"> </td> <t largura = 4 bgcolor = "#cccccccc"> </td> <td width = 4 bgcolor = "#cccccc"> </td> <td width = 4 bgcolor = "#ccccc"> </td> <td widthth = 4 bgcolor = "#ccccccc"> </td> <td width = 4 bgcolor = "#cccccc"> </td> <td width = 4 bgcolor = "#cccccc"> </td> <td width = 4 bgcolor = "#Cccccc"> </td> <td width = 4 bgcolor = "#cccccc"> </td> <td width = 4 bgcolor = "#cccccc"> </td> ');
Win.document.write ('</tr> </table> <br> <span id = "m_pub_wzs_progress_percent" style = "font-size: 10pt; vertical-align: middle; cor: preto; fon t-family: música: música estilo "> total ' + linhas +' linhas, exportado <font id =" sx "color ="#cc0000 "> </font> linhas! /> <r /> <script law = "javascript"> var osx = document.getElementById ("sx"); ; i ++) {var td = tr.Cells [i]; GetElementById ("m_pub_wzs_progress_x");
//win.document.write("<div style = 'font-size: 10pt; font-family: 安'> total " + linhas +", exportado <font id = 'sx' color = '#cc0000'> < /font> line!
//win.m_pub_wzs_progress_show (0, linhas);
strcols = ","+strcols+",";
var arowspans = new Array ();
for (var i = 0; i <cols; i ++) {
arowspans [i] = 1;
}
var isProgressor = false;
for (var i = 0; i <linhas; i ++) {
//btn.value = i;
if (! isprogressor) {
tentar {
win.m_pub_wzs_progress_show (linhas, i+1);
}
Catch (e) {
isProgressor = true;
}
}
var row = t.childnodes [i];
var xlcol = 0;
Var viwcol = -1;
var colorx = -1;
varpans var = 1;
for (var h = 0; h <cols; h ++) {
if (arowspans [h]> 1) {{
xlcol ++;
arowspans [h]-;
viwcol ++;
continuar;
}
outro {
COLINX ++;
}
var td = t.childnodes [i] .childnodes [colinx];
se (td == null) continuar;
colspans = td.colspan;
var lobspan = td.rowspan;
if (isnan (linhas)) linhas = 1;
for (var k = 0; k <td.colspan; k ++) {
viwcol ++;
xlcol ++;
Arowspans [viwcol] = lobmpan;
}
H+= td.colspan-;
If (td.className == "hidenode") {{
xlcol ---;
continuar;
}
var s = "";
If (td.haschildnodes () && td.firstchild.nodename.tologycase () == "input") {
if (td.firstchild.type.tologycase () == "text") {{
s = td.firstchild.value;
}
Caso contrário, if (td.firstchild.type.tologycase () == "radio") {// se for uma única caixa de seleção, atravessou toda a caixa de seleção única da caixa, encontre o valor selecionado
for (var k = 0; k <td.childnodes.length; k ++) {
var cn = td.childnodes [k];
if (cn.nodename.tolowerCase () == "input" && cn.type.tolowercase () == "Radio" && cn.checked) {
s = cn.Value;
Quebrar;
}
}
}
}
outro {
s = td.innerText;
}
if (strcols.indexOf ("," + (xlcol-1) + ",")! =-1) {
shell.cells (xlrow, xlcol) .NumberFormatLocal = '@';
}
if (td.rowspan> 1 || td.colspan> 1) {{
Shellheet.Range (Sheet.Cells (XLROW, XLCOL), Sheet.Cells (xlrow-1+td.rowspan, xlcol-td.colspan+1)). Select ();
Oxl.Selection.MergeCells = True;
heet.cells (xlrow, xlcol) .horizontalallyignment = 3;
//heet.cells (i +td.rowspan, xlcol-td.colspan +1).
Osheet.Cells (xlrow, xlcol-td.colspan+1).
} Outro {
Osheet.Cells (XLROW, XLCOL).
}
}
xlrow ++;
}
// Adicione a cauda
if ((sfooter == "") || (typeof (sfooter) == "subfinado") || (sfooter == null) {
sfooter = "";
}
var d = new Date ();
var subuse = "" ;;
if ((window.parent! = null) && (window.parent.parent! = null) {
tentar {
Suser = Window.parent.parent.bottomframe.document.getElementById ("Labuser").
}
captura (ex)
}
}
Var sfooterDefault = "Watchman:" + Suser + "Time Time:" + d.getlyear () + "-" + (d.getMound () + 1) + "-" + d.getdate () + "" " + d.Gethours () +":" +d.getminutes () +":" +d.getSeconds () +"";
heet.cells (xlrow, 1) = sfooterDefault + sfooter;
OSHEET.RANGE (OSHEET.CELLS (XLROW, 1), OSHEET.CELLS (XLROW, cor)).
Oxl.Selection.MergeCells = True;
Osheet.Range (OSHEET.CELLS (1, 1), OSHEET.CELLS (1,1).
heet.columns.autofit ();
for (var i = 1; i <xlrow; i ++) {
Osheet.Rows (i) .RowHeight = Osheet.Rows (i) .RowHeight + 6;
}
if (! isprogressor) {// fechar a barra de progresso
win.close ();
}
oxl.visible = true;
oxl.userControl = true;
oxl = nulo;
Obook = null;
osheets = null;
heet = null;
btn.style.cursor = "hand";
}