js format excel export control

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>js to excel</title>
<link href="css/style.css" rel="stylesheet" type="text/css">
<style type="text/css">
.tit{
	font-size:25px;
}
</style>
<script>
 function method1() {// Copy the entire table into Excel  
	// Retrieves the browser  
	if(navigator.userAgent.indexOf("MSIE")<0){
		alert(' Please use IE browser table export  ');
		return ;
	}

	var tableid="excel";
    var curTbl = document.getElementById(tableid); 
    var oXL = null; 
	try {
        oXL = GetObject("", "Excel.Application");
    }
    catch (E) {
        try {
            oXL = new ActiveXObject("Excel.Application");
        }
        catch (E2) {
            alert("Please confirm:\n1.Microsoft Excel has been installed.\n2.Internet Options=>Security=>Setting \"Enable unsafe ActiveX\"");
            return;
        }
    }

    // Create AX excel object  
    var oWB = oXL.Workbooks.Add(); 
     // Gets the workbook object  
    var oSheet = oWB.ActiveSheet; 
		
	// In this style control  
	oSheet.Rows(1+":"+1).RowHeight =20;// Define the height of a row  
	oSheet.Rows(2+":"+2).RowHeight =30;
	// Defines the width of the column  
	oSheet.Columns('A:A').ColumnWidth = 5;
	oSheet.Columns('B:B').ColumnWidth = 10;
	oSheet.Columns('C:C').ColumnWidth = 15;
	oSheet.Columns('D:D').ColumnWidth = 15;
	oSheet.Columns('E:E').ColumnWidth = 38;
	oSheet.Columns('F:F').ColumnWidth = 12;
	oSheet.Columns('G:G').ColumnWidth = 10;
	oSheet.Columns('H:H').ColumnWidth = 15;

	oSheet.Rows(1).HorizontalAlignment=3;   

    var sel = document.body.createTextRange(); // Activates the current sheet  
    sel.moveToElementText(curTbl); // The table of contents to a TextRange in  
    sel.select();  // Select all the contents in the TextRange  
    sel.execCommand("Copy"); // Copy the contents in the TextRange  
    oSheet.Paste(); // Paste into the activities of Excel  
    oXL.Visible = true; // Set the visible property of the excel  
	
	oSheet.Application.Quit();   // Ends the current process  

	window.opener=null;
	window.close();// Close the current window  
	
 } 
</script>
</head>
<body>
<div >
	<input type="button" value="export">
</div>
<table width="1038" border=1 align="center" ><!-- --> 
  <tHead>
    <tr>
      <td colspan="8" ><div align="center"><strong> The request for registration list  </strong></div></td>
    </tr>
    <tr>
      <td width="90"><div align="center" width="90"><strong> Ordinal number  </strong></div></td>
      <td width="121"><div align="center" width="121"><strong> File number  </strong></div></td>
      <td width="123"><div align="center" width="123"><strong>  File number  </strong></div></td>
      <td width="123"><div align="center"><strong>  Date  </strong></div></td>
      <td width="276"><div align="center"><strong>  Title  </strong></div></td>
      <td width="85"><div align="center"  width="85""><strong>  Note  </strong></div></td>
    </tr>
  </tHead>
  <tbody>

    <tr>
      <td align="center">&nbsp;1</td>
      <td align="center">2008-0202- Ask  </td>
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;2009-5-14 21:38</td>
      <td align="center">&nbsp;gggggg</td>
      <td align="center">&nbsp;</td>
    </tr>
	
	 <tr>
      <td align="center">&nbsp;1</td>
      <td align="center">2008-0202- Ask  </td>
      <td align="center">&nbsp;</td>
      <td align="center">&nbsp;2009-5-14 21:38</td>
      <td align="center">&nbsp;gggggg</td>
      <td align="center">&nbsp;</td>
    </tr>

  </tbody>
</table>
</body>
</html>

  • del.icio.us
  • StumbleUpon
  • Digg
  • TwitThis
  • Mixx
  • Technorati
  • Facebook
  • NewsVine
  • Reddit
  • Google
  • LinkedIn
  • YahooMyWeb

Related Posts of js format excel export control

  • Build flex + spring + blazeds + hibernate application

    Build flex + spring + blazeds + hibernate application First, set up the project blazeds 1, will blazeds.war extract to a directory, such as: myflex /; 2, set up java works were such as: MyFlex, in the orientation of selection create project from exis ...

  • Process migration from tomcat to websphere changes

    Process migration from tomcat to websphere changes Because customers use the web application server software used by different what tomcat5, tomcat6, websphere5.1, websphere6.1, weblogic8, and so on, and the software used inconsistent standards, ibm& ...

  • JAVA EE JSP_JNDI

    dsfdsa http://lindows.javaeye.com/admin/blogs/213348 Tomcat 6 with the connection pool data source configuration http://www.blogjava.net/ec2008/archive/2008/07/19/216063.html project: test Driver path: D: \ workspace \ test \ WebRoot \ WEB-INF \ lib ...

  • Hibernate connection pool configuration

    Hibernate connection pool configuration <! - Jdbc -> <property name="connection.driver_class"> oracle.jdbc.driver.OracleDriver </ property> <property name="connection.url"> jdbc: oracle: thin: @ 10.203.14.1 ...

  • hibernate generic generic DAO

    hibernate generic generic DAO

  • Servlet brief introduction

    Servlet brief introduction: Servlet is a small application server Are used to complete the B / S architecture, the client requests the response to treatment Platform independence, performance, able to run thread Servlet API for Servlet provides the s ...

  • Spring2.0 + hibernate3.1 + log4j + mysql demo

    applicationContext.xml Non-attachment jar package, necessary friends can send an email to todd.liangt @ gmail.com

  • Struts2 + hibernate + spring problem user log in

    dao layer services layer action jsp <tr> <td align="center"> <b> user name: </ b> </ td> <td> <s: textfield name = "czyNumber" cssClass = "textstyle" theme = "simple" size = &q

  • Hibernate secondary cache

    Hibernate cache: 2-bit cache, also known as process-level cache or SessionFactory level cache, secondary cache can be shared by all of the session Cache configuration and the use of: Will echcache.xml (the document code in hibernate package directory ...

  • Hibernate's lazy strategy

    hibernate Lazy strategy can be used in: <class> tag, it can be true / false Tags can <PROPERTY> values true / false type of necessary tools to enhance <set> <list> can tag values true / false / extra <many-to-one> <on ...

Leave a Reply

Recent
Recent Entries
Tag Cloud
Random Entries