本文整理汇总了Java中org.apache.poi.xssf.streaming.SXSSFSheet.createRow方法的典型用法代码示例。如果您正苦于以下问题:Java SXSSFSheet.createRow方法的具体用法?Java SXSSFSheet.createRow怎么用?Java SXSSFSheet.createRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.xssf.streaming.SXSSFSheet
的用法示例。
在下文中一共展示了SXSSFSheet.createRow方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTitleRow
import org.apache.poi.xssf.streaming.SXSSFSheet; //导入方法依赖的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]);
}
}
示例2: writeClassificationHeader
import org.apache.poi.xssf.streaming.SXSSFSheet; //导入方法依赖的package包/类
private static void writeClassificationHeader(SXSSFWorkbook workbook) {
SXSSFSheet sheet = workbook.createSheet("Bayes");
Row header = sheet.createRow(0);
header.createCell(0).setCellValue("File");
header.createCell(1).setCellValue("Text");
header.createCell(2).setCellValue("1st Level1");
header.createCell(3).setCellValue("1st Score1");
header.createCell(4).setCellValue("1st Level2");
header.createCell(5).setCellValue("1st Score2");
header.createCell(6).setCellValue("1st Level3");
header.createCell(7).setCellValue("1st Score3");
header.createCell(8).setCellValue("1st Level4");
header.createCell(9).setCellValue("1st Score4");
header.createCell(10).setCellValue("1st Level5");
header.createCell(11).setCellValue("1st Score5");
header.createCell(12).setCellValue("1st Level6");
header.createCell(13).setCellValue("1st Score7");
header.createCell(14).setCellValue("2nd Level1");
header.createCell(15).setCellValue("2nd Score1");
header.createCell(16).setCellValue("2nd Level2");
header.createCell(17).setCellValue("2nd Score2");
header.createCell(18).setCellValue("2nd Level3");
header.createCell(19).setCellValue("2nd Score3");
header.createCell(20).setCellValue("2nd Level4");
header.createCell(21).setCellValue("2nd Score4");
header.createCell(22).setCellValue("2nd Level5");
header.createCell(23).setCellValue("2nd Score5");
header.createCell(24).setCellValue("2nd Level6");
header.createCell(25).setCellValue("2nd Score6");
}
示例3: newSXSSFRow
import org.apache.poi.xssf.streaming.SXSSFSheet; //导入方法依赖的package包/类
public static SXSSFRow newSXSSFRow(SXSSFSheet sheet,int index) {
return (SXSSFRow) sheet.createRow(index);
}
示例4: write
import org.apache.poi.xssf.streaming.SXSSFSheet; //导入方法依赖的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);
}
}
示例5: getDocumentsExcel
import org.apache.poi.xssf.streaming.SXSSFSheet; //导入方法依赖的package包/类
/**
* Popola un excel con il contenuto dell'indice
*
* @since 1.2
* @param language lingua indice
* @param sheetResults excel da popolare
* @param c1 valori della colonna kpi1
* @param c2 valori della colonna kpi2
*/
public void getDocumentsExcel(String language, SXSSFSheet sheetResults, HashMap<String, String> c1, HashMap<String, String> c2) {
try {
int rownum = 1;
String index = getIndexFolder(language);
IndexReader reader = DirectoryReader.open(getFolderDir(index));
final LeafReader ar = SlowCompositeReaderWrapper.wrap(reader);
Bits liveDocs = MultiFields.getLiveDocs(reader);
final int maxdoc = reader.maxDoc();
for (int i = 0; i < maxdoc; i++) {
if (liveDocs != null && !liveDocs.get(i)) {
continue;
}
Document doc = ar.document(i);
SXSSFRow row = sheetResults.createRow(rownum++);
String text = doc.get(IndexManager.TEXT);
if (text == null) {
text = "";
}
row.createCell(6).setCellValue(text);
row.createCell(7).setCellValue(doc.get(IndexManager.BODY));
String id = doc.get(IndexManager.UUID);
String c1v = c1.get(id);
String c2v = c2.get(id);
if (c1v != null) {
row.createCell(8).setCellValue(c1v);
}
if (c2v != null) {
row.createCell(9).setCellValue(c2v);
}
String level1 = (String) intern.intern(doc.get(IndexManager.LEVEL1_NAME));
row.createCell(0).setCellValue(level1);
if (level1 != null) {
String level2 = (String) intern.intern(doc.get(IndexManager.LEVEL2_NAME));
if (level2 != null) {
row.createCell(1).setCellValue(level2);
String level3 = (String) intern.intern(doc.get(IndexManager.LEVEL3_NAME));
if (level3 != null) {
row.createCell(2).setCellValue(level3);
String level4 = (String) intern.intern(doc.get(IndexManager.LEVEL4_NAME));
if (level4 != null) {
row.createCell(3).setCellValue(level4);
String level5 = (String) intern.intern(doc.get(IndexManager.LEVEL5_NAME));
if (level5 != null) {
row.createCell(4).setCellValue(level5);
String level6 = (String) intern.intern(doc.get(IndexManager.LEVEL6_NAME));
if (level6 != null) {
row.createCell(5).setCellValue(level6);
}
}
}
}
}
}
if (i % 1000 == 0) {
LogGui.info("Read Progress... " + i);
}
}
reader.close();
} catch (Exception e) {
LogGui.printException(e);
}
}
示例6: exportExcelFile
import org.apache.poi.xssf.streaming.SXSSFSheet; //导入方法依赖的package包/类
/**
* Esporta il contenuto di un indice su Excel
*
* @since 1.2
* @param fileToExport file su cui esportare
* @param semGui frame
* @param documentsTable tabella dei documenti
*/
public static void exportExcelFile(String fileToExport, SemGui semGui, JTable documentsTable) {
Thread t = new Thread(new Runnable() {
@Override
public void run() {
String path = fileToExport;
if (!path.endsWith(".xlsx")) {
path = path + ".xlsx";
}
try {
HashMap<String, String> c1 = new HashMap<>();
HashMap<String, String> c2 = new HashMap<>();
if (documentsTable != null) {
GuiUtils.filterTable(documentsTable, null, 0);
int rc = documentsTable.getModel().getRowCount();
for (int i = 0; i < rc; i++) {
String key = (String) documentsTable.getValueAt(i, 0);
String c1v = (String) documentsTable.getValueAt(i, 9);
String c2v = (String) documentsTable.getValueAt(i, 10);
if (key != null) {
if (c1v != null) {
c1.put(key, c1v);
}
if (c2v != null) {
c2.put(key, c2v);
}
}
}
}
FileOutputStream fos = new FileOutputStream(path);
SXSSFWorkbook wb = new SXSSFWorkbook();
SXSSFSheet sheetResults = wb.createSheet("Index");
SXSSFRow headerResults = sheetResults.createRow(0);
headerResults.createCell(0).setCellValue("Level1");
headerResults.createCell(1).setCellValue("Level2");
headerResults.createCell(2).setCellValue("Level3");
headerResults.createCell(3).setCellValue("Level4");
headerResults.createCell(4).setCellValue("Level5");
headerResults.createCell(5).setCellValue("Level6");
headerResults.createCell(6).setCellValue("Text");
headerResults.createCell(7).setCellValue("Tokens");
headerResults.createCell(8).setCellValue("Class1");
headerResults.createCell(9).setCellValue("Class2");
semGui.getME().getDocumentsExcel((String) semGui.getLinguaAnalizzatoreIstruzione().getSelectedItem(), sheetResults, c1, c2);
wb.write(fos);
fos.close();
} catch (Exception e) {
LogGui.printException(e);
}
semGui.getFilesInfoLabel().setText("Esportazione terminata");
}
});
t.start();
}