Java Code Examples for jxl.read.biff.BiffException

The following are top voted examples for showing how to use jxl.read.biff.BiffException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: rapidminer   File: ExcelResultSetConfiguration.java   View source code 7 votes vote down vote up
/**
 * 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();
	}
}
 
Example 2
Project: FacetExtract   File: TopicNameProcess.java   View source code 7 votes vote down vote up
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();
}
 
Example 3
Project: rapidminer   File: ExcelResultSetConfiguration.java   View source code 6 votes vote down vote up
/**
 * 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();
	}
}
 
Example 4
Project: FacetExtract   File: aSaveContentAllTopics.java   View source code 6 votes vote down vote up
@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.");
}
 
Example 5
Project: FacetExtract   File: GetHyponymy.java   View source code 6 votes vote down vote up
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;
}
 
Example 6
Project: pattypan   File: CreateFilePane.java   View source code 6 votes vote down vote up
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;
}
 
Example 7
Project: pattypan   File: LoadPane.java   View source code 6 votes vote down vote up
/**
 * 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);
}
 
Example 8
Project: rapidminer-studio   File: ExcelResultSetConfiguration.java   View source code 6 votes vote down vote up
/**
 * 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();
	}
}
 
Example 9
Project: rapidminer-studio   File: ExcelResultSetConfiguration.java   View source code 6 votes vote down vote up
/**
 * 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();
	}
}
 
Example 10
Project: NyBatisCore   File: ExcelHandlerJxl.java   View source code 6 votes vote down vote up
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();
            }
        }

    }
 
Example 11
Project: nyla   File: Excel.java   View source code 6 votes vote down vote up
/**
   * 
   * 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);
}


  }
 
Example 12
Project: CS-FileTransfer   File: SyncListIO.java   View source code 6 votes vote down vote up
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
}
 
Example 13
Project: CS-FileTransfer   File: SyncListIO.java   View source code 6 votes vote down vote up
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));
        }
    }
 
Example 14
Project: CS-FileTransfer   File: FileTransferClient.java   View source code 6 votes vote down vote up
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);
}
 
Example 15
Project: hranalyzer   File: DivisionDataImporter.java   View source code 6 votes vote down vote up
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);
        }
    }
}
 
Example 16
Project: hranalyzer   File: DivisionDataImporter.java   View source code 6 votes vote down vote up
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);
        }
    }
}
 
Example 17
Project: hranalyzer   File: ApplicationTests.java   View source code 6 votes vote down vote up
@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();
        //            }
    }

}
 
Example 18
Project: Fast   File: ExcelFactory.java   View source code 6 votes vote down vote up
/**
 * 读取Excel
 * @param path	路径
 * @param model	模型
 * @param index	sheet索引
 * @param row	开始读取行数
 * @return
 * @throws IOException 
 * @throws FileNotFoundException 
 * @throws BiffException 
 */
public static List<?> read(String path,ExcelTemple<?> model,int index,int row) throws BiffException, FileNotFoundException, IOException {
	
	Workbook book = null;
	List<Object> list = null;
	
	try {
		
		book = Workbook.getWorkbook(new FileInputStream(path));
		//list = new ArrayList<Object>();
		Sheet sheet = book.getSheet(index);
		
		int rows = sheet.getRows();
		if(rows>0){
			list = new ArrayList<Object>();
			for(;row<rows;row++){
				list.add(model.readData(sheet.getRow(row)));
			}
		}
		
	}finally{
		if(book!=null)	book.close();
	}
	
	return list;
}
 
Example 19
Project: rapidminer-5   File: ExcelResultSetConfiguration.java   View source code 6 votes vote down vote up
/**
 * Returns the number of sheets in the excel file
 * @return
 * @throws IOException 
 * @throws BiffException 
 * @throws InvalidFormatException 
 */
public int getNumberOfSheets() throws BiffException, IOException, InvalidFormatException {
	if (getFile().getAbsolutePath().endsWith(".xlsx")) {
		// excel 2007 file
		if (workbookPOI == null) {
			createWorkbookPOI();
		}
		return workbookPOI.getNumberOfSheets();
	} else {
		// excel pre 2007 file
		if (workbookJXL == null) {
			createWorkbookJXL();
		}
		return workbookJXL.getNumberOfSheets();
	}
}
 
Example 20
Project: rapidminer-5   File: ExcelResultSetConfiguration.java   View source code 6 votes vote down vote up
/**
 * Returns the names of all sheets in the excel file
 * @return
 * @throws IOException 
 * @throws BiffException 
 * @throws InvalidFormatException 
 */
public String[] getSheetNames() throws BiffException, IOException, InvalidFormatException {
	if (getFile().getAbsolutePath().endsWith(".xlsx")) {
		// excel 2007 file
		if (workbookPOI == null) {
			createWorkbookPOI();
		}
		String[] sheetNames = new String[getNumberOfSheets()];
		for (int i = 0; i < getNumberOfSheets(); i++) {
			sheetNames[i] = workbookPOI.getSheetName(i);
		}
		return sheetNames;
	} else {
		// excel pre 2007 file
		if (workbookJXL == null) {
			createWorkbookJXL();
		}
		return workbookJXL.getSheetNames();
	}
}
 
Example 21
Project: screensaver   File: ICBGReportGenerator.java   View source code 6 votes vote down vote up
public ICBGReportGenerator( String[] args) throws BiffException, IOException
{
   super(args);
   addCommandLineOption(OptionBuilder.hasArg(true).withArgName("mf").withLongOpt("mapping-file")
			.withDescription("The path to the mapping file").create("mf"));    
   addCommandLineOption(OptionBuilder.hasArg(true).withArgName("cf").withLongOpt("assay-category-file")
	 				.withDescription("The path to the assay category file").create("cf"));   
  addCommandLineOption(OptionBuilder.hasArg(true).withArgName("of").withLongOpt("output-file")
					.withDescription("The output file path").create("of"));

  processOptions(true,false);
 
  if(isCommandLineFlagSet("of")) _reportFilename = getCommandLineOptionValue("of");
  _dao = (GenericEntityDAO) getSpringBean("genericEntityDao");
  _screenResultsDAO = (ScreenResultsDAO) getSpringBean("screenResultsDao");
  _mapper = new ICCBLPlateWellToINBioLQMapper(getCommandLineOptionValue("mf"));
  _assayInfoProducer = new AssayInfoProducer(getCommandLineOptionValue("cf"));
}
 
Example 22
Project: bishop-carroll-school-tracker   File: Excel.java   View source code 6 votes vote down vote up
/**
 * Returns the {@link TableModel} representation of an excel file.
 *
 * @param file file to get representation from
 * @return representation of the file
 * @throws IOException thrown when problems occur while converting to
 * {@link TableModel}
 */
public static TableModel getTableModelFrom(File file) throws IOException {
    try {
        Logging.log("Importing table from " + file.getPath());
        Workbook workbook = Workbook.getWorkbook(file);
        final Sheet sheet = workbook.getSheet(0);
        DefaultTableModel model = new DefaultTableModel(sheet.getRows(), sheet.getColumns());
        for (int y = 0; y < sheet.getRows(); y++) {
            for (int x = 0; x < sheet.getColumns(); x++) {
                Cell cell = sheet.getCell(x, y);
                model.setValueAt(cell.getContents(), y, x);
            }
        }
        return model;
    } catch (BiffException | IndexOutOfBoundsException ex) {
        throw new IOException();
    }
}
 
Example 23
Project: bishop-carroll-school-tracker   File: Excel.java   View source code 6 votes vote down vote up
/**
 * Returns the {@link TableModel} representation of an excel file.
 *
 * @param file {@link InputStream} to get representation from
 * @return representation of the file
 * @throws IOException thrown when problems occur while converting to
 * {@link TableModel}
 */
public static TableModel getTableModelFrom(InputStream file) throws IOException {
    try {
        Logging.log("Importing table from input stream");
        Workbook workbook = Workbook.getWorkbook(file);
        final Sheet sheet = workbook.getSheet(0);
        DefaultTableModel model = new DefaultTableModel(sheet.getRows(), sheet.getColumns());
        for (int y = 0; y < sheet.getRows(); y++) {
            for (int x = 0; x < sheet.getColumns(); x++) {
                Cell cell = sheet.getCell(x, y);
                model.setValueAt(cell.getContents(), y, x);
            }
        }
        return model;
    } catch (BiffException | IndexOutOfBoundsException ex) {
        throw new IOException();
    }
}
 
Example 24
Project: brigen-base   File: JxlDelegaterImpl.java   View source code 6 votes vote down vote up
private static void check() {
    try {
        Class.forName(jxl.Cell.class.getName());
        Class.forName(jxl.FormulaCell.class.getName());
        Class.forName(jxl.NumberFormulaCell.class.getName());
        Class.forName(jxl.Workbook.class.getName());
        Class.forName(jxl.WorkbookSettings.class.getName());
        Class.forName(jxl.biff.formula.FormulaException.class.getName());
        Class.forName(jxl.read.biff.BiffException.class.getName());
        Class.forName(jxl.write.Label.class.getName());
        Class.forName(jxl.write.WritableSheet.class.getName());
        Class.forName(jxl.write.WritableWorkbook.class.getName());
        Class.forName(jxl.write.WriteException.class.getName());
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
Example 25
Project: jexcelapi   File: BiffDump.java   View source code 6 votes vote down vote up
/**
 * Constructor
 *
 * @param file the file
 * @param os the output stream
 * @exception IOException 
 * @exception BiffException
 */
public BiffDump(java.io.File file, OutputStream os) 
  throws IOException, BiffException
{
  writer = new BufferedWriter(new OutputStreamWriter(os));
  FileInputStream fis = new FileInputStream(file);
  File f = new File(fis, new WorkbookSettings());
  reader = new BiffRecordReader(f);

  buildNameHash();
  dump();

  writer.flush();
  writer.close();
  fis.close();
}
 
Example 26
Project: jexcelapi   File: ReadWrite.java   View source code 6 votes vote down vote up
/**
 * Reads in the inputFile and creates a writable copy of it called outputFile
 * 
 * @exception IOException 
 * @exception BiffException 
 */
public void readWrite() throws IOException, BiffException, WriteException
{
  logger.info("Reading...");
  Workbook w1 = Workbook.getWorkbook(inputWorkbook);

  logger.info("Copying...");
  WritableWorkbook w2 = Workbook.createWorkbook(outputWorkbook, w1);

  if (inputWorkbook.getName().equals("jxlrwtest.xls"))
  {
    modify(w2);
  }

  w2.write();
  w2.close();
  logger.info("Done");
}
 
Example 27
Project: jexcelapi   File: PropertySetsReader.java   View source code 6 votes vote down vote up
/**
 * Write the property stream to the output stream
 */
void displayPropertySet(String ps, OutputStream os) 
  throws IOException,BiffException
{
  if (ps.equalsIgnoreCase("SummaryInformation"))
  {
    ps = BaseCompoundFile.SUMMARY_INFORMATION_NAME;
  }
  else if (ps.equalsIgnoreCase("DocumentSummaryInformation"))
  {
    ps = BaseCompoundFile.DOCUMENT_SUMMARY_INFORMATION_NAME;
  }
  else if (ps.equalsIgnoreCase("CompObj"))
  {
    ps = BaseCompoundFile.COMP_OBJ_NAME;
  }

  byte[] stream = compoundFile.getStream(ps);
  os.write(stream);
}
 
Example 28
Project: rapidminer   File: ExcelResultSetConfiguration.java   View source code 5 votes vote down vote up
/**
 * Creates the JXL workbook.
 *
 * @throws BiffException
 * @throws IOException
 */
private void createWorkbookJXL() throws BiffException, IOException {
	File file = getFile();
	WorkbookSettings workbookSettings = new WorkbookSettings();
	if (encoding != null) {
		workbookSettings.setEncoding(encoding.name());
	}
	workbookJXL = Workbook.getWorkbook(file, workbookSettings);
}
 
Example 29
Project: Educational-Management-System   File: TeacherGradeController.java   View source code 5 votes vote down vote up
@RequestMapping(value = "/{teacherId}/grade/{openId}/uploadCheck",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
public String uploadGradeCheck(@PathVariable("teacherId") int teacherId, @PathVariable("openId") int openId,
                               @RequestParam("file") MultipartFile file,Model model) throws IOException, BiffException {
    if(file==null) return null;
    Map<String ,Object> map = teacherGradeService.readNetworkExcel(file,openId);
    List<String> errorList = (List<String>)map.get("errorList");
    System.out.println(errorList);
    if(errorList.get(0).equals("OK")){
        model.addAttribute("success","success");
    }else{
        model.addAttribute("error",errorList);
    }
    return "/teacher/teacher_grade_upload";
}
 
Example 30
Project: FacetExtract   File: gLayerMerge.java   View source code 5 votes vote down vote up
public static void main(String[] args)
{
	String oriPath = "M:\\Data mining data set\\Content\\";
	try
	{
		readExcel(oriPath);
	} catch (BiffException | IOException e)
	{
		e.printStackTrace();
	}
	System.out.println("Done.");

}
 
Example 31
Project: FacetExtract   File: hGiveInstinctiveFacets.java   View source code 5 votes vote down vote up
public static void main(String[] args)
{
	String oriPath = "M:\\Data mining data set\\Content\\";
	try
	{
		readExcel(oriPath);
	} catch (BiffException | IOException e)
	{
		e.printStackTrace();
	}
	System.out.println("Done.");

}
 
Example 32
Project: FacetExtract   File: SaveContentAllTopics.java   View source code 5 votes vote down vote up
public static void main(String[] args) throws BiffException, IOException 
	{
		String oriPath = "M:\\我是研究生\\任务\\分面树的生成\\Facet\\";
		String domain = "Data_structure";
//		SaveContantAllTopics(oriPath, domain);
//		wiki(oriPath + "1_origin\\","Vlist");
    }
 
Example 33
Project: FacetExtract   File: hyponymyProc2.java   View source code 5 votes vote down vote up
public static void main(String file_path[]) throws IOException, BiffException, RowsExceededException, WriteException 
{	
	String InputFileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\数据结构上下位关系.xls";
	String OutputfileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\数据结构上下位关系-子连父new.xls";
	hyponymyFilter(InputFileName, OutputfileName);
	System.out.println("done"); 
}
 
Example 34
Project: FacetExtract   File: timesAppearedInExcel.java   View source code 5 votes vote down vote up
public static void main(String[] args)
{
	Workbook wb = null;
	try {
		wb = Workbook.getWorkbook(new File("E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\分面可用验证.xls"));
	} catch (BiffException | IOException e) {
		e.printStackTrace();
	}
	Sheet sheet = wb.getSheet(0); 
	Map<String, Integer> map = new HashMap<String, Integer>(); 
	for (int i = 1; i < sheet.getRows(); i++)
	{
		String str = sheet.getCell(3,i).getContents(); //第几列的值
		if (map.containsKey(str)) 
               map.put(str, map.get(str) + 1);  
           else 
               map.put(str, 1);  
	}
	Set<?> set = map.entrySet();
	for(Iterator<?> iter = set.iterator(); iter.hasNext();)
	{
		Map.Entry entry = (Map.Entry)iter.next();
		String key = (String)entry.getKey();
	    Integer value = (Integer)entry.getValue();
        System.out.println(key + " :\t" + value);
	}
}
 
Example 35
Project: FacetExtract   File: gDBPediaProc.java   View source code 5 votes vote down vote up
public static void main(String[] args) throws IOException, RowsExceededException, BiffException, WriteException
{
	String InputFileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\topicPredicate.xls";
	String OutputFileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\subjectPredicate.xls";
	procExcel(InputFileName, OutputFileName);
	System.out.println("done"); 
}
 
Example 36
Project: FacetExtract   File: TopicNameProcess.java   View source code 5 votes vote down vote up
public static void main(String file_path[]) throws IOException,  BiffException, RowsExceededException, WriteException 
{	
	String InputFileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\Data_structure_topics.xls";
	String OutputFileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\Data_structure_topics_filter.xls";
	readExcel(InputFileName, OutputFileName);
	System.out.println("done"); 
}
 
Example 37
Project: FacetExtract   File: HyponymyExtract.java   View source code 5 votes vote down vote up
public static void main(String[] args) throws IOException, RowsExceededException, BiffException, WriteException
	{
		String oriPath = "E:\\我是研究生\\任务\\分面树的生成\\Content\\";
//		String OutputFileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\hyponymyExtract.xls";
//		hyponymyExtract(oriPath, oriPath + "otherFiles\\hyponymyExtract.xls");
		moveOnceFacet(oriPath + "otherFiles\\hyponymyExtract.xls", oriPath + "otherFiles\\hyponymyExtract_onceFilter.xls");
		System.out.println("done"); 
	}
 
Example 38
Project: FacetExtract   File: hyponymyProc.java   View source code 5 votes vote down vote up
public static void main(String file_path[]) throws IOException, BiffException, RowsExceededException, WriteException 
{	
	String InputFileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\数据结构上下位关系-子连父new.xls";
	String OutputfileName = "E:\\我是研究生\\任务\\分面树的生成\\Content\\otherFiles\\数据结构上下位关系-use.xls";
	hyponymyFilter(InputFileName, OutputfileName);
	System.out.println("done"); 
}
 
Example 39
Project: FacetExtract   File: FindRelationship.java   View source code 5 votes vote down vote up
/**
 * 用于获得一个节点的兄弟,祖先,子节点,并存在一个对象中
 * @param node
 * @return oneNode类
 */
public static oneNode getRelation(String node, String root, String oriPath) {
	Workbook wb;
	ArrayList<String> upLocation = new ArrayList<>();
	ArrayList<String> dnLocation = new ArrayList<>();
	try {//把excel里面的内容存到内存中
           wb = Workbook.getWorkbook(new File(oriPath + "otherFiles\\" + root + "上下位.xls"));
           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();
	}

	oneNode topic = new oneNode();
	if(!NodeExist(upLocation, dnLocation, node))
	{
		System.err.println("所输入的节点不存在。");
		return topic;
	}
	topic.setNodeName(node);
	if (NodeExist(upLocation, dnLocation, root))
		topic.setLayer(findLayer(upLocation, dnLocation, node, root));
	else {
		System.err.println("所输入的根节点不存在。");
		return topic;
	}
	topic.setDisToLeaf(findDistToLeaf(upLocation, dnLocation, node));
	topic.setParentNodes(findParent(upLocation, dnLocation, node));
	topic.setBrotherNodes(findBrother(upLocation, dnLocation, node));
	topic.setChildNodes(findChild(upLocation, dnLocation, node));
	return topic;
}
 
Example 40
Project: lodsve-framework   File: ExcelUtils.java   View source code 5 votes vote down vote up
/**
 * 获取excel文件中的数据对象
 *
 * @param is                        excel
 * @param excelColumnNames          excel中每个字段的英文名(应该与pojo对象的字段名一致,顺序与excel一致)
 * @return                          excel每行是list一条记录,map是对应的"字段名-->值"
 * @throws Exception
 */
public static List<Map<String, String>> getImportData(InputStream is, List<String> excelColumnNames) throws Exception {
    logger.debug("InputStream:{}", is);
    if (is == null) {
        return Collections.emptyList();
    }

    Workbook workbook = null;
    try {
        //拿到excel
        workbook = Workbook.getWorkbook(is);
    } catch (BiffException | IOException e) {
        logger.error(e.getMessage(), e);
        return Collections.emptyList();
    }
    logger.debug("workbook:{}", workbook);

    //第一个sheet
    Sheet sheet = workbook.getSheet(0);
    //行数
    int rowCounts = sheet.getRows() - 1;
    logger.debug("rowCounts:{}", rowCounts);
    List<Map<String, String>> list = new ArrayList<>(rowCounts - 1);

    //双重for循环取出数据
    for(int i = 1; i < rowCounts + 1; i++){
        Map<String, String> params = new HashMap<>(excelColumnNames.size());
        //i,j i:行 j:列
        for(int j = 0; j < excelColumnNames.size(); j++){
            Cell cell = sheet.getCell(j, i);
            params.put(excelColumnNames.get(j), cell.getContents());
        }

        list.add(params);
    }

    return list;
}