本文整理汇总了Java中org.apache.poi.ss.usermodel.Workbook.getNumberOfSheets方法的典型用法代码示例。如果您正苦于以下问题:Java Workbook.getNumberOfSheets方法的具体用法?Java Workbook.getNumberOfSheets怎么用?Java Workbook.getNumberOfSheets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.Workbook
的用法示例。
在下文中一共展示了Workbook.getNumberOfSheets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: importExcel
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
public static <T> ImportResult<T> importExcel(ExcelFileType fileType,InputStream inputStream,Class<T> clazz) throws Exception{
if(importInfoMap.get(clazz) == null){//初始化信息
initTargetClass(clazz);
}
ImportInfo importInfo = importInfoMap.get(clazz);
Integer headRow = importInfo.getHeadRow();
Workbook workbook = createWorkbook(fileType, inputStream);
int sheetNum = workbook.getNumberOfSheets();
if(sheetNum < 1 ){
return null;
}
Sheet sheet = workbook.getSheetAt(0);
int rowCount = sheet.getPhysicalNumberOfRows();
if(rowCount < (headRow+1)){//
return null;
}
List<String> headNameList = createHeadNameList(sheet, headRow);
return readData(clazz, importInfo, workbook,headNameList);
}
示例2: 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);
}
示例3: processSpreadsheetUpload
import org.apache.poi.ss.usermodel.Workbook; //导入方法依赖的package包/类
private void processSpreadsheetUpload(Workbook wb, List<Map<QName,String>> users)
throws IOException
{
if (wb.getNumberOfSheets() > 1)
{
logger.info("Uploaded Excel file has " + wb.getNumberOfSheets() +
" sheets, ignoring all except the first one");
}
int firstRow = 0;
Sheet s = wb.getSheetAt(0);
DataFormatter df = new DataFormatter();
String[][] data = new String[s.getLastRowNum()+1][];
// If there is a heading freezepane row, skip it
PaneInformation pane = s.getPaneInformation();
if (pane != null && pane.isFreezePane() && pane.getHorizontalSplitTopRow() > 0)
{
firstRow = pane.getHorizontalSplitTopRow();
logger.debug("Skipping excel freeze header of " + firstRow + " rows");
}
// Process each row in turn, getting columns up to our limit
for (int row=firstRow; row <= s.getLastRowNum(); row++)
{
Row r = s.getRow(row);
if (r != null)
{
String[] d = new String[COLUMNS.length];
for (int cn=0; cn<COLUMNS.length; cn++)
{
Cell cell = r.getCell(cn);
if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK)
{
d[cn] = df.formatCellValue(cell);
}
}
data[row] = d;
}
}
// Handle the contents
processSpreadsheetUpload(data, users);
}