`
1846396994
  • 浏览: 72397 次
社区版块
存档分类
最新评论

使用jxl读写Excel文件

 
阅读更多

 

发现以前项目中使用jxl.jar来读写excel,为了方便自己和他人,现准备扎根如此!!

这个自己没做太多研究,只因项目需要关注过怎么读写excel,直接上代码:
<code lang='java' width='auto' height='auto'>
public class ExcelHelper {
public static void write(String filepath) throws IOException,RowsExceededException, WriteException {
  WorkbookSettings ws = new WorkbookSettings(); //工作簿设置
  ws.setLocale(new Locale("en", "EN"));
  WritableWorkbook workbook = Workbook.createWorkbook(new File(filepath),ws);
  //创建一个工作簿
  WritableSheet s2 = workbook.createSheet("Number Formats", 0);
  //填充数据
  List list = new ArrayList();
  for (int i = 0; i &lt; list.size(); i++) {
   Object obj = list.get(i);
   Object[] objset = (Object[]) obj;
   for (int j = 0; j &lt; objset.length; j++) {
    Label lr = new Label(j, i, objset[j] == null ? ""
      : (String) objset[j]);
    s2.addCell(lr);
   }
  }
  //写入数据


原文地址:使用jxl读写Excel文件 | http://orgcent.com/use-jxl-jar-read-write-excel-file/
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics