org.apache.poi.hssf.usermodel.HSSFWorkbook.getSheetName()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.3k)|赞(0)|评价(0)|浏览(269)

本文整理了Java中org.apache.poi.hssf.usermodel.HSSFWorkbook.getSheetName()方法的一些代码示例,展示了HSSFWorkbook.getSheetName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HSSFWorkbook.getSheetName()方法的具体详情如下:
包路径:org.apache.poi.hssf.usermodel.HSSFWorkbook
类名称:HSSFWorkbook
方法名:getSheetName

HSSFWorkbook.getSheetName介绍

暂无

代码示例

代码示例来源:origin: org.apache.poi/poi

@Override
public String getSheetName(int sheetIndex) {
  return _uBook.getSheetName(sheetIndex);
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Returns the name of this sheet
 *
 * @return the name of this sheet
 */
@SuppressWarnings("resource")
@Override
public String getSheetName() {
  HSSFWorkbook wb = getWorkbook();
  int idx = wb.getSheetIndex(this);
  return wb.getSheetName(idx);
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Sets the printarea for the sheet provided
 * <p>
 * i.e. Reference = $A$1:$B$2
 * @param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
 * @param reference Valid name Reference for the Print Area
 */
@Override
public void setPrintArea(int sheetIndex, String reference)
{
  NameRecord name = workbook.getSpecificBuiltinRecord(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
  if (name == null) {
    name = workbook.createBuiltInName(NameRecord.BUILTIN_PRINT_AREA, sheetIndex+1);
    // adding one here because 0 indicates a global named region; doesn't make sense for print areas
  }
  String[] parts = COMMA_PATTERN.split(reference);
  StringBuilder sb = new StringBuilder(32);
  for (int i = 0; i < parts.length; i++) {
    if(i>0) {
      sb.append(",");
    }
    SheetNameFormatter.appendFormat(sb, getSheetName(sheetIndex));
    sb.append("!");
    sb.append(parts[i]);
  }
  name.setNameDefinition(HSSFFormulaParser.parse(sb.toString(), this, FormulaType.NAMEDRANGE, sheetIndex));
}

代码示例来源:origin: org.apache.poi/poi

/**
 * Shifts columns in range [startColumn, endColumn] for n places to the right.
 * For n < 0, it will shift columns left.
 * Additionally adjusts formulas.
 * Probably should also process other features (hyperlinks, comments...) in the way analog to shiftRows method 
 * @param startRow               the row to start shifting
 * @param endRow                 the row to end shifting
 * @param n                      the number of rows to shift
 */
@Beta
@Override
public void shiftColumns(int startColumn, int endColumn, int n){ 
  HSSFColumnShifter columnShifter = new HSSFColumnShifter(this); 
  columnShifter.shiftColumns(startColumn, endColumn, n); 
  
  int sheetIndex = _workbook.getSheetIndex(this);
  short externSheetIndex = _book.checkExternSheet(sheetIndex);
  String sheetName = _workbook.getSheetName(sheetIndex);
  FormulaShifter formulaShifter = FormulaShifter.createForColumnShift(
      externSheetIndex, sheetName, startColumn, endColumn, n, SpreadsheetVersion.EXCEL97);
  updateFormulasForShift(formulaShifter); 
  // add logic for hyperlinks etc, like in shiftRows() 
}

代码示例来源:origin: org.apache.poi/poi

String name = _wb.getSheetName(i);
if(name != null) {
  text.append(name);

代码示例来源:origin: org.apache.poi/poi

String sheetName = _workbook.getSheetName(sheetIndex);
FormulaShifter formulaShifter = FormulaShifter.createForRowShift(
    externSheetIndex, sheetName, startRow, endRow, n, SpreadsheetVersion.EXCEL97);

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

@Override
public String getSheetName(int sheetIndex) {
  return _uBook.getSheetName(sheetIndex);
}

代码示例来源:origin: com.haulmont.thirdparty/poi

public String getSheetName(int sheetIndex) {
  return _uBook.getSheetName(sheetIndex);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

public String getSheetName(int sheetIndex) {
  return _uBook.getSheetName(sheetIndex);
}

代码示例来源:origin: org.openl.rules/org.openl.lib.poi.dev

/**
 * Returns the name of this sheet
 *
 * @return the name of this sheet
 */
public String getSheetName() {
  HSSFWorkbook wb = getWorkbook();
  int idx = wb.getSheetIndex(this);
  return wb.getSheetName(idx);
}

代码示例来源:origin: FenixEdu/fenixedu-academic

private String[] getAllSpreadsheets(HSSFWorkbook wb) {
  String[] spreadsheets = new String[wb.getNumberOfSheets()];
  for (int i = 0; i < wb.getNumberOfSheets(); i++) {
    spreadsheets[i] = wb.getSheetName(i);
  }
  return spreadsheets;
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

/**
 * Returns the name of this sheet
 *
 * @return the name of this sheet
 */
@SuppressWarnings("resource")
@Override
public String getSheetName() {
  HSSFWorkbook wb = getWorkbook();
  int idx = wb.getSheetIndex(this);
  return wb.getSheetName(idx);
}

代码示例来源:origin: com.haulmont.thirdparty/poi

/**
 * Returns the name of this sheet
 *
 * @return the name of this sheet
 */
public String getSheetName() {
  HSSFWorkbook wb = getWorkbook();
  int idx = wb.getSheetIndex(this);
  return wb.getSheetName(idx);
}

代码示例来源:origin: stackoverflow.com

FileInputStream fileInputStream = null;  
     try {  
      fileInputStream = new FileInputStream("PATH_TO_EXCEL_FILE+FILE_NAME");  
      HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);  
      for (int i = 0; i < workbook.getNumberOfSheets(); i++) {  
       if (workbook.getSheetName(i).equals("MY_OLD_SHEET_NAME")) {
         workbook.createSheet("MY_OLD_SHEET_NAME");
         workbook.setSheetOrder("MY_OLD_SHEET_NAME", i);
         // TO DO: add contents to new sheet 
       }
      }
      }
      ............

代码示例来源:origin: org.apache.poi/poi-contrib

public void actionPerformed(ActionEvent e) {
  //Create a new sheet then search for the sheet and make sure that the
  //sheetPane shows it.
  HSSFSheet newSheet = wb.createSheet();
  for (int i=0; i<wb.getNumberOfSheets();i++) {
   HSSFSheet sheet = wb.getSheetAt(i);
   if (newSheet == sheet) {
    sheetPane.insertTab(wb.getSheetName(i), null, makeSheetView(sheet), null, i);
   }
  }
 }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.poi

public void actionPerformed(ActionEvent e) {
  //Create a new sheet then search for the sheet and make sure that the
  //sheetPane shows it.
  HSSFSheet newSheet = wb.createSheet();
  for (int i=0; i<wb.getNumberOfSheets();i++) {
   HSSFSheet sheet = wb.getSheetAt(i);
   if (newSheet == sheet) {
    sheetPane.insertTab(wb.getSheetName(i), null, makeSheetView(sheet), null, i);
   }
  }
 }
}

代码示例来源:origin: org.apache.poi/poi-examples

@Override
 public void actionPerformed(ActionEvent e) {
  //Create a new sheet then search for the sheet and make sure that the
  //sheetPane shows it.
  HSSFSheet newSheet = wb.createSheet();
  for (int i=0; i<wb.getNumberOfSheets();i++) {
   HSSFSheet sheet = wb.getSheetAt(i);
   if (newSheet == sheet) {
    sheetPane.insertTab(wb.getSheetName(i), null, makeSheetView(sheet), null, i);
   }
  }
 }
}

代码示例来源:origin: QihooTest/Leo

/**
 * Creates a new XlsDataSet object that loads the specified Excel document.
 */
public XlsDataSet(InputStream in) throws IOException, DataSetException {
  _tables = super.createTableNameMap();
  HSSFWorkbook workbook = new HSSFWorkbook(in);
  int sheetCount = workbook.getNumberOfSheets();
  for (int i = 0; i < sheetCount; i++) {
    ITable table = new XlsTable(workbook, workbook.getSheetName(i),
        workbook.getSheetAt(i));
    _tables.add(table.getTableMetaData().getTableName(), table);
  }
}

代码示例来源:origin: QihooTest/Leo

/**
 * 从Excel的工作簿中创建XlsDataSet.
 */
@Deprecated
public XlsDataSet(HSSFWorkbook workbook) throws IOException, DataSetException {
  _tables = super.createTableNameMap();
  int sheetCount = workbook.getNumberOfSheets();
  for (int i = 0; i < sheetCount; i++) {
    ITable table = new XlsTable(workbook, workbook.getSheetName(i),
        workbook.getSheetAt(i));
    _tables.add(table.getTableMetaData().getTableName(), table);
  }
}

代码示例来源:origin: micromata/projectforge

public void doImport(final ImportStorage<KontoDO> storage, final InputStream is, final ActionLog actionLog) throws Exception
{
 final ExcelImport<KontenplanExcelRow> imp = new ExcelImport<KontenplanExcelRow>(is);
 for (short idx = 0; idx < imp.getWorkbook().getNumberOfSheets(); idx++) {
  imp.setActiveSheet(idx);
  final String name = imp.getWorkbook().getSheetName(idx);
  if (NAME_OF_EXCEL_SHEET.equals(name)) {
   imp.setActiveSheet(idx);
   final HSSFSheet sheet = imp.getWorkbook().getSheetAt(idx);
   importKontenplan(storage, imp, sheet, actionLog);
   return;
  }
 }
 log.error("Oups, no sheet named 'Kontenplan' found.");
}

相关文章

HSSFWorkbook类方法