本文整理汇总了Java中org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator类的典型用法代码示例。如果您正苦于以下问题:Java XSSFFormulaEvaluator类的具体用法?Java XSSFFormulaEvaluator怎么用?Java XSSFFormulaEvaluator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XSSFFormulaEvaluator类属于org.apache.poi.xssf.usermodel包,在下文中一共展示了XSSFFormulaEvaluator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: generateReport
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; //导入依赖的package包/类
@Override
public void generateReport(ReportConfig reportConfig) throws ReportGenerationException {
try {
LOGGER.info("starting report generation");
long start = System.currentTimeMillis();
LOGGER.debug("using config: " + reportConfig);
Workbook workbook = getWorkbook(reportConfig);
workbookPopulator.populateWorkbookWithData(reportConfig, workbook);
LOGGER.info("updating formulas");
XSSFFormulaEvaluator.evaluateAllFormulaCells((XSSFWorkbook) workbook);
FileOutputStream fileOut = new FileOutputStream(reportConfig.getDestinationFile());
workbook.write(fileOut);
fileOut.close();
String timeTaken = new SimpleDateFormat("mm:ss").format(new Date(System.currentTimeMillis() - start));
LOGGER.info("report successfully generated in " + timeTaken);
} catch (IOException | InvalidFormatException e ) {
LOGGER.error("unabe to generate report!");
throw new ReportGenerationException(e);
}
}
开发者ID:SumoLogic,项目名称:sumo-report-generator,代码行数:21,代码来源:ExcelReportGenerator.java
示例2: loadExcelTypeXLSX
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; //导入依赖的package包/类
public void loadExcelTypeXLSX(File f){
final File f1 = f;
new Thread(){
File f = f1;
public void run(){
int length = (int)f.length();
JDialog d = new JDialog((Frame)null, "Loading File");
JPanel p = new JPanel(new BorderLayout());
p.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
d.setLocationRelativeTo(null);
JProgressBar pb = new JProgressBar(0,length);
p.add(new JLabel("Loading " + (length / 1000) + " kb file"), BorderLayout.NORTH);
p.add(pb);
d.getContentPane().add(p);
d.pack();
d.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
d.setVisible(true);
d.setAlwaysOnTop(true);
//String excelPath = f1.getPath();
//XSSFWorkbook workbook = new XSSFWorkbook(excelPath);
omitCount = 0;
try {
FileInputStream fis = new FileInputStream(f);
XSSFWorkbook workbook = new XSSFWorkbook(fis);
if (workbook.getNumberOfSheets()<0) {return;}
//System.out.println(workbook.getNumberOfSheets());
StringBuffer sb2 = new StringBuffer();
if(workbook.getSheetAt(0) != null){
String sheetname = workbook.getSheetName(0);
// XSSFExcelExtractor extract = null;
XSSFSheet worksheet = workbook.getSheetAt(0);
// Check the columns usually first row of titles for columns. Just incase check next row.
int numCol = worksheet.getRow(0).getLastCellNum();
int numCol1 = worksheet.getRow(1).getLastCellNum();
if (numCol1 > numCol) {
numCol = numCol1;
}
XSSFFormulaEvaluator formulaEvaluator = new XSSFFormulaEvaluator(workbook);
for (int i = 0; i < worksheet.getLastRowNum()+1; i++) {
for (int j = 0; j < numCol; j++){
formulaEvaluator.evaluateInCell(worksheet.getRow(i).getCell(j));
sb2.append(worksheet.getRow(i).getCell(j) + "\t");
pb.setValue(pb.getValue()+ (((""+worksheet.getRow(i).getCell(j)).length()*2) + 38));
pb.repaint();
}
sb2.append("\n");
try {
if(worksheet.getRow(i).getCell(0).getStringCellValue().startsWith("#")) {
omitCount ++;
}
} catch (IllegalStateException ix) {}
//System.out.println(worksheet.getRow(1).getCell(1)+ " R " + worksheet.getLastRowNum() + " c " + worksheet.getRow(1).getLastCellNum());
//String excelText = extract.getText().replaceFirst(sheetname+"\n", "");
//input.setText(excelText);
}
name.setText(f.getName().substring(0, f.getName().lastIndexOf('.')));
//System.out.println(sb2.toString());
input.setText(sb2.toString());
System.out.println("Detected " + omitCount + " commented row(s). Commented data rows will not be plotted.");
detectMessage.setText("<html>Detected <b>" + omitCount + " </b> commented row(s).<br>Commented data rows <b>will not</b> be plotted.<br>Click Refresh to view updated count.</html>");
pack();
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
d.dispose();
System.out.println("data ready");
}
}.start();
}
开发者ID:iedadata,项目名称:geomapapp,代码行数:79,代码来源:DBInputDialog.java
示例3: asTable
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; //导入依赖的package包/类
@Documentation(
value = "Insert a table from an Excel .xlsx file.",
params = {
@Param(name = "uri", value = "The Excel .xlsx file uri, it can be relative to the template"),
@Param(name = "sheetName", value = "The sheet name"),
@Param(name = "topLeftCellAdress", value = "The top left cell address"),
@Param(name = "bottomRightCellAdress", value = "The bottom right cell address"),
@Param(name = "languageTag", value = "The language tag for the locale"),
},
result = "insert the table",
examples = {
@Example(expression = "'excel.xlsx'.asTable('Feuil1', 'C3', 'F7', 'fr-FR')", result = "insert the table from 'excel.xlsx'"),
}
)
// @formatter:on
public MTable asTable(String uriStr, String sheetName, String topLeftCellAdress, String bottomRightCellAdress,
String languageTag) throws IOException {
final MTable res = new MTableImpl();
final URI xlsxURI = URI.createURI(uriStr, false);
final URI uri = xlsxURI.resolve(templateURI);
try (XSSFWorkbook workbook = new XSSFWorkbook(uriConverter.createInputStream(uri));) {
final FormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook);
final XSSFSheet sheet = workbook.getSheet(sheetName);
if (sheet == null) {
throw new IllegalArgumentException(String.format("The sheet %s doesn't exists in %s.", sheetName, uri));
} else {
final Locale locale;
if (languageTag != null) {
locale = Locale.forLanguageTag(languageTag);
} else {
locale = Locale.getDefault();
}
final DataFormatter dataFormatter = new DataFormatter(locale);
final CellAddress start = new CellAddress(topLeftCellAdress);
final CellAddress end = new CellAddress(bottomRightCellAdress);
int rowIndex = start.getRow();
while (rowIndex <= end.getRow()) {
final XSSFRow row = sheet.getRow(rowIndex++);
if (row != null) {
final MRow mRow = new MRowImpl();
int cellIndex = start.getColumn();
while (cellIndex <= end.getColumn()) {
final XSSFCell cell = row.getCell(cellIndex++);
if (cell != null) {
final MStyle style = getStyle(cell);
final MElement text = new MTextImpl(dataFormatter.formatCellValue(cell, evaluator),
style);
final Color background = getColor(cell.getCellStyle().getFillForegroundColorColor());
final MCell mCell = new MCellImpl(text, background);
mRow.getCells().add(mCell);
} else {
mRow.getCells().add(createEmptyCell());
}
}
res.getRows().add(mRow);
} else {
final int length = end.getColumn() - start.getColumn() + 1;
res.getRows().add(createEmptyRow(length));
}
}
}
}
return res;
}
开发者ID:ObeoNetwork,项目名称:M2Doc,代码行数:69,代码来源:ExcelServices.java
示例4: ExcelFormulaEvaluator
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; //导入依赖的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
示例5: initWorkbook
import org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator; //导入依赖的package包/类
private void initWorkbook(InputStream in) throws IOException {
XSSFWorkbook workbook = new XSSFWorkbook(in);
XSSFFormulaEvaluator evaluator = new XSSFFormulaEvaluator(workbook);
evaluator.setIgnoreMissingWorkbooks(true);
init(workbook, evaluator);
}
开发者ID:uq-eresearch,项目名称:aorra,代码行数:7,代码来源:XlsxDataSource.java
注:本文中的org.apache.poi.xssf.usermodel.XSSFFormulaEvaluator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论