poi excel 导出数值格式的问题就是去掉倒三角
/**
*
*/
package org.xg.db;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.sql.Connection;
import java.sql.Date;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
public class newecxel {
public newecxel() throws Exception
{
Connection con = null ;
DBConnection db = new DBConnection() ;
con = db.getDB() ;
ServletRequest request = null;
String sql="select*form students ";
ResultSet rs = con.createStatement().executeQuery(sql) ;
// 获取总列数
int CountColumnNum = rs.getMetaData().getColumnCount() ;
int i = 1 ;
// 创建Excel文档
HSSFWorkbook wb = new HSSFWorkbook() ;
// sheet 对应一个工作页
HSSFSheet sheet = wb.createSheet("V_KNITSTAFFJOBOUTDETAILS表中的数据") ;
HSSFRow firstrow = sheet.createRow(0); //下标为0的行开始
HSSFCell[] firstcell = new HSSFCell[CountColumnNum];
String[] names = new String[CountColumnNum];
names[0] = "批號";
names[1] = "號";
names[2] = "部门";
names[3] = "本廠款號";
names[4] = "卡號";
names[5] = "種类";
names[6] = "條形碼";
names[7] = "尺碼";
names[8] = "色號";
names[9] = "单价";
while(rs.next())
{
// 创建电子表格的一行
HSSFRow row = sheet.createRow(i) ; // 下标为1的行开始
for(int j=0;j<CountColumnNum;j++)
{
HSSFCell cell = row.createCell((short) j) ;
cell.setCellValue(new HSSFRichTextString(rs.getString(j+1))) ;
}
i++ ;
}
// 创建文件输出流,准备输出电子表格
OutputStream out = new FileOutputStream("D:\\book.xls") ;
wb.write(out) ;
out.close() ;
System.out.println("数据库导出成功") ;
rs.close() ;
con.close() ;
}
public static void main(String[] args)
{
try {
@SuppressWarnings("unused")
newecxel excel = new newecxel() ;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
怎么设置其中一列输出为数值型呢 ??? 比如 names[9] = "单价"; 这一列
救命阿 大神!