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

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

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

HSSFWorkbook.removeSheetAt介绍

[英]Removes sheet at the given index.

Care must be taken if the removed sheet is the currently active or only selected sheet in the workbook. There are a few situations when Excel must have a selection and/or active sheet. (For example when printing - see Bug 40414).
This method makes sure that if the removed sheet was active, another sheet will become active in its place. Furthermore, if the removed sheet was the only selected sheet, another sheet will become selected. The newly active/selected sheet will have the same index, or one less if the removed sheet was the last in the workbook.
[中]删除给定索引处的工作表。
如果删除的工作表是工作簿中当前活动的工作表或唯一选定的工作表,则必须小心。在某些情况下,Excel必须有一个选择和/或活动工作表。(例如打印时-请参阅错误40414)。
此方法可确保如果删除的图纸处于活动状态,则另一张图纸将在其所在位置处于活动状态。此外,如果删除的图纸是唯一选定的图纸,则会选择另一张图纸。新激活/选定的工作表将具有相同的索引,如果删除的工作表是工作簿中的最后一个工作表,则索引将减少一个。

代码示例

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

public void actionPerformed(ActionEvent e) {
  int tabIndex = sheetPane.getSelectedIndex();
  if (tabIndex != -1) {
   if (JOptionPane.showConfirmDialog(sheetPane, "Are you sure that you want to delete the selected sheet", "Delete Sheet?", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
    wb.removeSheetAt(tabIndex);
    sheetPane.remove(tabIndex);
   }
  }
 }
}

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

public void actionPerformed(ActionEvent e) {
  int tabIndex = sheetPane.getSelectedIndex();
  if (tabIndex != -1) {
   if (JOptionPane.showConfirmDialog(sheetPane, "Are you sure that you want to delete the selected sheet", "Delete Sheet?", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
    wb.removeSheetAt(tabIndex);
    sheetPane.remove(tabIndex);
   }
  }
 }
}

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

@Override
 public void actionPerformed(ActionEvent e) {
  int tabIndex = sheetPane.getSelectedIndex();
  if (tabIndex != -1) {
   if (JOptionPane.showConfirmDialog(sheetPane, "Are you sure that you want to delete the selected sheet", "Delete Sheet?", JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
    wb.removeSheetAt(tabIndex);
    sheetPane.remove(tabIndex);
   }
  }
 }
}

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

File destFile = new File("/test.xls");
FileInputStream fileStream = new FileInputStream(destFile);
POIFSFileSystem fsPoi = new POIFSFileSystem(fileStream);

HSSFWorkbook workbook = new HSSFWorkbook(fsPoi);

int index = 0;

HSSFSheet sheet = workbook.getSheet("Setup");
if(sheet != null)   {
  index = workbook.getSheetIndex(sheet);
  workbook.removeSheetAt(index);
}
workbook.createSheet("Setup");
FileOutputStream output = new FileOutputStream(destFile);
workbook.write(output);
output.close();

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

wb.removeSheetAt(i);

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

wb.removeSheetAt(1);

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

wb.removeSheetAt(1);

相关文章

HSSFWorkbook类方法