<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    夢幻之旅

    DEBUG - 天道酬勤

       :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理 ::
      671 隨筆 :: 6 文章 :: 256 評論 :: 0 Trackbacks
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.io.InputStream;
    import java.util.HashMap;

    import jxl.Cell;
    import jxl.Sheet;
    import jxl.Workbook;
    import jxl.read.biff.BiffException;

    import org.apache.struts.upload.FormFile;

    /**
     * 
    @author Hay Vanpull
     * 
     
    */
    public class JXLTOOL
    {
        
    private Workbook                workbook   = null// 工作部對象
                                                           
        
    private HashMap<String, String> mapData    = null// data數據
                                                           
        
    private Sheet                   sheet      = null// 工作表
                                                           
        
    public int                      totalRows  = 0;   // 總行數
                                                           
        
    public int                      totalCells = 0;   // 總列數
                                                           
        
    /**
         * 以一個InputStream為參數的構造器
         * 
         * 
    @param inputStream
         * 
    @throws IOException
         * 
    @throws BiffException
         
    */
        
    public JXLTOOL(InputStream inputStream) throws BiffException, IOException
        {
            
    this.workbook = Workbook.getWorkbook(inputStream);
            
    this.sheet = this.workbook.getSheet(0);
            
    this.getRows();
            
    this.getCells();
        }
        
        
    /**
         * 以一個Struts FormFile為參數的構造器
         * 
         * 
    @param file
         * 
    @throws IOException
         * 
    @throws FileNotFoundException
         * 
    @throws BiffException
         
    */
        
    public JXLTOOL(FormFile file) throws FileNotFoundException, IOException,
                BiffException
        {
            
    this(file.getInputStream());
        }
        
        
    /**
         * 以一個File為參數的構造器
         * 
         * 
    @param file
         * 
    @throws IOException
         * 
    @throws BiffException
         
    */
        
    public JXLTOOL(File file) throws BiffException, IOException
        {
            
    this(new FileInputStream(file));
        }
        
        
    /**
         * 以一個文件路徑path的構造器
         * 
         * 
    @param filePath
         * 
    @throws IOException
         * 
    @throws BiffException
         
    */
        
    public JXLTOOL(String filePath) throws BiffException, IOException
        {
            
            
    this(new File(filePath));
        }
        
        
    /**
         * 把所有數據放到一個map中去,key為行號加列號
         * 
         * 
    @return
         
    */
        
    public HashMap<String, String> getExcelDate()
        {
            mapData 
    = new HashMap<String, String>();
            
    for (int i = 0; i < this.totalRows; i++)
            {
                
    for (int j = 0; j < this.totalCells; j++)
                {
                    
    this.mapData.put(i + "" + j, this.getData(j, i));
                }
            }
            
    return this.mapData;
        }
        
        
    /**
         * 得到總行數
         
    */
        
    private void getRows()
        {
            
    this.totalRows = sheet.getRows();
        }
        
        
    /**
         * 得到總列數
         
    */
        
    private void getCells()
        {
            
    this.totalCells = this.sheet.getColumns();
        }
        
        
    /**
         * 得到數據
         * 
         * 
    @param cell
         * 
    @param row
         * 
    @return
         
    */
        
    private String getData(int cell, int row)
        {
            Cell rs 
    = this.sheet.getCell(cell, row);
            
    return rs.getContents();
        }
    }
    posted on 2008-08-13 17:32 HUIKK 閱讀(8096) 評論(0)  編輯  收藏 所屬分類: TOOL
    主站蜘蛛池模板: 中文字幕亚洲综合小综合在线| 亚洲一区中文字幕| 男女作爱免费网站| 免费在线观看视频a| 亚洲av中文无码字幕色不卡| 女人18毛片特级一级免费视频 | 久久夜色精品国产亚洲AV动态图| 插鸡网站在线播放免费观看| 国产成人亚洲综合| 成年女人A毛片免费视频| 亚洲第一区香蕉_国产a| 99视频在线精品免费| 亚洲欧洲中文日产| 成全高清视频免费观看| 羞羞网站免费观看| 亚洲熟妇av一区二区三区漫画| 在线涩涩免费观看国产精品| 久久精品国产亚洲AV高清热 | 国产精品手机在线亚洲| 一本色道久久88亚洲综合 | 亚洲欧洲无码AV不卡在线| 夜夜爽免费888视频| 香蕉视频免费在线| 亚洲国产另类久久久精品| 久章草在线精品视频免费观看| 亚洲精品无码久久久久久久| 夭天干天天做天天免费看| 一级毛片a免费播放王色电影| 亚洲国产无套无码av电影| 国产免费不卡视频| 精品在线视频免费| 午夜亚洲国产理论秋霞| 国内大片在线免费看| 三上悠亚电影全集免费| 国产精品高清视亚洲精品| 亚洲午夜无码片在线观看影院猛| 最近中文字幕完整版免费高清| 亚洲精品无码久久久久秋霞| 国产亚洲成av片在线观看| 无码永久免费AV网站| 国产综合免费精品久久久|