java 导出excel方法
到http://download.csdn.net/source/1781433下载jxl.jar文件
/*Title是保存出来的文件名,gbl_LastOpenPath用于记录上次打开的路径*/
public void ExportToExcel(JTable table, String Title){
File DefaultFile;
JFileChooser fc = new JFileChooser();
File file;
if(gbl_LastOpenPath!=null){
DefaultFile = new File(gbl_LastOpenPath+"/"+Title+".xls");
if(DefaultFile.exists()){
//fc.setSelectedFile(DefaultFile);
// fc.setCurrentDirectory(DefaultFile); //设置打开的默认路径
fc.setSelectedFile(DefaultFile);
}
}
if(gbl_LastOpenPath==null){
//String s = System.getProperty("user.dir");
fc.setSelectedFile(new File("c:/"+Title+".xls"));
}
int Selection = fc.showDialog(this, null);
fc.setVisible(true);
if(Selection==0){
file = fc.getSelectedFile();
gbl_LastOpenPath = file.getParent();
/*开始导出数据*/
try {
WritableWorkbook book = Workbook.createWorkbook(file);
WritableSheet sheet=book.createSheet(Title,0); //工作表名称
sheet.mergeCells(0,0,(table.getColumnCount()-1),0); //合并第一行
/*表头:加粗*/
WritableFont CaptionFont = new WritableFont(WritableFont.ARIAL, 14,WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
/*表头:居中*/
WritableCellFormat CatpionStyle = new WritableCellFormat(CaptionFont);
CatpionStyle.setAlignment(Alignment.CENTRE);
CatpionStyle.setVerticalAlignment(VerticalAlignment.CENTRE);
sheet.addCell(new Label(0,0,Title,CatpionStyle));
/*写表头*/
WritableFont TitleFont = new WritableFont(WritableFont.ARIAL, 10,WritableFont.BOLD, false, UnderlineStyle.NO_UNDERLINE,Colour.BLACK);
/*表头:居中*
相关文档:
package的命名 package 的名字由全部小写的字母组成,例如:cn.mybole。
class和interface的命名 class和interface的名字由大写字母开头而其他字母都小写的单词组成,例如:Person,RuntimeException。
class变量的命名 变量的名字用一个小写字母开头,后面的单词用大写字母开头,例如:index,currentImage。
clas ......
import java.util.LinkedList;
//单向队列
public class Queue {
public Queue() {
}
private LinkedList list = new LinkedList();
public void pu ......
JSP:javascript 和 struts部分
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td>
<span class="txt1">三级单位:</span>
<html:select property="oilarea" style="width:182" styleId="area" onchange="javascript:fillWell()"&g ......
Alan Kay曾经总结了Smalltalk的五项特征,这些特征是Java所依赖的基础之一,当然这些特征也代表了的面向对象的编程的方法。
&n ......
一. 什么是Native Method
简单地讲,一个Native Method就是一个java调用非java代码的接口。一个Native Method是这样一个java的方法:该方法的实现由非java语言实现,比如C。这个特征并非java所特有,很多其它的编程语言都有这一机制,比如在C++中,你可以用extern "C"告知C++编译器去调用一个C的函 ......