本文整理汇总了Java中org.apache.poi.ss.usermodel.Workbook.createSheet方法的典型用法代码示例。如果您正苦于以下问题:Java Workbook.createSheet方法的具体用法?Java Workbook.createSheet怎么用?Java Workbook.createSheet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.Workbook
的用法示例。
在下文中一共展示了Workbook.createSheet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testDown
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
@RequestMapping(value = "/test2.xlsx", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE)
@ResponseBody
byte[] testDown() throws IOException, InvalidFormatException {
Workbook workbook = new SXSSFWorkbook();
Sheet sheet = workbook.createSheet();
for (int i = 0; i < 60000; i++) {
Row newRow = sheet.createRow(i);
for (int j = 0; j < 100; j++) {
newRow.createCell(j).setCellValue("test" + Math.random());
}
}
ByteArrayOutputStream os = new ByteArrayOutputStream();
workbook.write(os);
byte[] bytes = os.toByteArray();
return bytes;
}
示例2: createWorkBook
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
public static void createWorkBook() throws IOException {
// ����excel������
final Workbook wb = new XSSFWorkbook();
// ����sheet��ҳ��
final Sheet sheet1 = wb.createSheet("Sheet_1");
final Sheet sheet2 = wb.createSheet("Sheet_2");
for (int i = 0; i < 20; i = i + 2) {
final Row row1 = sheet1.createRow(i);
final Row row2 = sheet2.createRow(i);
for (int j = 0; j < 10; j++) {
row1.createCell(j).setCellValue(j + "new");
row2.createCell(j).setCellValue(j + "This is a string");
}
}
// ����һ���ļ� ����Ϊworkbooks.xlsx
final FileOutputStream fileOut = new FileOutputStream("d:\\workbooks.xlsx");
// �����洴���Ĺ�����������ļ���
wb.write(fileOut);
// �ر������
fileOut.close();
}
示例3: createWookBook
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
public static Workbook createWookBook() {
// Time.getTime();
// String currrentPath = path + "/" + Time.year + "/" + Time.month;
// FileOperation.createDir(currrentPath);
// ����excel������
final Workbook wb = new XSSFWorkbook();
// ����sheet��ҳ��
final Sheet sheet1 = wb.createSheet("Data");
return wb;
}
示例4: createSheet
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
/**
* Creates an excel sheet in the provided workbook using provided parameters.
*
* @param input the data to put in the sheet-
* @param sheetName the name to user for the sheet.
* @param wb the workbook to create the sheet in.
*/
private void createSheet( List<MessageResourceEntry> input,
String sheetName,
Workbook wb)
{
// create a new sheet
String name = StringUtils.isBlank(sheetName) ? this.defaultSheetName : sheetName;
LOG.info("Create sheet with name " + name);
Sheet sheet = wb.createSheet(name);
sheet.setZoom(this.zoom, 100);
Map<Locale, Integer> langs = getLanguageInformation(input);
createHeader(sheet, langs);
CellStyle keyStyle = sheet.getWorkbook().createCellStyle();
keyStyle.setAlignment(CellStyle.ALIGN_LEFT);
keyStyle.setBorderBottom(CellStyle.BORDER_THIN);
keyStyle.setBorderRight(CellStyle.BORDER_MEDIUM);
Font f = sheet.getWorkbook().createFont();
f.setBoldweight(Font.BOLDWEIGHT_NORMAL);
keyStyle.setFont(f);
CellStyle valueStyle = sheet.getWorkbook().createCellStyle();
valueStyle.setAlignment(CellStyle.ALIGN_LEFT);
valueStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
valueStyle.setBorderBottom(CellStyle.BORDER_THIN);
valueStyle.setBorderRight(CellStyle.BORDER_THIN);
valueStyle.setBorderTop(CellStyle.BORDER_THIN);
valueStyle.setBorderLeft(CellStyle.BORDER_THIN);
valueStyle.setFont(f);
valueStyle.setWrapText(true);
CellStyle emptyStyle = sheet.getWorkbook().createCellStyle();
emptyStyle.setAlignment(CellStyle.ALIGN_LEFT);
emptyStyle.setVerticalAlignment(CellStyle.VERTICAL_TOP);
emptyStyle.setBorderBottom(CellStyle.BORDER_THIN);
emptyStyle.setBorderRight(CellStyle.BORDER_THIN);
emptyStyle.setBorderTop(CellStyle.BORDER_THIN);
emptyStyle.setBorderLeft(CellStyle.BORDER_THIN);
emptyStyle.setFont(f);
emptyStyle.setFillForegroundColor(IndexedColors.LAVENDER.getIndex());
emptyStyle.setFillPattern(CellStyle.SOLID_FOREGROUND);
emptyStyle.setWrapText(true);
LOG.info("Write data to sheet " + name);
int rowIndex = this.languageHeaderRow + 1;
for (MessageResourceEntry entry : input)
{
Row row = sheet.createRow(rowIndex);
createContentRow(entry, row, langs, keyStyle, valueStyle, emptyStyle);
rowIndex++;
}
sizeColumns(sheet, langs);
sheet.createFreezePane(this.firstLanguageColumn, this.languageHeaderRow + 1, this.firstLanguageColumn, this.languageHeaderRow + 1);
}
示例5: createSheet
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
/**
* 创建一个工作表
*
* @author ZhengWei(HY)
* @createDate 2017-03-16
* @version v1.0
*
* @param i_Workbook 工作薄对象
* @param i_SheetName 工作表名称(当为空时,自动生成)
* @return
*/
public final static Sheet createSheet(Workbook i_Workbook ,String i_SheetName)
{
int v_SheetCount = i_Workbook.getNumberOfSheets();
String v_SheetName = i_SheetName;
if ( Help.isNull(v_SheetName) )
{
v_SheetName = "sheet" + (v_SheetCount + 1);
}
return i_Workbook.createSheet(v_SheetName);
}
示例6: examToExcel
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
private static Result examToExcel(Exam exam) throws IOException {
Map<String, String> values = new LinkedHashMap<>();
values.put("Creator ID", exam.getCreator().getId().toString());
values.put("First name", exam.getCreator().getFirstName());
values.put("Last name", exam.getCreator().getLastName());
values.put("Exam type", exam.getExamType().getType());
values.put("Course code", exam.getCourse().getCode());
values.put("Course name", exam.getCourse().getName());
values.put("Course credits", exam.getCourse().getCredits().toString());
values.put("Course unit type", forceNotNull(exam.getCourse().getCourseUnitType()));
values.put("Course level", forceNotNull(exam.getCourse().getLevel()));
values.put("Created", ISODateTimeFormat.date().print(new DateTime(exam.getCreated())));
values.put("Begins", ISODateTimeFormat.date().print(new DateTime(exam.getExamActiveStartDate())));
values.put("Ends", ISODateTimeFormat.date().print(new DateTime(exam.getExamActiveEndDate())));
values.put("Duration", exam.getDuration() == null ? "N/A" : exam.getDuration().toString());
values.put("Grade scale", exam.getGradeScale() == null ? "N/A" : exam.getGradeScale().getDescription());
values.put("State", exam.getState().toString());
values.put("Attachment", exam.getAttachment() == null ? "" : exam.getAttachment().getFilePath() + exam.getAttachment().getFileName());
values.put("Instructions", forceNotNull(exam.getInstruction()));
values.put("Shared", Boolean.valueOf(exam.isShared()).toString());
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet(exam.getName());
Row headerRow = sheet.createRow(0);
int i = 0;
for (String key : values.keySet()) {
headerRow.createCell(i++).setCellValue(key);
}
Row dataRow = sheet.createRow(1);
i = 0;
for (String value : values.values()) {
dataRow.createCell(i++).setCellValue(value);
}
response().setHeader("Content-Disposition", "attachment; filename=\"exams.xlsx\"");
return ok(encode(wb));
}
示例7: getExamEnrollments
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result getExamEnrollments(Long id) throws IOException {
Exam proto = Ebean.find(Exam.class).fetch("examEnrolments").fetch("examEnrolments.user")
.fetch("examEnrolments.reservation").fetch("course")
.where().eq("id", id).isNull("parent").findUnique();
if (proto == null) {
return notFound("sitnet_error_exam_not_found");
}
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("enrolments");
String[] headers = {"student name", "student ID", "student EPPN", "reservation time", "enrolment time"};
addHeader(sheet, headers);
for (ExamEnrolment e : proto.getExamEnrolments()) {
String[] data = new String[5];
data[0] = String.format("%s %s", e.getUser().getFirstName(), e.getUser().getLastName());
data[1] = forceNotNull(e.getUser().getIdentifier());
data[2] = e.getUser().getEppn();
data[3] = e.getReservation() == null ? "" : ISODateTimeFormat.dateTimeNoMillis().print(
new DateTime(e.getReservation().getStartAt()));
data[4] = ISODateTimeFormat.dateTimeNoMillis().print(new DateTime(e.getEnrolledOn()));
Row dataRow = sheet.createRow(proto.getExamEnrolments().indexOf(e) + 1);
for (int i = 0; i < data.length; ++i) {
dataRow.createCell(i).setCellValue(data[i]);
}
}
IntStream.range(0, 5).forEach(i -> sheet.autoSizeColumn(i, true));
response().setHeader("Content-Disposition", "attachment; filename=\"enrolments.xlsx\"");
return ok(encode(wb));
}
示例8: reportStudentActivity
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result reportStudentActivity(Long studentId, String from, String to) throws IOException {
final DateTime start = DateTime.parse(from, DTF);
final DateTime end = DateTime.parse(to, DTF);
User student = Ebean.find(User.class, studentId);
if (student == null) {
return notFound("sitnet_error_not_found");
}
List<ExamParticipation> participations = Ebean.find(ExamParticipation.class)
.fetch("exam")
.where()
.gt("started", start)
.lt("ended", end)
.eq("user.id", studentId)
.findList();
Workbook wb = new XSSFWorkbook();
Sheet studentSheet = wb.createSheet("student");
String[] studentHeaders = {"id", "first name", "last name", "email", "language"};
addHeader(studentSheet, studentHeaders);
Row dataRow = studentSheet.createRow(1);
int index = 0;
dataRow.createCell(index++).setCellValue(student.getId());
dataRow.createCell(index++).setCellValue(student.getFirstName());
dataRow.createCell(index++).setCellValue(student.getLastName());
dataRow.createCell(index++).setCellValue(student.getEmail());
dataRow.createCell(index).setCellValue(student.getLanguage().getCode());
generateParticipationSheet(wb, participations, false);
response().setHeader("Content-Disposition", "attachment; filename=\"student_activity.xlsx\"");
return ok(encode(wb));
}
示例9: build
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
public static ByteArrayOutputStream build(Long examId, Collection<Long> childIds) throws IOException {
List<ExamRecord> examRecords = Ebean.find(ExamRecord.class)
.fetch("examScore")
.where()
.eq("exam.parent.id", examId)
.in("exam.id", childIds)
.findList();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("Exam records");
String[] headers = ExamScore.getHeaders();
Row headerRow = sheet.createRow(0);
for (int i = 0; i < headers.length; i++) {
headerRow.createCell(i).setCellValue(headers[i]);
}
for (ExamRecord record : examRecords) {
String[] data = record.getExamScore().asArray(record.getStudent(), record.getTeacher(), record.getExam());
Row dataRow = sheet.createRow(examRecords.indexOf(record) + 1);
for (int i = 0; i < data.length; ++i) {
dataRow.createCell(i).setCellValue(data[i]);
}
}
IntStream.range(0, headers.length).forEach(i -> sheet.autoSizeColumn(i, true));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
wb.write(bos);
bos.close();
return bos;
}
示例10: ExcelTestHelper
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
ExcelTestHelper(final String parent, boolean generateXls) throws Exception {
this.xls = generateXls;
// Create a test Excel sheet with all types of supported data
Workbook wb = generateXls ? new HSSFWorkbook() : new XSSFWorkbook();
CreationHelper creationHelper = wb.getCreationHelper();
DataFormat dataFormat = creationHelper.createDataFormat();
short fmt = dataFormat.getFormat("yyyy-mm-dd hh:mm:ss");
CellStyle style = wb.createCellStyle();
style.setDataFormat(fmt);
Sheet sheetWithHeader = wb.createSheet("Sheet 1");
// Create header row
Row headerRow = sheetWithHeader.createRow((short) 0);
headerRow.createCell(0).setCellValue("Number");
headerRow.createCell(1).setCellValue("String1");
headerRow.createCell(2).setCellValue("String2");
headerRow.createCell(3).setCellValue("MyTime");
headerRow.createCell(4).setCellValue("Formula");
headerRow.createCell(5).setCellValue("Boolean");
headerRow.createCell(6).setCellValue("Error");
generateSheetData(sheetWithHeader, style, (short)1);
Sheet sheetWithoutHeader = wb.createSheet("Sheet 2");
generateSheetData(sheetWithoutHeader, style, (short)0);
testFilePath = new File(parent, "excelTestFile").getPath();
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream(testFilePath);
wb.write(fileOut);
fileOut.close();
}
示例11: createSheet
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
public Sheet createSheet(Workbook workbook, String sheetName) {
if (StringUtils.isNotEmpty(sheetName)) {
return workbook.createSheet(sheetName);
} else {
return workbook.createSheet(DefaultSheetName);
}
}
示例12: getTeacherExamsByDate
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result getTeacherExamsByDate(Long uid, String from, String to) throws IOException {
final DateTime start = DateTime.parse(from, DTF);
final DateTime end = DateTime.parse(to, DTF);
List<Exam> exams = Ebean.find(Exam.class)
.fetch("creator")
.fetch("examType")
.fetch("course")
.fetch("children")
.where()
.between("created", start, end)
.isNull("parent")
.isNotNull("course")
.eq("creator.id", uid)
.orderBy("created")
.findList();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("teacher's exams");
String[] headers = {"exam", "created", "state", "course code", "active during", "credits", "exam type", "in review",
"graded", "logged"};
addHeader(sheet, headers);
for (Exam parent : exams) {
int inReview = 0;
int graded = 0;
int logged = 0;
for (Exam child : parent.getChildren()) {
switch (child.getState()) {
case REVIEW:
case REVIEW_STARTED:
inReview++;
break;
case GRADED:
graded++;
break;
case GRADED_LOGGED:
logged++;
break;
default:
break;
}
}
String[] data = new String[10];
data[0] = parent.getName();
data[1] = ISODateTimeFormat.date().print(new DateTime(parent.getCreated()));
data[2] = parent.getState().toString();
data[3] = parent.getCourse().getCode();
data[4] = String.format("%s - %s", ISODateTimeFormat.date().print(new DateTime(parent.getExamActiveStartDate())),
ISODateTimeFormat.date().print(new DateTime(parent.getExamActiveEndDate())));
data[5] = parent.getCourse().getCredits() == null ? "" : Double.toString(parent.getCourse().getCredits());
data[6] = parent.getExamType().getType();
data[7] = Integer.toString(inReview);
data[8] = Integer.toString(graded);
data[9] = Integer.toString(logged);
Row dataRow = sheet.createRow(exams.indexOf(parent) + 1);
for (int i = 0; i < data.length; ++i) {
dataRow.createCell(i).setCellValue(data[i]);
}
}
IntStream.range(0, 10).forEach(i -> sheet.autoSizeColumn(i, true));
response().setHeader("Content-Disposition", "attachment; filename=\"teachers_exams.xlsx\"");
return ok(encode(wb));
}
示例13: getReviewsByDate
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result getReviewsByDate(String from, String to) throws IOException {
final DateTime start = DateTime.parse(from, DTF);
final DateTime end = DateTime.parse(to, DTF);
List<Exam> exams = Ebean.find(Exam.class)
.fetch("course")
.where()
.between("gradedTime", start, end)
.disjunction()
.eq("state", Exam.State.GRADED)
.eq("state", Exam.State.GRADED_LOGGED)
.endJunction()
.orderBy("creator.id")
.findList();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("graded exams");
String[] headers = {"student", "exam", "course", "taken on", "graded on", "graded by",
"credits", "grade", "exam type", "answer language"};
addHeader(sheet, headers);
for (Exam e : exams) {
String[] data = new String[10];
data[0] = String.format("%s %s", e.getCreator().getFirstName(), e.getCreator().getLastName());
data[1] = e.getName();
data[2] = e.getCourse().getCode();
data[3] = ISODateTimeFormat.dateTimeNoMillis().print(new DateTime(e.getCreated()));
data[4] = ISODateTimeFormat.dateTimeNoMillis().print(new DateTime(e.getGradedTime()));
data[5] = parse(() -> String.format("%s %s", e.getGradedByUser().getFirstName(),
e.getGradedByUser().getLastName()));
data[6] = e.getCourse().getCredits() == null ? "" :
Double.toString(e.getCourse().getCredits()); // custom credits?
data[7] = parse(() -> e.getGrade().getName());
data[8] = parse(() -> e.getCreditType().getType());
data[9] = e.getAnswerLanguage();
Row dataRow = sheet.createRow(exams.indexOf(e) + 1);
for (int i = 0; i < data.length; ++i) {
dataRow.createCell(i).setCellValue(data[i]);
}
}
IntStream.range(0, 10).forEach(i -> sheet.autoSizeColumn(i, true));
response().setHeader("Content-Disposition", "attachment; filename=\"reviews.xlsx\"");
return ok(encode(wb));
}
示例14: getReservationsForRoomByDate
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
@Restrict({@Group("ADMIN")})
public Result getReservationsForRoomByDate(Long roomId, String from, String to) throws IOException {
final DateTime start = DateTime.parse(from, DTF);
final DateTime end = DateTime.parse(to, DTF);
List<ExamEnrolment> enrolments = Ebean.find(ExamEnrolment.class)
.fetch("user")
.fetch("exam")
.where()
.gt("reservation.endAt", start)
.lt("reservation.startAt", end)
.eq("reservation.machine.room.id", roomId)
.findList();
Workbook wb = new XSSFWorkbook();
Sheet sheet = wb.createSheet("reservations");
String[] headers = {"enrolment id", "enrolled on", "user id", "user first name", "user last name", "exam id",
"exam name", "reservation id", "reservation begins", "reservation ends", "machine id", "machine name",
"machine IP", "room id", "room name", "room code"};
addHeader(sheet, headers);
for (ExamEnrolment e : enrolments) {
List<String> data = Arrays.asList(
Long.toString(e.getId()),
ISODateTimeFormat.date().print(new DateTime(e.getEnrolledOn())),
Long.toString(e.getUser().getId()),
e.getUser().getFirstName(),
e.getUser().getLastName(),
Long.toString(e.getExam().getId()),
e.getExam().getName(),
Long.toString(e.getReservation().getId()),
ISODateTimeFormat.dateTime().print(new DateTime(e.getReservation().getStartAt())),
ISODateTimeFormat.dateTime().print(new DateTime(e.getReservation().getEndAt())),
Long.toString(e.getReservation().getMachine().getId()),
e.getReservation().getMachine().getName(),
e.getReservation().getMachine().getIpAddress(),
Long.toString(e.getReservation().getMachine().getRoom().getId()),
e.getReservation().getMachine().getRoom().getName(),
e.getReservation().getMachine().getRoom().getRoomCode()
);
Row dataRow = sheet.createRow(enrolments.indexOf(e) + 1);
for (int i = 0; i < data.size(); ++i) {
dataRow.createCell(i).setCellValue(data.get(i));
}
}
IntStream.range(0, 17).forEach(i -> sheet.autoSizeColumn(i, true));
response().setHeader("Content-Disposition", "attachment; filename=\"reservations.xlsx\"");
return ok(encode(wb));
}
示例15: generateParticipationSheet
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
private static void generateParticipationSheet(Workbook workbook, List<ExamParticipation> participations,
boolean includeStudentInfo) {
Sheet sheet = workbook.createSheet("participations");
List<String> headers = new ArrayList<>();
if (includeStudentInfo) {
headers.addAll(Arrays.asList("student id", "student first name", "student last name", "student email"));
}
headers.addAll(Arrays.asList("graded by teacher id", "graded by teacher first name", "graded by teacher last name",
"graded by teacher email", "reservation id", "exam started", "exam ended", "actual duration", "room id",
"room name", "room code", "machine id", "machine name", "machine IP", "course name", "course code",
"exam id", "exam name", "exam duration", "exam state", "exam score", "exam grade scale", "exam grade",
"graded on", "credit type"));
addHeader(sheet, headers.toArray(new String[headers.size()]));
for (ExamParticipation p : participations) {
ExamEnrolment enrolment = Ebean.find(ExamEnrolment.class)
.fetch("reservation")
.fetch("reservation.machine")
.fetch("reservation.machine.room")
.where()
.eq("user.id", p.getUser().getId())
.eq("exam.id", p.getExam().getId())
.findUnique();
if (enrolment == null) {
continue;
}
List<String> data = new ArrayList<>();
if (includeStudentInfo) {
data.add(Long.toString(p.getUser().getId()));
data.add(p.getUser().getFirstName());
data.add(p.getUser().getLastName());
data.add(p.getUser().getEmail());
}
data.add(p.getExam().getGradedByUser() == null ? "" : Long.toString(p.getExam().getGradedByUser().getId()));
data.add(p.getExam().getGradedByUser() == null ? "" : p.getExam().getGradedByUser().getFirstName());
data.add(p.getExam().getGradedByUser() == null ? "" : p.getExam().getGradedByUser().getLastName());
data.add(p.getExam().getGradedByUser() == null ? "" : p.getExam().getGradedByUser().getEmail());
data.add(Long.toString(enrolment.getReservation().getId()));
data.add(ISODateTimeFormat.dateTime().print(new DateTime(p.getStarted())));
data.add(ISODateTimeFormat.dateTime().print(new DateTime(p.getEnded())));
data.add(ISODateTimeFormat.time().print(new DateTime(p.getDuration())));
data.add(Long.toString(enrolment.getReservation().getMachine().getRoom().getId()));
data.add(enrolment.getReservation().getMachine().getRoom().getName());
data.add(enrolment.getReservation().getMachine().getRoom().getRoomCode());
data.add(Long.toString(enrolment.getReservation().getMachine().getId()));
data.add(enrolment.getReservation().getMachine().getName());
data.add(enrolment.getReservation().getMachine().getIpAddress());
data.add(p.getExam().getCourse().getName());
data.add(p.getExam().getCourse().getCode());
data.add(Long.toString(p.getExam().getId()));
data.add(p.getExam().getName());
data.add(Integer.toString(p.getExam().getDuration()));
data.add(p.getExam().getState().toString());
data.add(Double.toString(p.getExam().getTotalScore()));
data.add(p.getExam().getGradeScale().getDescription());
data.add(p.getExam().getGrade() == null ? "" : p.getExam().getGrade().getName());
data.add(p.getExam().getGradedTime() == null ? "" :
ISODateTimeFormat.dateTime().print(new DateTime(p.getExam().getGradedTime())));
data.add(p.getExam().getCreditType() == null ? "" : p.getExam().getCreditType().getType());
Row dataRow = sheet.createRow(participations.indexOf(p) + 1);
for (int i = 0; i < data.size(); ++i) {
dataRow.createCell(i).setCellValue(data.get(i));
}
}
IntStream.range(0, headers.size()).forEach(i -> sheet.autoSizeColumn(i, true));
}