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

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

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

HSSFWorkbook.close介绍

[英]Closes the underlying POIFSFileSystem from which the Workbook was read, if any.

Once this has been called, no further operations, updates or reads should be performed on the Workbook.
[中]关闭从中读取工作簿的底层文件系统(如果有)。
调用此函数后,不应对工作簿执行进一步的操作、更新或读取。

代码示例

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

public static void main( String[] args ) throws IOException {
    OutputStreamWriter osw = new OutputStreamWriter(System.out, Charset.defaultCharset());
    PrintWriter pw = new PrintWriter(osw);
    POIFSFileSystem fs = new POIFSFileSystem(new File(args[0]));
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    try {
      pw.println( "Drawing group:" );
      wb.dumpDrawingGroupRecords(true);
  
      int i = 1;
      for (Sheet sheet : wb)
      {
        pw.println( "Sheet " + i + "(" + sheet.getSheetName() + "):" );
        ((HSSFSheet) sheet).dumpDrawingRecords(true, pw);
      }
    } finally {
      wb.close();
      fs.close();
    }
  }
}

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

wb.close();
is.close();

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

public static void writeToFile(OutputStream fos, InputStream xlsWorkbook, boolean excludeWorkbookRecords, String[] params) throws IOException {
  HSSFWorkbook workbook = new HSSFWorkbook(xlsWorkbook);
  InternalWorkbook internalWorkbook = workbook.getInternalWorkbook();
  DrawingGroupRecord r = (DrawingGroupRecord) internalWorkbook.findFirstRecordBySid(DrawingGroupRecord.sid);
  StringBuilder builder = new StringBuilder();
  builder.append("<workbook>\n");
  String tab = "\t";
  if (!excludeWorkbookRecords && r != null) {
    r.decode();
    List<EscherRecord> escherRecords = r.getEscherRecords();
    for (EscherRecord record : escherRecords) {
      builder.append(record.toXml(tab));
    }
  }
  List<Integer> sheets = getSheetsIndexes(params, workbook);
  for (Integer i : sheets) {
    HSSFPatriarch p = workbook.getSheetAt(i).getDrawingPatriarch();
    if(p != null ) {
      builder.append(tab).append("<sheet").append(i).append(">\n");
      builder.append(p.getBoundAggregate().toXml(tab + "\t"));
      builder.append(tab).append("</sheet").append(i).append(">\n");
    }
  }
  builder.append("</workbook>\n");
  fos.write(builder.toString().getBytes(StringUtil.UTF8));
  fos.close();
  workbook.close();
}

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

System.out.println(extractor.getText());
extractor.close();
wb.close();

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

@Override
public void close() throws IOException {
  wb.close();
}

代码示例来源:origin: youseries/ureport

}finally{
  try {
    wb.close();
  } catch (IOException e) {
    e.printStackTrace();

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

public static void main( String[] args ) throws IOException {
    OutputStreamWriter osw = new OutputStreamWriter(System.out, Charset.defaultCharset());
    PrintWriter pw = new PrintWriter(osw);
    POIFSFileSystem fs = new POIFSFileSystem(new File(args[0]));
    HSSFWorkbook wb = new HSSFWorkbook(fs);
    try {
      pw.println( "Drawing group:" );
      wb.dumpDrawingGroupRecords(true);
  
      int i = 1;
      for (Sheet sheet : wb)
      {
        pw.println( "Sheet " + i + "(" + sheet.getSheetName() + "):" );
        ((HSSFSheet) sheet).dumpDrawingRecords(true, pw);
      }
    } finally {
      wb.close();
      fs.close();
    }
  }
}

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

wb.close();
is.close();

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

public static void writeToFile(OutputStream fos, InputStream xlsWorkbook, boolean excludeWorkbookRecords, String[] params) throws IOException {
  HSSFWorkbook workbook = new HSSFWorkbook(xlsWorkbook);
  InternalWorkbook internalWorkbook = workbook.getInternalWorkbook();
  DrawingGroupRecord r = (DrawingGroupRecord) internalWorkbook.findFirstRecordBySid(DrawingGroupRecord.sid);
  StringBuilder builder = new StringBuilder();
  builder.append("<workbook>\n");
  String tab = "\t";
  if (!excludeWorkbookRecords && r != null) {
    r.decode();
    List<EscherRecord> escherRecords = r.getEscherRecords();
    for (EscherRecord record : escherRecords) {
      builder.append(record.toXml(tab));
    }
  }
  List<Integer> sheets = getSheetsIndexes(params, workbook);
  for (Integer i : sheets) {
    HSSFPatriarch p = workbook.getSheetAt(i).getDrawingPatriarch();
    if(p != null ) {
      builder.append(tab).append("<sheet").append(i).append(">\n");
      builder.append(p.getBoundAggregate().toXml(tab + "\t"));
      builder.append(tab).append("</sheet").append(i).append(">\n");
    }
  }
  builder.append("</workbook>\n");
  fos.write(builder.toString().getBytes(StringUtil.UTF8));
  fos.close();
  workbook.close();
}

代码示例来源:origin: com.github.hazendaz/displaytag

/**
 * @see org.displaytag.export.BinaryExportView#doExport(java.io.OutputStream)
 */
@Override
public void doExport(OutputStream out) throws IOException, JspException
{
  try
  {
    HSSFWorkbook wb = new HSSFWorkbook();
    getHssfTableWriter(wb).writeTable(this.model, "-1");
    wb.write(out);
    wb.close();
  }
  catch (Exception e)
  {
    throw new HssfGenerationException(e);
  }
}

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

workbook.close();
file.close();

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

/**
 * Converts Excel file (97-2007) into XSL FO file.
 * 
 * @param xlsFile
 *            file to process
 * @return DOM representation of result XSL FO
 */
public static Document process( File xlsFile ) throws Exception
{
  final HSSFWorkbook workbook = AbstractExcelUtils.loadXls( xlsFile );
  try {
    ExcelToFoConverter excelToHtmlConverter = new ExcelToFoConverter(
        XMLHelper.getDocumentBuilderFactory().newDocumentBuilder()
            .newDocument() );
    excelToHtmlConverter.processWorkbook( workbook );
    return excelToHtmlConverter.getDocument();
  } finally {
    workbook.close();
  }
}

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

wb.close();
input.close();

代码示例来源:origin: xjs1919/util

workbook.close();
return out.toByteArray();

代码示例来源:origin: FutureCitiesCatapult/TomboloDigitalConnector

workbook.close();

代码示例来源:origin: FutureCitiesCatapult/TomboloDigitalConnector

workbook.close();

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

embeddedWorkbook.close();
} else if (contentType.equals("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")) {

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

DirectoryNode dn = (DirectoryNode) obj.getDirectory();
  HSSFWorkbook embeddedWorkbook = new HSSFWorkbook(dn, false);
  embeddedWorkbook.close();
} else if (oleName.equals("Document")) {
  DirectoryNode dn = (DirectoryNode) obj.getDirectory();

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

System.out.println(extractor.getText());
extractor.close();
wb.close();

代码示例来源:origin: com.github.hazendaz/displaytag

wb.close();

相关文章

HSSFWorkbook类方法