本文整理了Java中org.apache.poi.hssf.usermodel.HSSFWorkbook.getCreationHelper()
方法的一些代码示例,展示了HSSFWorkbook.getCreationHelper()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFWorkbook.getCreationHelper()
方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFWorkbook
类名称:HSSFWorkbook
方法名:getCreationHelper
暂无
代码示例来源:origin: stackoverflow.com
HSSFWorkbook book;
HSSFSheet sheet;
HSSFRow row;
CreationHelper createHelper = book.getCreationHelper();
代码示例来源:origin: youseries/ureport
private void doProduce(Report report, OutputStream outputStream,boolean withPaging,boolean withSheet) {
CellStyleContext cellStyleContext=new CellStyleContext();
HSSFWorkbook wb = new HSSFWorkbook();
CreationHelper creationHelper=wb.getCreationHelper();
Paper paper=report.getPaper();
代码示例来源:origin: stackoverflow.com
public static void main(String[] args) {
try {
FileOutputStream fileOut = new FileOutputStream("poi-test.xls");
HSSFWorkbook workbook = new HSSFWorkbook();
CreationHelper createHelper = workbook.getCreationHelper();
HSSFSheet worksheet = workbook.createSheet("POI Worksheet");
for(int i=0; i<20000; i++) {
Row row = worksheet.createRow(i);
row.createCell(0).setCellValue(createHelper.createRichTextString("row " + i));
}
fileOut.flush();
workbook.write(fileOut);
fileOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
代码示例来源:origin: stackoverflow.com
HSSFWorkbook wb = new HSSFWorkbook();
HSSFRow row = wb.createSheet().createRow(0);
CellStyle cellStyle = wb.createCellStyle();
cellStyle.setDataFormat(wb.getCreationHelper().createDataFormat().getFormat("HH:mm:ss"));
HSSFCell cell = row.createCell(1);
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, 1970);
cal.set(Calendar.MONTH, 0);
cal.set(Calendar.DATE, 1);
//you can set the time you need here ...
cell.setCellValue(cal);
cell.setCellStyle(cellStyle);
代码示例来源:origin: bedatadriven/activityinfo
public XlsFormBuilder(FormClassProvider formClassProvider) {
this.formClassProvider = formClassProvider;
book = new HSSFWorkbook();
creationHelper = book.getCreationHelper();
surveySheet = book.createSheet("survey");
choicesSheet = book.createSheet("choices");
addSurveySheetHeaders();
addChoiceSheetHeaders();
nextFieldRow = 1;
nextChoiceRow = 1;
}
代码示例来源:origin: stackoverflow.com
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
HSSFSheet sheet = workbook.getSheetAt(0);
Row row = sheet.getRow(2);
代码示例来源:origin: stackoverflow.com
HSSFWorkbook book = new HSSFWorkbook(myxls);
FormulaEvaluator eval =
book.getCreationHelper().createFormulaEvaluator();
HSSFSheet sheet = book.getSheetAt(0);
for (Row row : sheet) {
代码示例来源:origin: stackoverflow.com
HSSFSheet sheet = workbook.getSheetAt(0);
FormulaEvaluator formulaEval =
workbook.getCreationHelper().createFormulaEvaluator();
int rowEnd = sheet.getLastRowNum();
int rowStart = sheet.getFirstRowNum();
代码示例来源:origin: stackoverflow.com
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
代码示例来源:origin: stackoverflow.com
HSSFWorkbook objWorkbook = new HSSFWorkbook(xlsfile);
Sheet sheet = objWorkbook.getSheetAt(0);
FormulaEvaluator evaluator = objWorkbook.getCreationHelper().createFormulaEvaluator();
代码示例来源:origin: bedatadriven/activityinfo
private void writeHeaders(HSSFSheet sheet, String title, List<XlsColumn> columns) {
Cell titleCell = sheet.createRow(0).createCell(0);
titleCell.setCellValue(book.getCreationHelper().createRichTextString(title));
titleCell.setCellStyle(titleStyle);
Row columnHeaderRow = sheet.createRow(1);
columnHeaderRow.setHeightInPoints(HEADER_CELL_HEIGHT);
int columnIndex = 0;
for (int i = 0; i < columns.size(); i++) {
XlsColumn column = columns.get(i);
Cell cell = columnHeaderRow.createCell(columnIndex);
cell.setCellStyle(headerStyle);
cell.setCellValue(column.getHeading());
sheet.setColumnWidth(columnIndex, width(column.getHeading()));
columnIndex++;
}
}
代码示例来源:origin: stackoverflow.com
public static void triggerFormula(HSSFWorkbook workbook){
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
HSSFSheet sheet = workbook.getSheetAt(0);
int lastRowNo=sheet.getLastRowNum();
for(int rownum=0;rownum<=lastRowNo;rownum++){
Row row;
if (sheet.getRow(rownum)!=null){
row= sheet.getRow(rownum);
int lastCellNo=row.getLastCellNum();
for(int cellnum=0;cellnum<lastCellNo;cellnum++){
Cell cell;
if(row.getCell(cellnum)!=null){
cell = row.getCell(cellnum);
if(Cell.CELL_TYPE_FORMULA==cell.getCellType()){
evaluator.evaluateFormulaCell(cell);
}
}
}
}
}
}
代码示例来源:origin: qcadoo/mes
private void createHeaderLineForProduction(final HSSFSheet sheet, final Locale locale, final HSSFRow headerMainLine,
final HSSFRow headerProduction, final PPSReportXlsStyleContainer styleContainer, List<ReportColumn> columns) {
CreationHelper helper = sheet.getWorkbook().getCreationHelper();
helper.createDataFormat();
appendHeaderMainLine(sheet, locale, headerMainLine, styleContainer);
int columnNumber = 0;
for (ReportColumn column : columns) {
HSSFCell cell = headerProduction.createCell(columnNumber);
cell.setCellValue(column.getHeader(locale));
column.setHeaderStyle(cell, styleContainer);
columnNumber++;
}
headerProduction.setHeightInPoints(20);
mergeHeaderCells(sheet, columns.size());
}
代码示例来源:origin: stackoverflow.com
CreationHelper ch = wb.getCreationHelper();
ClientAnchor anchor = ch.createClientAnchor();
anchor.setCol1(2);
代码示例来源:origin: com.haulmont.yarg/yarg
@Override
public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) {
try {
Image image = new Image(paramValue, paramsMatcher);
if (image.isValid()) {
HSSFSheet sheet = resultCell.getSheet();
HSSFWorkbook workbook = sheet.getWorkbook();
int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG);
CreationHelper helper = workbook.getCreationHelper();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(resultCell.getColumnIndex());
anchor.setRow1(resultCell.getRowIndex());
anchor.setCol2(resultCell.getColumnIndex());
anchor.setRow2(resultCell.getRowIndex());
if (patriarch == null) {
throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName()));
}
HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx);
Dimension size = ImageUtils.getDimensionFromAnchor(picture);
double actualHeight = size.getHeight() / EMU_PER_PIXEL;
double actualWidth = size.getWidth() / EMU_PER_PIXEL;
picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight);
}
} catch (IllegalArgumentException e) {
throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e);
}
}
代码示例来源:origin: EaseTech/easytest-core
/**
* Evaluate if the cell contains the formula
*
* @param workbook the workbook that contains the cell
* @param cell the cell that contains the formula
* @return the object representation of formula cell value.
*/
private Object evaluateCellFormula(final HSSFWorkbook workbook, final Cell cell) {
FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
CellValue cellValue = evaluator.evaluate(cell);
Object result = null;
if (cellValue.getCellType() == Cell.CELL_TYPE_BOOLEAN) {
result = cellValue.getBooleanValue();
} else if (cellValue.getCellType() == Cell.CELL_TYPE_NUMERIC) {
result = cellValue.getNumberValue();
} else if (cellValue.getCellType() == Cell.CELL_TYPE_STRING) {
result = cellValue.getStringValue();
}
return result;
}
代码示例来源:origin: cuba-platform/yarg
@Override
public void inlineToXls(HSSFPatriarch patriarch, HSSFCell resultCell, Object paramValue, Matcher paramsMatcher) {
try {
Image image = new Image(paramValue, paramsMatcher);
if (image.isValid()) {
HSSFSheet sheet = resultCell.getSheet();
HSSFWorkbook workbook = sheet.getWorkbook();
int pictureIdx = workbook.addPicture(image.imageContent, Workbook.PICTURE_TYPE_JPEG);
CreationHelper helper = workbook.getCreationHelper();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(resultCell.getColumnIndex());
anchor.setRow1(resultCell.getRowIndex());
anchor.setCol2(resultCell.getColumnIndex());
anchor.setRow2(resultCell.getRowIndex());
if (patriarch == null) {
throw new IllegalArgumentException(String.format("No HSSFPatriarch object provided. Charts on this sheet could cause this effect. Please check sheet %s", resultCell.getSheet().getSheetName()));
}
HSSFPicture picture = patriarch.createPicture(anchor, pictureIdx);
Dimension size = ImageUtils.getDimensionFromAnchor(picture);
double actualHeight = size.getHeight() / EMU_PER_PIXEL;
double actualWidth = size.getWidth() / EMU_PER_PIXEL;
picture.resize((double) image.width / actualWidth, (double) image.height / actualHeight);
}
} catch (IllegalArgumentException e) {
throw new ReportFormattingException("An error occurred while inserting bitmap to xls file", e);
}
}
代码示例来源:origin: org.apache.poi/poi-examples
public static void main(String[] args) throws IOException {
try (HSSFWorkbook wb = new HSSFWorkbook()) {
HSSFCreationHelper helper = wb.getCreationHelper();
代码示例来源:origin: cuba-platform/yarg
newStyle.setVerticalAlignment(cellStyle.getVerticalAlignmentEnum());
DataFormat dataFormat = resultWorkbook.getCreationHelper().createDataFormat();
newStyle.setDataFormat(dataFormat.getFormat(cellStyle.getDataFormatString()));
newStyle.setHidden(cellStyle.getHidden());
代码示例来源:origin: com.haulmont.yarg/yarg
newStyle.setVerticalAlignment(cellStyle.getVerticalAlignment());
DataFormat dataFormat = resultWorkbook.getCreationHelper().createDataFormat();
newStyle.setDataFormat(dataFormat.getFormat(cellStyle.getDataFormatString()));
newStyle.setHidden(cellStyle.getHidden());
内容来源于网络,如有侵权,请联系作者删除!