本文整理汇总了Java中org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator类的典型用法代码示例。如果您正苦于以下问题:Java HSSFFormulaEvaluator类的具体用法?Java HSSFFormulaEvaluator怎么用?Java HSSFFormulaEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HSSFFormulaEvaluator类属于org.apache.poi.hssf.usermodel包,在下文中一共展示了HSSFFormulaEvaluator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parsePlanungSheet
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; //导入依赖的package包/类
public List<String> parsePlanungSheet(final HSSFWorkbook wb) throws ParserException {
// ExcelService anlegen
this.exlSv = new ExcelOutputService(wb);
// Parameter pruefen
if (wb == null) {
throw new IllegalArgumentException("Workbook must not be null");
}
List<String> lines = new ArrayList<String>();
// Betreffendes Sheet anhand des Indexes ermitteln (funkt. auch noch
// wenn mal das Tabellenblatt umbenannt wird)
HSSFSheet sheet = null;
sheet = wb.getSheet(ExcelNodeService.CONST_SHEETNNAME_PLANUNG);
if (sheet == null) {
sheet = wb.createSheet(ExcelNodeService.CONST_SHEETNNAME_PLANUNG);
}
// alle Formeln berechnen
@SuppressWarnings("deprecation")
HSSFFormulaEvaluator formulaEval = new HSSFFormulaEvaluator(sheet, wb);
int startRownNum = ExcelNodeService.CONST_PLANUNG_ROUW_UE;
// Ue;
startRownNum++;
for (int rowNum = startRownNum; rowNum <= sheet.getLastRowNum(); rowNum++) {
String line = this.parsePlanungLine(sheet, formulaEval, rowNum);
if (line != null) {
lines.add(line);
}
}
return lines;
}
开发者ID:das-praktische-schreinerlein,项目名称:your-all-in-one,代码行数:36,代码来源:ExcelImporter.java
示例2: XlsDataSource
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; //导入依赖的package包/类
public XlsDataSource(InputStream in) throws IOException {
HSSFWorkbook workbook = new HSSFWorkbook(in);
HSSFFormulaEvaluator evaluator = workbook.getCreationHelper()
.createFormulaEvaluator();
evaluator.setIgnoreMissingWorkbooks(true);
init(workbook, evaluator);
}
开发者ID:uq-eresearch,项目名称:aorra,代码行数:8,代码来源:XlsDataSource.java
示例3: ExcelFormulaEvaluator
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; //导入依赖的package包/类
public ExcelFormulaEvaluator (@Nonnull final Workbook aWB, @Nullable final IStabilityClassifier aStability)
{
m_aEvaluator = aWB instanceof HSSFWorkbook ? new HSSFFormulaEvaluator ((HSSFWorkbook) aWB, aStability)
: XSSFFormulaEvaluator.create ((XSSFWorkbook) aWB, aStability, null);
}
开发者ID:phax,项目名称:ph-poi,代码行数:6,代码来源:ExcelFormulaEvaluator.java
示例4: parseXLS
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; //导入依赖的package包/类
public JSONObject parseXLS(String filename, int sheetNo) throws FileNotFoundException, IOException, JSONException{
JSONObject jobj=new JSONObject();
POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream(filename));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
HSSFSheet sheet = wb.getSheetAt(sheetNo);
int startRow=0;
int maxRow=sheet.getLastRowNum();
int maxCol=0;
int noOfRowsDisplayforSample = 20;
if(noOfRowsDisplayforSample > sheet.getLastRowNum()){
noOfRowsDisplayforSample = sheet.getLastRowNum();
}
JSONArray jArr=new JSONArray();
try {
for(int i=0;i <= noOfRowsDisplayforSample;i++) {
HSSFRow row = sheet.getRow(i);
JSONObject obj=new JSONObject();
JSONObject jtemp1 = new JSONObject();
if(row==null){
continue;
}
if(i==0) {
maxCol=row.getLastCellNum();
}
for(int cellcount=0; cellcount<maxCol; cellcount++){
HSSFCell cell = row.getCell(cellcount);
CellReference cref = new CellReference(i, cellcount);
String colHeader=cref.getCellRefParts()[2];
String val=null;
if(cell!=null){
switch(cell.getCellType()){
case HSSFCell.CELL_TYPE_NUMERIC:
if(HSSFDateUtil.isCellDateFormatted(cell)){
val=Double.toString(cell.getNumericCellValue());
java.util.Date date1 = HSSFDateUtil.getJavaDate(Double.parseDouble(val));
DateFormat sdf = new SimpleDateFormat(df);
val = sdf.format(date1);
}else{
val=dfmt.format(cell.getNumericCellValue());
}
break;
case HSSFCell.CELL_TYPE_STRING: val=cleanHTML(cell.getRichStringCellValue().getString()); break;
}
}
if(i==0){ // List of Headers (Consider first row as Headers)
if(val!=null){
jtemp1 = new JSONObject();
jtemp1.put("header", val==null?"":val);
jtemp1.put("index", cellcount);
jobj.append("Header", jtemp1);
}
}
obj.put(colHeader,val);
}
// if(obj.length()>0){ //Don't show blank row in preview grid[SK]
jArr.put(obj);
// }
}
} catch(Exception ex) {
Logger.getLogger(ImportHandler.class.getName()).log(Level.SEVERE, null, ex);
}
jobj.put("startrow", startRow);
jobj.put("maxrow", maxRow);
jobj.put("maxcol", maxCol);
jobj.put("index", sheetNo);
jobj.put("data", jArr);
jobj.put("filename", filename);
jobj.put("msg", "XLS has been successfully uploaded");
jobj.put("lsuccess", true);
jobj.put("valid", true);
return jobj;
}
开发者ID:mobilipia,项目名称:Deskera-HRMS,代码行数:79,代码来源:ImportHandler.java
示例5: parseXLS1
import org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator; //导入依赖的package包/类
public JSONObject parseXLS1(String filename, int sheetNo,int startindex) throws FileNotFoundException, IOException, JSONException{
JSONObject jobj=new JSONObject();
POIFSFileSystem fs =
new POIFSFileSystem(new FileInputStream(filename));
HSSFWorkbook wb = new HSSFWorkbook(fs);
HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(wb);
HSSFSheet sheet = wb.getSheetAt(sheetNo);
ArrayList<String> arr = new ArrayList<String>();
int startRow=0;
int maxRow=sheet.getLastRowNum();
int maxCol=0;
JSONArray jArr=new JSONArray();
try {
for(int i=startindex;i<=sheet.getLastRowNum();i++) {
HSSFRow row = sheet.getRow(i);
JSONObject obj=new JSONObject();
JSONObject jtemp1 = new JSONObject();
if(row==null){
continue;
}
if(i==startindex){
maxCol=row.getLastCellNum();
}
for(int j=0; j<maxCol; j++){
HSSFCell cell = row.getCell(j);
String val=null;
if(cell==null){
arr.add(val);
continue;
};
String colHeader=new CellReference(i, j).getCellRefParts()[2];
switch(cell.getCellType()){
case HSSFCell.CELL_TYPE_NUMERIC:
if(HSSFDateUtil.isCellDateFormatted(cell)){
val=Double.toString(cell.getNumericCellValue());
java.util.Date date1 = HSSFDateUtil.getJavaDate(Double.parseDouble(val));
DateFormat sdf = new SimpleDateFormat(df);
val = sdf.format(date1);
}else{
val=dfmt.format(cell.getNumericCellValue());
}
break;
case HSSFCell.CELL_TYPE_STRING: val=cleanHTML(cell.getRichStringCellValue().getString()); break;
}
if(i==startindex){ // List of Headers (consider startindex row as a headers)
if(val!=null){
jtemp1 = new JSONObject();
jtemp1.put("header", val);
jtemp1.put("index", j);
jobj.append("Header", jtemp1);
obj.put(colHeader,val);
}
arr.add(val);
} else {
if(arr.get(j)!=null)
obj.put(arr.get(j),val);
}
}
if(obj.length()>0){
jArr.put(obj);
}
}
} catch(Exception ex) {
Logger.getLogger(ImportHandler.class.getName()).log(Level.SEVERE, null, ex);
}
jobj.put("startrow", startRow);
jobj.put("maxrow", maxRow);
jobj.put("maxcol", maxCol);
jobj.put("index", sheetNo);
jobj.put("data", jArr);
jobj.put("filename", filename);
jobj.put("msg", "XLS has been successfully uploaded");
jobj.put("lsuccess", true);
jobj.put("valid", true);
return jobj;
}
开发者ID:mobilipia,项目名称:Deskera-HRMS,代码行数:81,代码来源:ImportHandler.java
注:本文中的org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论