请问如何把excel的东西转换成html文档(最好有代码)

解决方案 »

  1.   

    先解析读取excel数据,然后用JAVA代码输出html源文件的形式输出.
    读取excel:
    try   {
                Workbook book  =  Workbook.getWorkbook(new File("c:\\aaa.xls"));
                 //  获得第一个工作表对象
                Sheet sheet  =  book.getSheet(0);
                 //  得到第一列第一行的单元格
                Demo1 d1 = new Demo1();
                for(int i=1;i<131;i++){
                 Cell cell1  =  sheet.getCell(3,i);
                 Cell cell2  =  sheet.getCell(5,i);
                 Cell cell3  =  sheet.getCell(7,i);
                 Cell cell4  =  sheet.getCell(0,i);
                 Cell cell5  =  sheet.getCell(1,i);
                    String cell1_1  =  cell1.getContents().trim();
                    String cell2_1  =  cell2.getContents().trim();
                    String cell5_1  =  cell5.getContents().trim();
                    String cell3_1 = null;
                    cell3_1  
     //               System.out.println(cell4_1 + "::" +cell1_1 + "::" + cell2_1 + "::" + cell3_1);=  cell3.getContents().trim();
                    String cell4_1  =  cell4.getContents().trim();
                    d1.gets(cell4_1,cell5_1,cell1_1,cell2_1,cell3_1);
                    System.out.println(cell1_1.length());
                }
                book.close();
            }   catch  (Exception e)  {
                System.out.println(e);
            } 
    }
      

  2.   

    再输出html源文件
    try {
    file2.createNewFile();// 创建文件
    sb.append("<head>");
    sb
    .append("<meta http-equiv='content-type' content='text/html; charset=UTF-8'>");
    sb.append("\n");
    sb.append("<title>aaaaaaa</title>");
    sb.append("\n");
    // ******************************css样式Str****************************************
    sb.append("<style type='text/css'>");
    sb.append("\n");
    sb.append(".tablerow0 {background: #EEEEEE;}");
    sb.append("\n");
    ……………………………………………………………………………………………………………………………………………………………………………………………………………………