本文整理匯總了Java中org.apache.poi.ss.usermodel.Sheet.createRow方法的典型用法代碼示例。如果您正苦於以下問題:Java Sheet.createRow方法的具體用法?Java Sheet.createRow怎麽用?Java Sheet.createRow使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.ss.usermodel.Sheet
的用法示例。
在下文中一共展示了Sheet.createRow方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: buildSheet
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private void buildSheet(SXSSFWorkbook wb,VariableCategory vc,XSSFCellStyle style){
String name=vc.getName();
Sheet sheet=wb.createSheet(name);
Row row=sheet.createRow(0);
List<Variable> variables=vc.getVariables();
for(int i=0;i<variables.size();i++){
sheet.setColumnWidth(i,4000);
Cell cell=row.createCell(i);
Variable var=variables.get(i);
cell.setCellValue(var.getLabel());
cell.setCellStyle(style);
}
}
示例2: createFirstRow
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private static List<String> createFirstRow(String sheetName,
List<Locale> locales, Sheet sheet, CellStyle styleTitle) {
int colIdx = 0;
Row titleRow = sheet.createRow(0);
sheet.setColumnWidth(colIdx, 30 * 256);
Cell titleCell = titleRow.createCell(colIdx++);
titleCell.setCellStyle(styleTitle);
titleCell.setCellValue(getDefaultResourceBundle().getString(
BaseBean.LABEL_SHOP_TRANSLARIONS_KEY));
return createColumnHeaders(sheetName, locales, sheet, styleTitle,
colIdx, titleRow);
}
示例3: writeTitlePageFooter
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
/**
* 按報表模板格式寫分頁頁腳標題
*
* @author ZhengWei(HY)
* @createDate 2017-06-25
* @version v1.0
*
* @param i_DataWorkbook 數據工作薄
* @param i_DataSheet 數據工作表
* @param io_RTotal 將數據寫入Excel時的輔助統計信息
* @param io_RSystemValue 係統變量信息
* @param i_Datas 數據
* @param i_RTemplate 報表模板對象
*/
public final static void writeTitlePageFooter(RWorkbook i_DataWorkbook ,Sheet i_DataSheet ,RTotal io_RTotal ,RSystemValue io_RSystemValue ,Object i_Datas ,RTemplate i_RTemplate)
{
Sheet v_TemplateSheet = i_RTemplate.getTemplateSheet();
int v_TemplateRowCount = io_RTotal.getTitlePageFooterCount();
int v_ExcelRowIndex = io_RTotal.getExcelRowIndex();
copyMergedRegionsTitlePageFooter(i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板合並單元格
copyImagesTitlePageFooter( i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板複製圖片
for (int v_RowNo=0; v_RowNo<v_TemplateRowCount; v_RowNo++)
{
int v_TemplateRowNo = i_RTemplate.getTitlePageFooterBeginRow() + v_RowNo;
Row v_TemplateRow = v_TemplateSheet.getRow(v_TemplateRowNo);
int v_DataRowNo = v_RowNo + v_ExcelRowIndex;
Row v_DataRow = i_DataSheet.createRow(v_DataRowNo);
io_RTotal.addExcelRowIndex(1);
copyRow(i_RTemplate ,v_TemplateRow ,i_DataWorkbook ,io_RTotal ,io_RSystemValue ,v_DataRow ,i_Datas);
}
}
示例4: addTitleToSheet
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
public int addTitleToSheet(ReportTitle reportTitle, Sheet sheet, int row, int firstCol, int lastCol) {
if (!reportTitle.isShowTitle()) {
return row;
}
Row titleRow = sheet.createRow(row);
Cell titleCell = titleRow.createCell(firstCol);
titleCell.setCellType(Cell.CELL_TYPE_STRING);
titleCell.setCellValue(reportTitle.getTitle());
CellStyle titleStyle = new TitleStyleBuilder().builder(reportTitle, sheet.getWorkbook());
titleCell.setCellStyle(titleStyle);
CellRangeAddress rangle = new CellRangeAddress(row, row, firstCol, lastCol);
sheet.addMergedRegion(rangle);
this.setCellRangeAddressBorder(rangle, sheet);
return row + 1;
}
示例5: writeSubtotal
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
/**
* 按報表模板格式寫入小計(暫時不支持分頁功能)
*
* @author ZhengWei(HY)
* @createDate 2017-03-27
* @version v1.0
*
* @param i_DataWorkbook 數據工作薄
* @param i_DataSheet 數據工作表
* @param io_RTotal 將數據寫入Excel時的輔助統計信息
* @param io_RSystemValue 係統變量信息
* @param i_Datas 數據
* @param i_RTemplate 報表模板對象
*/
public final static void writeSubtotal(RWorkbook i_DataWorkbook ,Sheet i_DataSheet ,RTotal io_RTotal ,RSystemValue io_RSystemValue, Object i_Datas ,RTemplate i_RTemplate)
{
Sheet v_TemplateSheet = i_RTemplate.getTemplateSheet();
int v_TemplateRowCountSubtotal = i_RTemplate.getRowCountSubtotal();
int v_ExcelRowIndex = io_RTotal.getExcelRowIndex();
copyMergedRegionsSubtotal(i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板合並單元格
copyImagesSubtotal( i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板複製圖片
for (int v_RowNo=0; v_RowNo<v_TemplateRowCountSubtotal; v_RowNo++)
{
int v_TemplateRowNo = i_RTemplate.getSubtotalBeginRow() + v_RowNo;
Row v_TemplateRow = v_TemplateSheet.getRow(v_TemplateRowNo);
int v_DataRowNo = v_RowNo + v_ExcelRowIndex;
Row v_DataRow = i_DataSheet.createRow(v_DataRowNo);
io_RTotal.addExcelRowIndex(1);
io_RTotal.addRealDataCount(1);
copyRow(i_RTemplate ,v_TemplateRow ,i_DataWorkbook ,io_RTotal ,io_RSystemValue ,v_DataRow ,i_Datas);
}
}
示例6: feedDetailsSheet
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
public void feedDetailsSheet(Sheet sheet, boolean exportAsTemplate, List<XLTestStep> xLTestSteps) {
int index = 0;
for (XLTestStep xLTestStep : xLTestSteps) {
index++;
Row row = sheet.createRow(index);
Cell cell = row.createCell(STEPNAME_INDEX);
cell.setCellValue(xLTestStep.getName());
cell = row.createCell(EXPECTED_OR_ACTION_INDEX);
cell.setCellValue(xLTestStep.getExpected());
cell = row.createCell(RESULT_INDEX);
if (exportAsTemplate)
cell.setCellValue("");
else
cell.setCellValue(xLTestStep.getActual());
cell = row.createCell(STATUS_INDEX);
formatCellStatus(sheet, cell);
if (exportAsTemplate)
cell.setCellValue("");
else
cell.setCellValue(Integer.parseInt(xLTestStep.getStatus()));
}
this.autoSize(sheet, new int[] { 0, 1, 2, 3 });
}
示例7: main
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
public static void main(String[] args) throws Throwable {
SXSSFWorkbook wb = new SXSSFWorkbook(100); // keep 100 rows in memory, exceeding rows will be flushed to disk
Sheet sh = wb.createSheet();
for (int rownum = 0; rownum < 1000; rownum++) {
Row row = sh.createRow(rownum);
Row row1 = sh.createRow(rownum);
for (int cellnum = 0; cellnum < 10; cellnum++) {
Cell cell = row.createCell(cellnum);
String address = new CellReference(cell).formatAsString();
cell.setCellValue(address);
}
}
// Rows with rownum < 900 are flushed and not accessible
// for (int rownum = 0; rownum < 103857; rownum++) {
// Assert.assertNull(sh.getRow(rownum));
// }
//
// // ther last 100 rows are still in memory
// for (int rownum = 103857; rownum < 104857; rownum++) {
// Assert.assertNotNull(sh.getRow(rownum));
// }
File file = new File("C:\\Users\\FlyingHe\\Desktop", "datas.xlsx");
FileOutputStream out = new FileOutputStream(file);
wb.write(out);
out.close();
// dispose of temporary files backing this workbook on disk
wb.dispose();
}
示例8: writeTitlePageHeader
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
/**
* 按報表模板格式寫分頁頁眉標題
*
* @author ZhengWei(HY)
* @createDate 2017-06-25
* @version v1.0
*
* @param i_DataWorkbook 數據工作薄
* @param i_DataSheet 數據工作表
* @param io_RTotal 將數據寫入Excel時的輔助統計信息
* @param io_RSystemValue 係統變量信息
* @param i_Datas 數據
* @param i_RTemplate 報表模板對象
*/
public final static void writeTitlePageHeader(RWorkbook i_DataWorkbook ,Sheet i_DataSheet ,RTotal io_RTotal ,RSystemValue io_RSystemValue ,Object i_Datas ,RTemplate i_RTemplate)
{
Sheet v_TemplateSheet = i_RTemplate.getTemplateSheet();
int v_TemplateRowCount = io_RTotal.getTitlePageHeaderCount();
int v_ExcelRowIndex = io_RTotal.getExcelRowIndex();
copyMergedRegionsTitlePageHeader(i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板合並單元格
copyImagesTitlePageHeader( i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板複製圖片
io_RSystemValue.setPageNo(io_RSystemValue.getPageNo() + 1);
for (int v_RowNo=0; v_RowNo<v_TemplateRowCount; v_RowNo++)
{
int v_TemplateRowNo = i_RTemplate.getTitlePageHeaderBeginRow() + v_RowNo;
Row v_TemplateRow = v_TemplateSheet.getRow(v_TemplateRowNo);
int v_DataRowNo = v_RowNo + v_ExcelRowIndex;
Row v_DataRow = i_DataSheet.createRow(v_DataRowNo);
io_RTotal.addExcelRowIndex(1);
copyRow(i_RTemplate ,v_TemplateRow ,i_DataWorkbook ,io_RTotal ,io_RSystemValue ,v_DataRow ,i_Datas);
}
}
示例9: writeDataByBlankSpace
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
/**
* 按報表模板格式寫入“空白”數據
*
* @author ZhengWei(HY)
* @createDate 2017-07-03
* @version v1.0
*
* @param i_DataWorkbook 數據工作薄
* @param i_DataSheet 數據工作表
* @param io_RTotal 將數據寫入Excel時的輔助統計信息
* @param io_RSystemValue 係統變量信息
* @param i_Datas 數據
* @param i_RTemplate 報表模板對象
*/
public final static void writeDataByBlankSpace(RWorkbook i_DataWorkbook ,Sheet i_DataSheet ,RTotal io_RTotal ,RSystemValue io_RSystemValue, RTemplate i_RTemplate)
{
Sheet v_TemplateSheet = i_RTemplate.getTemplateSheet();
int v_TemplateRowCount = i_RTemplate.getRowCountData();
int v_ExcelRowIndex = io_RTotal.getExcelRowIndex();
copyMergedRegionsData(i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板合並單元格
copyImagesData( i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板複製圖片
for (int v_RowNo=0; v_RowNo<v_TemplateRowCount; v_RowNo++)
{
int v_TemplateRowNo = i_RTemplate.getDataBeginRow() + v_RowNo;
Row v_TemplateRow = v_TemplateSheet.getRow(v_TemplateRowNo);
int v_DataRowNo = v_RowNo + v_ExcelRowIndex;
Row v_DataRow = i_DataSheet.createRow(v_DataRowNo);
io_RTotal.addExcelRowIndex(1);
copyRowByBlankSpace(i_RTemplate ,v_TemplateRow ,i_DataWorkbook ,io_RTotal ,io_RSystemValue ,v_DataRow);
}
}
示例10: writeData
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
/**
* 按報表模板格式寫入數據
*
* @author ZhengWei(HY)
* @createDate 2017-03-17
* @version v1.0
*
* @param i_DataWorkbook 數據工作薄
* @param i_DataSheet 數據工作表
* @param io_RTotal 將數據寫入Excel時的輔助統計信息
* @param io_RSystemValue 係統變量信息
* @param i_Datas 數據
* @param i_RTemplate 報表模板對象
*/
public final static void writeData(RWorkbook i_DataWorkbook ,Sheet i_DataSheet ,RTotal io_RTotal ,RSystemValue io_RSystemValue, Object i_Datas ,RTemplate i_RTemplate)
{
Sheet v_TemplateSheet = i_RTemplate.getTemplateSheet();
int v_TemplateRowCount = i_RTemplate.getRowCountData();
int v_ExcelRowIndex = io_RTotal.getExcelRowIndex();
copyMergedRegionsData(i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板合並單元格
copyImagesData( i_RTemplate ,i_DataSheet ,io_RTotal); // 按模板複製圖片
for (int v_RowNo=0; v_RowNo<v_TemplateRowCount; v_RowNo++)
{
int v_TemplateRowNo = i_RTemplate.getDataBeginRow() + v_RowNo;
Row v_TemplateRow = v_TemplateSheet.getRow(v_TemplateRowNo);
int v_DataRowNo = v_RowNo + v_ExcelRowIndex;
Row v_DataRow = i_DataSheet.createRow(v_DataRowNo);
io_RTotal.addExcelRowIndex(1);
io_RTotal.addRealDataCount(1);
copyRow(i_RTemplate ,v_TemplateRow ,i_DataWorkbook ,io_RTotal ,io_RSystemValue ,v_DataRow ,i_Datas);
}
}
示例11: getExamEnrollments
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的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));
}
示例12: createSheetDataRow
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private static <T> void createSheetDataRow(List<T> dataList, int dataRowNum,
int listStart, int listEnd,ExportInfo exportInfo,
Map<Field, CellStyle> dataCellStyleMap, List<Field> availableFields,Sheet sheet)
throws IllegalAccessException, InvocationTargetException {
Map<Field, ExportFieldInfo> fieldInfoMap = exportInfo.getFieldInfoMap();
Cell cell;
Field field;
Row row;
T obj ;
int dataSize = dataList.size() ;
listEnd = listEnd > dataSize ? dataSize : listEnd ;
int fieldListSize = availableFields.size();
int dataHightInPoint = exportInfo.getDataHightInPoint();
for(int i = listStart ; i < listEnd ; i++ , dataRowNum ++){
obj = dataList.get(i);
row = sheet.createRow(dataRowNum );
row.setHeightInPoints(dataHightInPoint);
for(int j = 0 ; j < fieldListSize ; j++){
field = availableFields.get(j);
if(field == null ){
continue;
}
cell= row.createCell(j);
Object returnVal = obj;
List<Method> methods = fieldInfoMap.get(field).getMethodChain();
for(Method method : methods){
if (returnVal == null) {
continue;
}
returnVal = method.invoke(returnVal);
}
setCellValue(cell, fieldInfoMap.get(field), returnVal, obj);
if(dataCellStyleMap != null && dataCellStyleMap.get(field) != null){
cell.setCellStyle(dataCellStyleMap.get(field));
}
}
}
}
示例13: buildGridExcelHeader
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
private int buildGridExcelHeader(ReportGrid gridModel, Sheet sheet, int starHeaderRow, Map<String, CellStyle> styles) {
Map<Integer, Object> rowMap = new HashMap<Integer, Object>();
this.calculateMaxHeaderLevel(gridModel, gridModel.getGridHeaderModelList());
int maxHeaderLevel = gridModel.getMaxHeaderLevel();
for (int i = 0; i < maxHeaderLevel; i++) {
Row row = sheet.createRow((short) i + starHeaderRow);
rowMap.put(i + starHeaderRow, row);
}
List<ReportGridHeader> topHeaders = new ArrayList<ReportGridHeader>();
calculateGridHeadersByLevel(gridModel.getGridHeaderModelList(), 1, topHeaders);
this.buildGridExcelHeader(sheet, rowMap, maxHeaderLevel, 1, starHeaderRow, 0, topHeaders, styles);
return starHeaderRow + maxHeaderLevel;
}
示例14: writeOneRow
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
public static Workbook writeOneRow(Workbook wb, int sheetIndex, int rowIndex, List<String> content) {
final Sheet sheet = wb.getSheetAt(sheetIndex);
final Row row = sheet.createRow(rowIndex);
for (int i = 0; i < content.size(); i++) {
row.createCell(i).setCellValue(content.get(i));
}
return wb;
}
示例15: createHeader
import org.apache.poi.ss.usermodel.Sheet; //導入方法依賴的package包/類
/**
* Creates the header row for the sheet provided.
*
* @param sheet the sheet to create the header for
* @param langs the languages to use in the header
*/
private void createHeader( Sheet sheet,
Map<Locale, Integer> langs)
{
LOG.info("Create header row with languages " + langs.toString());
CellStyle key = sheet.getWorkbook().createCellStyle();
key.setAlignment(CellStyle.ALIGN_CENTER);
key.setBorderBottom(CellStyle.BORDER_MEDIUM);
key.setBorderRight(CellStyle.BORDER_MEDIUM);
Font f = sheet.getWorkbook().createFont();
f.setBoldweight(Font.BOLDWEIGHT_BOLD);
key.setFont(f);
CellStyle hlang = sheet.getWorkbook().createCellStyle();
hlang.setAlignment(CellStyle.ALIGN_CENTER);
hlang.setBorderBottom(CellStyle.BORDER_MEDIUM);
hlang.setBorderRight(CellStyle.BORDER_THIN);
hlang.setFont(f);
Row row = sheet.createRow(this.languageHeaderRow);
Cell cell = row.createCell(this.keyColumn);
cell.setCellStyle(key);
cell.setCellValue("KEY");
for (Entry<Locale, Integer> lang : langs.entrySet())
{
cell = row.createCell(lang.getValue());
cell.setCellStyle(hlang);
cell.setCellValue(lang.getKey().toString());
}
}