特急,如能解决马上给分

yangyong36 2003-09-05 06:17:16
怎样将java中取得的数据导到Excel中 ,最好带个例子
...全文
20 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
Bonjor 2003-09-05
  • 打赏
  • 举报
回复
使用poi,挺easy的,
import org.apache.poi.hssf.usermodel.*;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;

public class CreateCells{
public static void main(String[] args) throws IOException{
HSSFWorkbook wb = new HSSFWorkbook();//建立新HSSFWorkbook对象
HSSFSheet sheet = wb.createSheet("new sheet");//建立新的sheet对象
HSSFRow row = sheet.createRow((short)0);//建立新行
HSSFCell cell = row.createCell((short)0);//建立新cell
cell.setCellValue(1);//设置cell的整数类型的值
row.createCell((short)0).setCellValue(1.2);//设置cell浮点类型的值
row.createCell((short)1).setCellValue(1.2);//设置cell浮点类型的值
row.createCell((short)2).setCellValue("test");//设置cell字符类型的值
row.createCell((short)3).setCellValue(true);//设置cell布尔类型的值
HSSFCell csCell =row.createCell((short)5);
csCell.setEncoding(HSSFCell.ENCODING_UTF_16);//设置cell编码解决中文高位字节截断
csCell.setCellValue("中文测试_Chinese Words Test");//设置中西文结合字符串
row.createCell((short)6).setCellType(HSSFCell.CELL_TYPE_ERROR);//建立错误cell
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
}
}
seaman0916 2003-09-05
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/2228/2228695.xml?temp=.8008386

刚看到的!
seaman0916 2003-09-05
  • 打赏
  • 举报
回复
关注 !
seaman0916 2003-09-05
  • 打赏
  • 举报
回复
<servlet与jsp权威指南>上有个例子 ,但我没试成功!

我也在找这方面的资料!
键舞鸿蒙 2003-09-05
  • 打赏
  • 举报
回复
up
junsunchen 2003-09-05
  • 打赏
  • 举报
回复
up
wangchq 2003-09-05
  • 打赏
  • 举报
回复
看看apache的poi,专门处理ms office与java的转化的
danceflash 2003-09-05
  • 打赏
  • 举报
回复
要是想在java里导入就麻烦了
需要第三方的支持包
jokerjava 2003-09-05
  • 打赏
  • 举报
回复
很简单 告诉你 例子就免了

你的文件格式如下 execl就能打开
string1,string2,string3;

81,114

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧