本文整理汇总了Java中org.apache.poi.xssf.streaming.SXSSFCell.setCellValue方法的典型用法代码示例。如果您正苦于以下问题:Java SXSSFCell.setCellValue方法的具体用法?Java SXSSFCell.setCellValue怎么用?Java SXSSFCell.setCellValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xssf.streaming.SXSSFCell
的用法示例。
在下文中一共展示了SXSSFCell.setCellValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SegmentationExcelWriter
import org.apache.poi.xssf.streaming.SXSSFCell; //导入方法依赖的package包/类
/**
* Istanzia oggetto
*
* @param se segment engine
*/
public SegmentationExcelWriter(SegmentEngine se) {
sheetCellIndex = new LinkedHashMap<>();
wb = new SXSSFWorkbook();
sheetResults = wb.createSheet("Results");
headerResults = sheetResults.createRow(0);
SXSSFCell fCell = headerResults.createCell(0);
fCell.setCellValue("File Name");
fCell = headerResults.createCell(1);
fCell.setCellValue("Language");
fCell = headerResults.createCell(2);
fCell.setCellValue("Original Text");
fCell = headerResults.createCell(3);
fCell.setCellValue("KPI");
int idxCell = 4;
for (SegmentConfiguration sc : se.getPatternMatrix()) {
idxCell = createExcelHeader(wb, headerResults, sheetCellIndex, idxCell, "", sc, sheetResults);
}
writeClassificationHeader(wb);
}
示例2: writeLink
import org.apache.poi.xssf.streaming.SXSSFCell; //导入方法依赖的package包/类
@Override
public void writeLink(final String text, final String link)
throws IOException {
final SXSSFCell cell =
(SXSSFCell) this.row.createCell(this.colCount++, CellType.FORMULA);
// final Cell cell = this.row.createCell(this.colCount++);
if (text != null) {
if (link != null) {
cell.setCellFormula("HYPERLINK(\""
+ link.replace("\"", "\"\"") + "\",\"" + text.replace("\"", "\"\"")
+ "\")");
cell.setCellStyle(this.linkStyle);
}
cell.setCellValue(text);
}
}
示例3: createSegmentHeader
import org.apache.poi.xssf.streaming.SXSSFCell; //导入方法依赖的package包/类
private int createSegmentHeader(SXSSFRow headerResults, Map<String, Integer> cellIndex, int idxCell, SegmentConfiguration sc, String segmentName) {
SXSSFCell scell = headerResults.createCell(idxCell);
scell.setCellValue(segmentName);
cellIndex.put("SEGMENT." + segmentName, idxCell);
idxCell++;
List<CaptureConfiguration> captureConfigurations = sc.getCaptureConfigurations();
List<CaptureConfiguration> segmentCaptureConfigurations = sc.getSentenceCaptureConfigurations();
idxCell = getCapturesHeader(headerResults, cellIndex, idxCell, segmentName, captureConfigurations, segmentCaptureConfigurations);
return idxCell;
}
示例4: generateTitleRow
import org.apache.poi.xssf.streaming.SXSSFCell; //导入方法依赖的package包/类
/**
* 生成标题行
*
* @author nan.li
* @param sheet
* @param titles
* @param object
*/
private static void generateTitleRow(SXSSFSheet sheet, String[] titles, CellStyle cellStyle)
{
SXSSFRow row = sheet.createRow(0);
for (int i = 0; i < titles.length; i++)
{
SXSSFCell cell = row.createCell(i);
cell.setCellStyle(cellStyle);// 设置元素的风格
cell.setCellValue(titles[i]);
}
}
示例5: write
import org.apache.poi.xssf.streaming.SXSSFCell; //导入方法依赖的package包/类
@Override
public void write(Object newDAO) throws OfficeWriterException {
SpreadSheetCellDAO sscd = MSExcelWriter.checkSpreadSheetCellDAO(newDAO);
String safeSheetName=WorkbookUtil.createSafeSheetName(sscd.getSheetName());
SXSSFSheet currentSheet=this.currentWorkbook.getSheet(safeSheetName);
if (currentSheet==null) {// create sheet if it does not exist yet
currentSheet=this.currentWorkbook.createSheet(safeSheetName);
if (!(safeSheetName.equals(sscd.getSheetName()))) {
LOG.warn("Sheetname modified from \""+sscd.getSheetName()+"\" to \""+safeSheetName+"\" to correspond to Excel conventions.");
}
// create drawing anchor (needed for comments...)
this.mappedDrawings.put(safeSheetName,currentSheet.createDrawingPatriarch());
}
// check if cell exist
CellAddress currentCA = new CellAddress(sscd.getAddress());
SXSSFRow currentRow = currentSheet.getRow(currentCA.getRow());
if (currentRow==null) { // row does not exist? => create it
currentRow=currentSheet.createRow(currentCA.getRow());
}
SXSSFCell currentCell = currentRow.getCell(currentCA.getColumn());
if ((currentCell!=null)) { // cell already exists and no template loaded ? => throw exception
throw new OfficeWriterException("Invalid cell specification: cell already exists at "+currentCA);
}
// create cell if no template is loaded or cell not available in template
currentCell=currentRow.createCell(currentCA.getColumn());
// set the values accordingly
if (!("".equals(sscd.getFormula()))) { // if formula exists then use formula
currentCell.setCellFormula(sscd.getFormula());
} else {
// else use formattedValue
currentCell.setCellValue(sscd.getFormattedValue());
}
// set comment
if ((sscd.getComment()!=null) && (!("".equals(sscd.getComment())))) {
/** the following operations are necessary to create comments **/
/** Define size of the comment window **/
ClientAnchor anchor = this.currentWorkbook.getCreationHelper().createClientAnchor();
anchor.setCol1(currentCell.getColumnIndex());
anchor.setCol2(currentCell.getColumnIndex()+this.howc.getCommentWidth());
anchor.setRow1(currentRow.getRowNum());
anchor.setRow2(currentRow.getRowNum()+this.howc.getCommentHeight());
/** create comment **/
Comment currentComment = mappedDrawings.get(safeSheetName).createCellComment(anchor);
currentComment.setString(this.currentWorkbook.getCreationHelper().createRichTextString(sscd.getComment()));
currentComment.setAuthor(this.howc.getCommentAuthor());
currentCell.setCellComment(currentComment);
}
}