⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readsheet.java

📁 基于Java的地图数据管理软件。使用MySQL数据库管理系统。
💻 JAVA
字号:
package net.aetherial.gis.publicuse.excel;

import jxl.Sheet;
import net.aetherial.gis.jiaotongbu.outputJTB.txtOutput.module.excel.Property;
import java.io.File;
import java.io.IOException;
import jxl.read.biff.BiffException;
import jxl.Workbook;

/**
 * <p>Title: </p>
 *
 * <p>Description: </p>
 *
 * <p>Copyright: Copyright (c) 2004</p>
 *
 * <p>Company: </p>
 *
 * @author not attributable
 * @version 1.0
 */
public class ReadSheet {
  private Sheet mySheet = null;

  /**
   * 行数
   */
  private int rows = 0;

  public ReadSheet() {
  }

  public void setSheetFile(String sheetFile, String sheetName) {
    this.mySheet = this.getSheet(sheetFile, sheetName);
    if (this.mySheet == null) {
      this.mySheet = this.getSheet(sheetFile, 0);
    }
    try {
      this.rows = this.mySheet.getRows();
    }
    catch (Exception ex) {
    }
  }

  public void setSheetFile(String sheetFile, int sheetID) {
    this.mySheet = this.getSheet(sheetFile, sheetID);
    try {
      this.rows = this.mySheet.getRows();
    }
    catch (Exception ex) {
    }
  }


  private Sheet getSheet(String fileName, String sheetName) {
    Workbook workbook = null;
    try {
      workbook = Workbook.getWorkbook(new File(fileName));
    }
    catch (BiffException ex) {
      System.err.println(ex.getMessage() +
                         " in Item.getSheet(String fileName,String sheetName) BiffException");
    }
    catch (IOException ex) {
      System.err.println(ex.getMessage() +
                         " in Item.getSheet(String fileName,String sheetName) IOException");
    }
    if (workbook != null) {
      return workbook.getSheet(sheetName);
    }
    else {
      return null;
    }
  }

  private Sheet getSheet(String fileName, int id) {
    Workbook workbook = null;
    try {
      workbook = Workbook.getWorkbook(new File(fileName));
    }
    catch (BiffException ex) {
      System.err.println(ex.getMessage() +
                         " in Item.getSheet(String fileName,String sheetName) BiffException");
    }
    catch (IOException ex) {
      System.err.println(ex.getMessage() +
                         " in Item.getSheet(String fileName,String sheetName) IOException");
    }
    if (workbook != null) {
      return workbook.getSheet(id);
    }
    else {
      return null;
    }
  }

  public Sheet getMySheet() {
    return mySheet;
  }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -