本文整理汇总了Java中com.rapidminer.operator.nio.ExcelExampleSource类的典型用法代码示例。如果您正苦于以下问题:Java ExcelExampleSource类的具体用法?Java ExcelExampleSource怎么用?Java ExcelExampleSource使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ExcelExampleSource类属于com.rapidminer.operator.nio包,在下文中一共展示了ExcelExampleSource类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeDataResultSet
import com.rapidminer.operator.nio.ExcelExampleSource; //导入依赖的package包/类
@Override
public DataResultSet makeDataResultSet(Operator operator) throws OperatorException {
if (getFile() == null) {
throw new UserError(operator, 205, ExcelExampleSource.PARAMETER_EXCEL_FILE, "");
}
if (getFile().getAbsolutePath().endsWith(".xlsx")) {
// excel 2007 file
return new Excel2007ResultSet(operator, this);
} else if (getFile().getAbsolutePath().endsWith(".xls")) {
// excel pre 2007 file
return new ExcelResultSet(operator, this);
} else {
// we might also get a file object that has neither .xlsx nor .xls as file ending,
// so we have no choice but to try and open the file with the pre 2007 JXL lib to see if it works.
// If it does not work, it's an excel 2007 file.
try {
Workbook.getWorkbook(getFile());
return new ExcelResultSet(operator, this);
} catch (Exception e) {
return new Excel2007ResultSet(operator, this);
}
}
}
示例2: ExcelResultSetConfiguration
import com.rapidminer.operator.nio.ExcelExampleSource; //导入依赖的package包/类
/**
* This constructor must read in all settings from the parameters of the given operator.
*
* @throws OperatorException
*/
public ExcelResultSetConfiguration(ExcelExampleSource excelExampleSource) throws OperatorException {
if (excelExampleSource.isParameterSet(ExcelExampleSource.PARAMETER_IMPORTED_CELL_RANGE)) {
parseExcelRange(excelExampleSource.getParameterAsString(ExcelExampleSource.PARAMETER_IMPORTED_CELL_RANGE));
}
if (excelExampleSource.isParameterSet(PARAMETER_SHEET_NUMBER)) {
this.sheet = excelExampleSource.getParameterAsInt(PARAMETER_SHEET_NUMBER) - 1;
}
if (excelExampleSource.isFileSpecified()) {
this.workbookFile = excelExampleSource.getSelectedFile();
} else {
String excelParamter;
try {
excelParamter = excelExampleSource.getParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE);
} catch (UndefinedParameterError e) {
excelParamter = null;
}
if (excelParamter != null && !"".equals(excelParamter)) {
File excelFile = new File(excelParamter);
if (excelFile.exists()) {
this.workbookFile = excelFile;
}
}
}
if (excelExampleSource.isParameterSet(AbstractDataResultSetReader.PARAMETER_DATE_FORMAT)) {
datePattern = excelExampleSource.getParameterAsString(AbstractDataResultSetReader.PARAMETER_DATE_FORMAT);
}
if (excelExampleSource.isParameterSet(AbstractDataResultSetReader.PARAMETER_TIME_ZONE)) {
timezone = excelExampleSource.getParameterAsString(AbstractDataResultSetReader.PARAMETER_TIME_ZONE);
}
encoding = Encoding.getEncoding(excelExampleSource);
isEmulatingOldNames = excelExampleSource.getCompatibilityLevel()
.isAtMost(ExcelExampleSource.CHANGE_5_0_11_NAME_SCHEMA);
}
示例3: makeDataResultSet
import com.rapidminer.operator.nio.ExcelExampleSource; //导入依赖的package包/类
/**
* Creates a {@link DataResultSet} based on the current configuration and the provided
* {@link XlsxReadMode}.
*
* @param operator
* the operator to create the {@link DataResultSet} for. Might be {@code null} in
* case no operator is available
* @param readMode
* the read mode
* @param provider
* a {@link DateFormatProvider}, can be {@code null} in which case the date format is
* fixed by the current value of {@link configuration#getDatePattern()}
* @return the created {@link DataResultSet}
* @throws OperatorException
* in case the creation fails because of an invalid configuration
*/
public DataResultSet makeDataResultSet(Operator operator, XlsxReadMode readMode, DateFormatProvider provider)
throws OperatorException {
File file = getFile();
if (file == null) {
throw new UndefinedParameterError(ExcelExampleSource.PARAMETER_EXCEL_FILE, operator);
}
String absolutePath = file.getAbsolutePath();
DataResultSet resultSet;
if (absolutePath.endsWith(XLSX_FILE_ENDING)) {
resultSet = createExcel2007ResultSet(operator, readMode, provider);
} else if (absolutePath.endsWith(XLS_FILE_ENDING)) {
// excel pre 2007 file
resultSet = new ExcelResultSet(operator, this, provider);
} else {
// we might also get a file object that has neither .xlsx nor .xls as file ending,
// so we have no choice but to try and open the file with the pre 2007 JXL lib to
// see if it works. If it does not work, it's an excel 2007 file.
try {
Workbook.getWorkbook(file);
resultSet = new ExcelResultSet(operator, this, provider);
} catch (Exception e) {
resultSet = createExcel2007ResultSet(operator, readMode, provider);
}
}
return resultSet;
}
示例4: setParameters
import com.rapidminer.operator.nio.ExcelExampleSource; //导入依赖的package包/类
@Override
public void setParameters(AbstractDataResultSetReader source) {
String range = Tools.getExcelColumnName(columnOffset) + (rowOffset + 1);
// only add end range to cell range parameter if user has specified it explicitly
if (Integer.MAX_VALUE != columnLast && Integer.MAX_VALUE != rowOffset) {
range += ":" + Tools.getExcelColumnName(columnLast) + (rowLast + 1);
}
source.setParameter(ExcelExampleSource.PARAMETER_IMPORTED_CELL_RANGE, range);
source.setParameter(PARAMETER_SHEET_NUMBER, String.valueOf(sheet + 1));
source.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, workbookFile.getAbsolutePath());
}
示例5: setParameters
import com.rapidminer.operator.nio.ExcelExampleSource; //导入依赖的package包/类
@Override
public void setParameters(AbstractDataResultSetReader source) {
String range = Tools.getExcelColumnName(columnOffset) + (rowOffset + 1) + ":" + Tools.getExcelColumnName(columnLast) + (rowLast + 1);
source.setParameter(ExcelExampleSource.PARAMETER_IMPORTED_CELL_RANGE, range);
source.setParameter(PARAMETER_SHEET_NUMBER, String.valueOf(sheet + 1));
source.setParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE, workbookFile.getAbsolutePath());
}
示例6: ExcelResultSetConfiguration
import com.rapidminer.operator.nio.ExcelExampleSource; //导入依赖的package包/类
/**
* This constructor must read in all settings from the parameters of the given operator.
*
* @throws OperatorException
*/
public ExcelResultSetConfiguration(ExcelExampleSource excelExampleSource) throws OperatorException {
if (excelExampleSource.isParameterSet(ExcelExampleSource.PARAMETER_IMPORTED_CELL_RANGE)) {
parseExcelRange(excelExampleSource.getParameterAsString(ExcelExampleSource.PARAMETER_IMPORTED_CELL_RANGE));
}
// else {
// throw new UserError(null, 205, ExcelExampleSource.PARAMETER_IMPORTED_CELL_RANGE, excelExampleSource.getName());
// }
if (excelExampleSource.isParameterSet(PARAMETER_SHEET_NUMBER)) {
this.sheet = excelExampleSource.getParameterAsInt(PARAMETER_SHEET_NUMBER) - 1;
}
if (excelExampleSource.isFileSpecified()) {
this.workbookFile = excelExampleSource.getSelectedFile();
} else {
String excelParamter;
try {
excelParamter = excelExampleSource.getParameter(ExcelExampleSource.PARAMETER_EXCEL_FILE);
} catch (UndefinedParameterError e) {
excelParamter = null;
}
if (excelParamter != null && !"".equals(excelParamter)) {
File excelFile = new File(excelParamter);
if (excelFile.exists()) {
this.workbookFile = excelFile;
}
}
}
// if (excelExampleSource.isParameterSet(PARAMETER_EXCEL_FILE)) {
// this.workbookFile = excelExampleSource.getParameterAsFile(PARAMETER_EXCEL_FILE);
// }
if (excelExampleSource.isParameterSet(AbstractDataResultSetReader.PARAMETER_DATE_FORMAT)) {
datePattern = excelExampleSource.getParameterAsString(AbstractDataResultSetReader.PARAMETER_DATE_FORMAT);
}
if (excelExampleSource.isParameterSet(AbstractDataResultSetReader.PARAMETER_TIME_ZONE)) {
timezone = excelExampleSource.getParameterAsString(AbstractDataResultSetReader.PARAMETER_TIME_ZONE);
}
encoding = Encoding.getEncoding(excelExampleSource);
isEmulatingOldNames = excelExampleSource.getCompatibilityLevel().isAtMost(ExcelExampleSource.CHANGE_5_0_11_NAME_SCHEMA);
}
示例7: createExcel2007ResultSet
import com.rapidminer.operator.nio.ExcelExampleSource; //导入依赖的package包/类
/**
* Creates a new XLSX DataResultSet for the specified operator.
*
* @param operator
* the operator which is used as error source in case something goes wrong
* @param readMode
* the read mode which should be used to read the file. The read mode defines how
* many lines should actually be read.
* @return the new XLSX DataResultSet
*/
@SuppressWarnings("deprecation")
private DataResultSet createExcel2007ResultSet(Operator operator, XlsxReadMode readMode, DateFormatProvider provider)
throws OperatorException {
if (operator == null || operator.getCompatibilityLevel().isAbove(ExcelExampleSource.CHANGE_6_2_0_OLD_XLSX_IMPORT)) {
return createXLSXResultSet(operator, readMode, provider);
} else {
return new Excel2007ResultSet(operator, this);
}
}