當前位置: 首頁>>代碼示例>>Java>>正文


Java BiffException類代碼示例

本文整理匯總了Java中jxl.read.biff.BiffException的典型用法代碼示例。如果您正苦於以下問題:Java BiffException類的具體用法?Java BiffException怎麽用?Java BiffException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BiffException類屬於jxl.read.biff包,在下文中一共展示了BiffException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getNumberOfSheets

import jxl.read.biff.BiffException; //導入依賴的package包/類
/**
 * Returns the number of sheets in the excel file
 *
 * @return
 * @throws IOException
 * @throws BiffException
 * @throws InvalidFormatException
 */
public int getNumberOfSheets() throws BiffException, IOException, InvalidFormatException, UserError {
	if (getFile().getAbsolutePath().endsWith(XLSX_FILE_ENDING)) {
		// excel 2007 file
		try (ZipFile zipFile = new ZipFile(getFile().getAbsolutePath())) {
			try {
				return getNumberOfSheets(parseWorkbook(zipFile));
			} catch (ParserConfigurationException | SAXException e) {
				throw new UserError(null, e, "xlsx_content_malformed");
			}
		}
	} else {
		// excel pre 2007 file
		if (workbookJXL == null) {
			createWorkbookJXL();
		}
		return workbookJXL.getNumberOfSheets();
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:27,代碼來源:ExcelResultSetConfiguration.java

示例2: readExcel

import jxl.read.biff.BiffException; //導入依賴的package包/類
public static void readExcel(String inputfileName, String outputfileName) throws BiffException, IOException , RowsExceededException, WriteException{
	Workbook wb=Workbook.getWorkbook(new File(inputfileName));
	Sheet sheet = wb.getSheet(0); //get sheet(0)
	WritableWorkbook wwb = Workbook.createWorkbook(new File(outputfileName));
	WritableSheet ws = wwb.createSheet("topicName", 0);
	//traversal
	for(int i=0; i<sheet.getRows(); i++)
	{
		String content = sheet.getCell(0,i).getContents();
		String[] words = content.split("\\(");
		content = words[0];
		content = content.toLowerCase();
		content = content.replaceAll("_", " ");
		content = content.replaceAll("-", " ");
		content = content.replaceAll("\\s+", " ");
		if(content.contains("data structure") && !content.trim().equals("data structure"))
			content = content.replaceAll("data structure", "");
		Label labelC = new Label(0, i, content.trim()); 
		ws.addCell(labelC); 
	}
       wwb.write();    
       wwb.close();
}
 
開發者ID:guozhaotong,項目名稱:FacetExtract,代碼行數:24,代碼來源:TopicNameProcess.java

示例3: getSheetNames

import jxl.read.biff.BiffException; //導入依賴的package包/類
/**
 * Returns the names of all sheets in the excel file
 *
 * @return
 * @throws IOException
 * @throws BiffException
 * @throws InvalidFormatException
 */
public String[] getSheetNames() throws BiffException, IOException, InvalidFormatException, UserError {
	if (getFile().getAbsolutePath().endsWith(XLSX_FILE_ENDING)) {
		// excel 2007 file
		try (ZipFile zipFile = new ZipFile(getFile().getAbsolutePath())) {
			XlsxWorkbook workbook;
			try {
				workbook = parseWorkbook(zipFile);
				String[] sheetNames = new String[getNumberOfSheets(workbook)];
				for (int i = 0; i < getNumberOfSheets(); i++) {
					sheetNames[i] = workbook.xlsxWorkbookSheets.get(i).name;
				}
				return sheetNames;
			} catch (ParserConfigurationException | SAXException e) {
				throw new UserError(null, e, "xlsx_content_malformed");
			}

		}
	} else {
		// excel pre 2007 file
		if (workbookJXL == null) {
			createWorkbookJXL();
		}
		return workbookJXL.getSheetNames();
	}
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:34,代碼來源:ExcelResultSetConfiguration.java

示例4: SaveContantAllTopics

import jxl.read.biff.BiffException; //導入依賴的package包/類
@SuppressWarnings("deprecation")
public static void SaveContantAllTopics(String oriPath) throws BiffException, IOException
{
	File dirfile =new File(oriPath + "1_origin");    
	if  (!dirfile .exists()  && !dirfile .isDirectory())      
	{       
	    dirfile .mkdir();    
	} 
	String dirPath = oriPath + "1_origin\\";
	String topics = FileUtils.readFileToString(new File("M:\\Data mining data set\\topic.txt"));
	String[] topic = topics.split("\n");
	System.out.println("共有" + topic.length + "個術語");
	for (int i = 0; i < topic.length; i++)
	{
		System.out.println("Save content\t" + i + "\t" + topic[i]);
		wiki(dirPath,topic[i]);
	}
	System.out.println("Done.");
}
 
開發者ID:guozhaotong,項目名稱:FacetExtract,代碼行數:20,代碼來源:aSaveContentAllTopics.java

示例5: GetHyponymyFromExl

import jxl.read.biff.BiffException; //導入依賴的package包/類
public static AllHyponymy GetHyponymyFromExl(String exlFilePath) {
    Workbook wb;
    ArrayList<String> upLocation = new ArrayList<>();
    ArrayList<String> dnLocation = new ArrayList<>();
    try {
        wb = Workbook.getWorkbook(new File(exlFilePath));
        Sheet sheet = wb.getSheet(0); //get sheet(0)
        for (int i = 1; i < sheet.getRows(); i++) {
            dnLocation.add(sheet.getCell(0, i).getContents());
            upLocation.add(sheet.getCell(1, i).getContents());
        }
    } catch (BiffException | IOException e) {
        e.printStackTrace();
    }
    AllHyponymy allHyponymy = new AllHyponymy(upLocation, dnLocation);
    return allHyponymy;
}
 
開發者ID:guozhaotong,項目名稱:FacetExtract,代碼行數:18,代碼來源:GetHyponymy.java

示例6: setActions

import jxl.read.biff.BiffException; //導入依賴的package包/類
private WikiPane setActions() {
  fileName.textProperty().addListener((observable, oldValue, newValue) -> {
    createButton.setDisable(newValue.isEmpty());
  });

  createButton.setOnAction(event -> {
    try {
      createSpreadsheet();
      showOpenFileButton();
      Settings.saveProperties();
    } catch (IOException | BiffException | WriteException ex) {
      addElement(new WikiLabel("create-file-error"));
      LOGGER.log(Level.WARNING, 
          "Error occurred during creation of spreadsheet file: {0}",
          new String[]{ex.getLocalizedMessage()}
      );
    }
  });

  return this;
}
 
開發者ID:yarl,項目名稱:pattypan,代碼行數:22,代碼來源:CreateFilePane.java

示例7: readSpreadSheet

import jxl.read.biff.BiffException; //導入依賴的package包/類
/**
 * Reads spreadsheet stored in Session.FILE.
 */
private void readSpreadSheet() throws BiffException, IOException, Exception {
  infoContainer.getChildren().clear();
  Session.SCENES.remove("CheckPane");

  WorkbookSettings ws = new WorkbookSettings();
  ws.setEncoding("Cp1252");

  try {
    Workbook workbook = Workbook.getWorkbook(Session.FILE, ws);
    Sheet dataSheet = workbook.getSheet(0);
    Sheet templateSheet = workbook.getSheet(1);
    readHeaders(dataSheet);
    addFilesToUpload(readDescriptions(dataSheet), readTemplate(templateSheet));
  } catch (IndexOutOfBoundsException ex) {
    throw new Exception("Error: your spreadsheet should have minimum two tabs.");
  }

  reloadButton.setDisable(false);
}
 
開發者ID:yarl,項目名稱:pattypan,代碼行數:23,代碼來源:LoadPane.java

示例8: readFrom

import jxl.read.biff.BiffException; //導入依賴的package包/類
private Map<String, NList> readFrom( InputStream inputStream, Reader reader ) throws UncheckedIOException {

        Map<String, NList> result   = new LinkedHashMap<>();
        Workbook           workBook = null;

        try {

            workBook = Workbook.getWorkbook( inputStream );
            reader.read( workBook, result );
            return result;

        } catch( IOException | BiffException e ) {
            throw new UncheckedIOException( e, "Error on reading excel data from input stream." );
        } finally {
            if( workBook != null ) {
                workBook.close();
            }
        }

    }
 
開發者ID:NyBatis,項目名稱:NyBatisCore,代碼行數:21,代碼來源:ExcelHandlerJxl.java

示例9: Excel

import jxl.read.biff.BiffException; //導入依賴的package包/類
/**
   * 
   * Constructor for Excel initializes internal 
   * data settings.
   */
  private Excel(File aFile)
  throws IOException
  {
     
     //Open file for read
     try
{
	this.workbook = Workbook.getWorkbook(aFile);
}
catch (BiffException e)
{
	throw new IOException(e);
}


  }
 
開發者ID:nyla-solutions,項目名稱:nyla,代碼行數:22,代碼來源:Excel.java

示例10: loadDefaultList

import jxl.read.biff.BiffException; //導入依賴的package包/類
private void loadDefaultList() throws BiffException,
        FileNotFoundException,
        IOException,
        WriteException {
    // iterator the file in the directory
    Path dir = Paths.get(fileDir);
    // create a file directory stream to iterat the content
    try (DirectoryStream<Path> readDirStream = Files.newDirectoryStream(dir)) {
        boolean onlyFirstTurn = true;
        // for each loop to iterate
        for (Path afile : readDirStream) {
            addItem(afile, onlyFirstTurn);
            onlyFirstTurn = false;
        }
    }
    // because you have use the try method
    // here you need not to close the stream
}
 
開發者ID:smileboywtu,項目名稱:CS-FileTransfer,代碼行數:19,代碼來源:SyncListIO.java

示例11: main

import jxl.read.biff.BiffException; //導入依賴的package包/類
public static void main(String[] args) throws IOException, 
            BiffException, 
            FileNotFoundException, 
            WriteException {
        // test
        SyncListIO test = new SyncListIO();
        
        // test write to the file
        // here just create the string array
//        String[] strs = {"readme.txt"};
//        test.writeList(strs);
        
        // then test the read 
        Object[] strObj = test.readList();
        for(Object a: strObj){
            System.out.println(Arrays.toString((String[])a));
        }
    }
 
開發者ID:smileboywtu,項目名稱:CS-FileTransfer,代碼行數:19,代碼來源:SyncListIO.java

示例12: createUserInterface

import jxl.read.biff.BiffException; //導入依賴的package包/類
private static void createUserInterface() throws IOException,
        URISyntaxException,
        BiffException,
        FileNotFoundException,
        WriteException {
    // create a new frame
    JFrame appFrame = new JFrame("FileTransferTool");
    // set attributes
    appFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    // add content pane to it
    FileTransferClient client = new FileTransferClient();
    appFrame.setContentPane(client.clientInit());

    // make it in the center of the screen
    appFrame.setLocationRelativeTo(null);
    int x = appFrame.getLocation().x - appFrame.getPreferredSize().width / 2;
    int y = appFrame.getLocation().y - appFrame.getPreferredSize().height / 2;
    appFrame.setLocation(x, y);

    // pack and show 
    appFrame.pack();
    appFrame.setVisible(true);
}
 
開發者ID:smileboywtu,項目名稱:CS-FileTransfer,代碼行數:25,代碼來源:FileTransferClient.java

示例13: importDivision201312

import jxl.read.biff.BiffException; //導入依賴的package包/類
public void importDivision201312() throws BiffException, IOException {
    // prepare the data from source
    XLSReader reader = new XLSReader("data/201312.xls");

    Term term201312 = em.createQuery(
            "select term from Term term where term.name = '201312'",
            Term.class).getSingleResult();

    Division division = null;
    for (int idx = 1; idx < reader.getTotalRows(); idx++) {
        division = new Division(reader.getRow(idx), term201312);

        // try to get the division by name
        Long count = em
                .createQuery(
                        "select count(d) from Division d where d.name = :name",
                        Long.class)
                .setParameter("name", division.getName()).getSingleResult();

        if (count == 0 && !division.getName().isEmpty()) {
            em.persist(division);
        }
    }
}
 
開發者ID:destiny1020,項目名稱:hranalyzer,代碼行數:25,代碼來源:DivisionDataImporter.java

示例14: importDivision201406

import jxl.read.biff.BiffException; //導入依賴的package包/類
public void importDivision201406() throws BiffException, IOException {
    // prepare the data from source
    XLSReader reader = new XLSReader("data/201406.xls");

    Term term201406 = em.createQuery(
            "select term from Term term where term.name = '201406'",
            Term.class).getSingleResult();

    Division division = null;
    for (int idx = 1; idx < reader.getTotalRows(); idx++) {
        division = new Division(reader.getRow(idx), term201406);

        // try to get the division by name
        Long count = em
                .createQuery(
                        "select count(d) from Division d where d.name = :name",
                        Long.class)
                .setParameter("name", division.getName()).getSingleResult();

        if (count == 0 && !division.getName().isEmpty()) {
            em.persist(division);
        }
    }
}
 
開發者ID:destiny1020,項目名稱:hranalyzer,代碼行數:25,代碼來源:DivisionDataImporter.java

示例15: testReadingXLS

import jxl.read.biff.BiffException; //導入依賴的package包/類
@Test
public void testReadingXLS() throws IOException, BiffException {
    Workbook book = Workbook.getWorkbook(new File("data/201406.xls"));

    System.out.println(book.getNumberOfSheets());

    Sheet listSheet = book.getSheet(1);
    System.out.println(listSheet.getName());

    System.out.println(listSheet.getRows());

    for (int i = 0; i < listSheet.getRows(); i++) {
        Cell[] row = listSheet.getRow(i);
        for (int j = 0; j < row.length; j++) {
            if (j < row.length - 1) {
                System.out.print((j + 1) + ": " + row[j].getContents()
                        + " --- ");
            } else {
                System.out.print((j + 1) + ": " + row[j].getContents());
            }
        }
        System.out.println();
        //            }
    }

}
 
開發者ID:destiny1020,項目名稱:hranalyzer,代碼行數:27,代碼來源:ApplicationTests.java


注:本文中的jxl.read.biff.BiffException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。