我用过把HTML表里的数据存成EXCEL,然后可以在浏览器里查询以EXCEL显示,用的是apache的类库,再具体的没有做过,不过apache应该做过或者在做这方面的东西。
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import com.optel.telemaster.util.excel.*;
import java.io.*;
import java.util.*;
import org.exolab.castor.jdo.*;
import com.optel.telemaster.model.*;public interface OutputExcelFile
{
public ExcelSheet createSheet(String sheetName,int row,short column); public void setTitleAndHead(String sheetName); public void setContent(String sheetName,Database db) throws QueryException,
PersistenceException; //public void writeToFile(String path,String fileName,Database db) throws IOException,
// QueryException,PersistenceException ; public void writeToDB(ExcelFile excelFile,Database db) throws IOException,
QueryException,PersistenceException;
}
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import com.optel.telemaster.util.excel.*;
import java.io.*;
import java.util.*;
import org.exolab.castor.jdo.*;
import com.optel.telemaster.model.*;public interface OutputExcelFile
{
public ExcelSheet createSheet(String sheetName,int row,short column); public void setTitleAndHead(String sheetName); public void setContent(String sheetName,Database db) throws QueryException,
PersistenceException; //public void writeToFile(String path,String fileName,Database db) throws IOException,
// QueryException,PersistenceException ; public void writeToDB(ExcelFile excelFile,Database db) throws IOException,
QueryException,PersistenceException;
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("application/vnd.ms-excel");
try
{
int id = getIntParameter(request, "id", 1);
byte excelFile[] = getExcelFile(id);
if(excelFile != null)
{
javax.servlet.ServletOutputStream output = response.getOutputStream();
output.write(excelFile);
output.close();
}
}
catch(Exception e)
{
e.printStackTrace();
response.setContentType("text/html;charset=gb2312");
PrintWriter output = response.getWriter();
output.write("\u65E0\u6CD5\u6253\u5F00\u6587\u4EF6!");
output.close();
}
}
但是org.apache.poi.poifs.filesystem的包从哪里能免费下载呢。多谢
所以::::::
如果你的excel文件是固定格式的,每一列都有固定的含义,那么可以将它看成一个表,事实上,excel文件就是一张兼容dbase的表。
所以:::::
最简单的方法是把excel当作数据库来看待,如果将excel文件存成dbase格式的话,我们就可以用我们熟悉的sql语句来操作它。用JDBC访问,或者将存放有excel的目录建成ODBC数据源,然后用JDBC-ODBC桥来访问。将excel表存成dbase格式文件的方法很简单,只需增加一个定位就可以了。
http://jakarta.apache.org/poi/hssf/quick-guide.html