資源簡(jiǎn)介
通過(guò)讀取excel中的價(jià)目表形成搜索目錄,選取項(xiàng)目完畢后自動(dòng)生成合同訂單的一個(gè)小程序。

代碼片段和文件信息
package?excel;
import?java.awt.AWTException;
import?java.awt.BorderLayout;
import?java.awt.Button;
import?java.awt.FlowLayout;
import?java.awt.frame;
import?java.awt.Label;
import?java.awt.Panel;
import?java.awt.Robot;
import?java.awt.TextField;
import?java.awt.event.ActionEvent;
import?java.awt.event.ActionListener;
import?java.awt.event.KeyEvent;
import?java.awt.event.TextEvent;
import?java.awt.event.TextListener;
import?java.awt.event.WindowAdapter;
import?java.awt.event.WindowEvent;
import?java.io.File;
import?java.io.FileWriter;
import?java.io.IOException;
import?java.net.URL;
import?java.text.SimpleDateFormat;
import?java.util.Calendar;
import?java.util.Vector;
import?javax.swing.BorderFactory;
import?javax.swing.JEditorPane;
import?javax.swing.JList;
import?javax.swing.JOptionPane;
import?javax.swing.JScrollPane;
import?javax.swing.event.ListSelectionEvent;
import?javax.swing.event.ListSelectionListener;
import?jxl.Cell;
import?jxl.Sheet;
import?jxl.Workbook;
import?jxl.read.biff.BiffException;
class?Item?{
String?xh?mc;
double?jg1?jg2;
Item(String?x?String?m?double?j1?double?j2)?{
xh?=?x;
mc?=?m;
jg1?=?j1;
jg2?=?j2;
}
void?pri()?{
System.out.println(xh?+?“?“?+?mc?+?“?“?+?jg1?+?“?“?+?jg2);
}
boolean?isprefix(String?str)?{
if?(xh.toLowerCase().startsWith(str.toLowerCase()))
return?true;
else
return?false;
}
}
class?LItem?{
Item?con;
int?num;
double?sum;
LItem(Item?c?int?n)?{
con?=?c;
num?=?n;
sum?=?(c.jg1?+?c.jg2)?*?n;
}
}
class?Mywin?extends?frame?implements?TextListener?ListSelectionListener
ActionListener?{
private?static?final?long?serialVersionUID?=?1L;
TextField?tf;
JList?l1?l2;
Vectorject>?vec?vec2?vec3;
Button?bt?cl;
int?flag;
boolean?boo;
Mywin()?{
super(“價(jià)目“);
tf?=?new?TextField(17);
tf.addTextListener(this);
l1?=?new?JList();
vec?=?new?Vectorject>();
vec2?=?new?Vectorject>();
vec3?=?new?Vectorject>();
for?(int?i?=?0;?i?8;?i++)?{
vec.addElement(Main.item[i].xh);
}
l1?=?new?JList(vec);
l1.setVisibleRowCount(8);
l1.setBorder(BorderFactory.createtitledBorder(“請(qǐng)選擇“));
l1.addListSelectionListener(this);
Panel?p0?=?new?Panel();
p0.setLayout(new?FlowLayout(0));
p0.add(new?Label(“搜索“));
p0.add(tf);
Panel?p1?=?new?Panel();
p1.setLayout(new?BorderLayout(0?0));
p1.add(p0?BorderLayout.NORTH);
p1.add(l1?BorderLayout.CENTER);
l2?=?new?JList();
l2.setVisibleRowCount(10);
l2.setBorder(BorderFactory.createtitledBorder(“已選“));
l2.addListSelectionListener(this);
Panel?p2?=?new?Panel();
p2.setLayout(new?BorderLayout(1?2));
p2.add(p1?BorderLayout.WEST);
p2.add(new?JScrollPane(l2)?BorderLayout.CENTER);
this.add(p2?BorderLayout.CENTER);
bt?=?new?Button(“生成訂單合同“);
bt.addActionListener(this);
cl?=?new?Button(“清空已選項(xiàng)目“);
cl.addActionListener(this);
Panel?p3?=?new?Panel
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????308??2009-01-15?21:20??.classpath
?????文件????????381??2009-01-11?17:38??.project
?????文件????1558016??2009-01-11?17:41??book.xls
?????文件???????1232??2009-01-25?15:56??bin\excel\Item.class
?????文件????????483??2009-01-25?15:56??bin\excel\LItem.class
?????文件???????1911??2009-01-25?15:56??bin\excel\Main.class
?????文件????????621??2009-01-25?15:56??bin\excel\Mywin$1.class
?????文件??????10011??2009-01-25?15:56??bin\excel\Mywin.class
?????文件????????614??2009-01-25?15:56??bin\excel\ViewPAGE$1.class
?????文件???????3437??2009-01-25?15:56??bin\excel\ViewPAGE.class
?????文件?????725247??2008-11-25?08:40??lib\jxl.jar
?????文件??????11600??2009-01-25?15:56??src\excel\Main.java
?????目錄??????????0??2009-01-23?17:52??bin\excel
?????目錄??????????0??2009-01-15?13:51??src\excel
?????目錄??????????0??2009-01-23?17:52??bin
?????目錄??????????0??2009-01-15?21:19??lib
?????目錄??????????0??2009-01-11?17:38??src
-----------?---------??----------?-----??----
??????????????2313861????????????????????17
評(píng)論
共有 條評(píng)論