POI Auto Filter

前端 未结 6 681
逝去的感伤
逝去的感伤 2021-02-13 16:36

How do I use Apache POI to pre-define an auto-filter region in an Excel 2007 document?

A small code example or link would be nice.

6条回答
  •  清酒与你
    2021-02-13 17:13

    //include poi-3.7.jar,ojdbc.jar in classpath
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.ResultSetMetaData;
    import java.sql.Statement;
    import java.io.*;
    import java.net.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import org.apache.poi.hssf.usermodel.*;
    import org.apache.poi.hssf.util.HSSFColor;
    import org.apache.poi.ss.usermodel.Cell;
    import org.apache.poi.ss.usermodel.CellStyle;
    import org.apache.poi.ss.usermodel.IndexedColors;
    
    public class ExcelCreator{
    public static void createExcel(String anySql,OutputStream out) throws Exception{
    Connection conn=getOracleConnection();
    String userSql1="select * from tab";
    String userSql2="select * from tab";
        String[] sqls={userSql1,userSql2,anySql};
        String[] workSheetNames={"User","Manager","Any"};
           HSSFWorkbook wb = new HSSFWorkbook();
           CellStyle style1 = wb.createCellStyle();
           CellStyle style2 = wb.createCellStyle();
           for(int i=0;i

提交回复
热议问题