Powerful XCEL components in jsp

Source: Internet
Author: User

To use excel components in this way, the client must have an excel program. The method is to extract the content of each td tag in the table as the content of a cell in an excel file.
1. Add a java script to the webpage.

Function AutomateExcel (tableid, unusecolumn)

{

// Obtain the excel component
Var oXL = new ActiveXObject ("Excel. Application ");
 
// Create a workbook
Var oWB = oXL. Workbooks. Add ();
Var oSheet = oWB. ActiveSheet;
Var table = document. getElementById (tableid );
Var hang = table. rows. length;
Var lie = table. rows (0). cells. length;
For (I = 0; I {
For (j = 0; j <lie-unusecolumn; j)
{
OSheet. Cells (I 1, j 1). value = table. rows (I). cells (j). innerText;
}
}
OXL. Visible = true;
OXL. UserControl = true;
}

2. Add the export button.

<Input class = "Noprint" type = "Button" onclick = "AutomateExcel (ordertable, 0);" value = "Export">

The first parameter of the AutomateExcel function is the ID of the table to be exported. The second parameter indicates the number of columns to be ignored at the end of the table during export. If this parameter is not required, set it to '0'

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.