<html> <head> <style media=print mce_bogus="1"> .Noprint{display:none;} .PageNext{page-break-after:always;} </style> </head> <script language="javascript" type="text/javascript"> Ext.onReady(function(){ var data=[ [1, 'EasyJWeb', 'EasyJF','rokr.javaeye.com'], [2, 'rokr', 'rokr','rokr.javaeye.com'], [3, 'rokr', 'rokr','rokr.javaeye.com'], [4, 'rokr', 'rokr','rokr.javaeye.com'] ]; var sm=new Ext.grid.CheckboxSelectionModel(); var store=new Ext.data.SimpleStore({data:data,fields:["id","name","rokr","rokr"]}); var grid = new Ext.grid.GridPanel({ renderTo:"hello", title:"rokr.javaeye.com", height:150, width:600, columns:[sm,{header:" Project name ",dataIndex:"name"}, {header:" The development team ",dataIndex:"organization"}, {header:" Web site ",dataIndex:"homepage"}], sm:sm, store:store, autoExpandColumn:2 }); }); </script> <body > <br /> <div></div> <br/><br> <div ></div> <br><br> <span> <input type="button" value=" Export Excel"> <input type="button" value=" Export Word"> <input type=button value= Print page setup ' button "value =" print preview "> <OBJECT classid=CLSID:8856F961-340A-11D0-A96B-00C04FD705A2 height=0"file" name="file"/> <input type="button" name="excelimport" value="Excel Import " /> </span> </div> <script language="javascript" type="text/javascript"> function readExcel() { if(document.getElementById("file").value.split(".")[1]=="xls"){ var oXL = new ActiveXObject("Excel.Application"); try{ var oWB = oXL.Workbooks.open(document.getElementById("file").value); }catch(e){ alert(' Open a file failed !'); } var oSheet = oWB.ActiveSheet; var table=document.createElement("table"); table.setAttribute("border","1"); table.setAttribute("cellpadding","0"); table.setAttribute("cellspacing","0"); table.setAttribute("border-collapse","collapse"); table.setAttribute("width","60%"); //table.setAttribute("style-fontSize","12"); table.setAttribute("id","mytable"); document.body.appendChild(table); for(var i=0;i<oSheet.usedrange.rows.count;i++){ var row=table.insertRow(i); for(var j=0;j<(oSheet.usedrange.cells.count/oSheet.usedrange.rows.count);j++){ //oSheet.Cells(i,j).Font.Size = 10; //alert(oSheet.Cells(i+1,j+1).value); if(oSheet.Cells(i+1,j+1).value==null){ row.insertCell(j).appendChild(document.createTextNode("")); } else{ row.insertCell(j).appendChild(document.createTextNode(oSheet.Cells(i+1,j+1).value)); } } } var div=document.getElementById("newTable"); div.appendChild(table); //alert(oSheet.Rows.rows); // alert(oSheet.Cells(1,1).value);//cell The value of the // alert(oSheet.usedrange.cells.count);//cell The value of the // alert(oSheet.usedrange.rows.count);// Use the number of rows // alert(oWB.Worksheets.count);// Get the number of the sheet oSheet=null; oWB.close(); oXL=null; }else{ if(document.getElementById("file").value==""){ window.alert(" Please select the Excel file "); return false; }else{ window.alert(" You select the Excel file is not "); return false; } } } // Import Excel function AllAreaExcel() { // Create the Excel formatting objects var oXL = new ActiveXObject("Excel.Application"); //var oXL = createOXL(); // Get the workbook object var oWB = oXL.Workbooks.Add(); // Activate current sheet var oSheet = oWB.ActiveSheet; //oSheet.Cells(1,1).Font.Size = 30; var sel=document.body.createTextRange(); // To move the contents of the table to the TextRange in sel.moveToElementText(hello); // Select all the contents in the TextRange sel.select(); // Copy the contents in the TextRange sel.execCommand("Copy"); // Paste into the activities of Excel oSheet.Paste(); // Set the excel visible property oXL.Visible = true; //oXL.Quit(); } // Export word function OpenWord(){ var ExcelSheet = new ActiveXObject('word.Application'); // Make Excel through Application Object visibility . ExcelSheet.Application.Visible = true; var orgNum=ExcelSheet.Documents.Add("",0,1); var myRange =orgNum.Range(0,1) var sel=document.body.createTextRange(); var oTblExport =document.getElementById("hello"); if (oTblExport != null) { sel.moveToElementText(oTblExport); sel.execCommand('Copy'); document.body.blur(); myRange.Paste(); } //window.close(); //ExcelSheet.Application.Quit(); } </script> </body> </html>