Execl Analysis of jsp operations

Source: Internet
Author: User

<% @ Page contentType = "text/html; charset = gb2312" language = "java" import = "java. SQL. *" %>
<% @ Page import = "jxl. *" %>
<% @ Page import = "jxl. write. *" %>
<% @ Page import = "java. io. *" %>
<% @ Page import = "java. util. *" %>
<Jsp (preferred for SUN Enterprise Applications): useBean id = "conn" class = "db. DbConnection" scope = "page"/>
<%
String SQL = (String) session. getValue ("SQL ");
// String apti = (String) session. getValue ("apti ");
// Select companyapti. companyid, companyapti. companytype, companyapti. c

Ompanyname, companyinfo. province, companyinfo. city, companyinfo. address,
// Companyinfo. connectman, companyinfo. mobile, companyinfo. tel, companyinfo. telephone
%>
<%
Try {

WritableWorkbook workbook = Workbook. createWorkbook (new File (request. getRealPath ("/") + "/mis/" + "/enterprise info. xls "));
// Create an Excel worksheet
WritableSheet sheet = workbook. createSheet ("enterprise information", 0 );
// Jxl. write. WritableSheet ws = wwb. createSheet ("Test Sheet 1", 0 );

// Set the font and format
 
// Writer data
// While (rs. next () {// while start
// For (int I = 1; I <= 23; I ++ ){
// Username = rs. getString (1). equals ("0 ")? "": Rs. getString (1). trim ();

// Username = "yzhxy2002 ";
// Label l = new Label (0, 0, username );
// Sheet. addCell (l );
// Jxl. write. Label labelC = new jxl. write. Label (1, 0, "This is a Label cell ");
// Sheet. addCell (labelC );
Label n = null, p = null, c = null, a = null, m = null, s = null, t = null, t1 = null, t2 = null;
String companyid = "", apti = "", aptiname = "", companyname = "", companytype = "", province = "",

City = "", address = "", connectman = "", mobile = "", tel = "", telephone = "";
ResultSet rs = null;

// Out. print (SQL );
Rsw.conn.exe cuteQuery (SQL );
Int I = 0;
While (rs. next ()){
// Query qualifications
StringTokenizer fenxi = new StringTokenizer (rs. getString ("companytype "),"-");
While (fenxi. hasMoreTokens ()){
Companytype = fenxi. nextToken (). toString ();
String sql0 = "select * from aptitype where typeid =" + companytype + "";
ResultSet rs01_conn.exe cuteQuery (sql0 );
If (rs0.next ()){
Aptiname = new String (rs0.getString ("typename"). getBytes ("iso8859-1 "));
}
Apti = aptiname + "-" + apti;
} // While
//
 
N = new Label (0, I, new String (rs. getString ("companyname"). getBytes ("iso8859-1 ")));
P = new Label (1, I, new String (rs. getString ("province"). getBytes ("iso8859-1 ")));
C = new Label (2, I, new String (rs. getString ("city"). getBytes ("iso8859-1 ")));
A = new Label (3, I, new String (rs. getString ("address"). getBytes ("iso8859-1 ")));
M = new Label (4, I, new String (rs. getString ("connectman"). getBytes ("iso8859-1 ")));
S = new Label (5, I, rs. getString ("mobile "));
T = new Label (6, I, rs. getString ("tel "));
T1 = new Label (7, I, rs. getString ("telephone "));
T2 = new Label (8, I, apti );

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.