⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 busy developers' guide to hssf features.htm

📁 Jakarta POI 是apache的子项目
💻 HTM
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!-- saved from url=(0043)http://poi.apache.org/hssf/quick-guide.html -->
<HTML><HEAD><TITLE>Busy Developers' Guide to HSSF Features</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8"><!--*** This is a generated file.  Do not edit.  ***--><LINK 
href="Busy Developers' Guide to HSSF Features.files/tigris.css" type=text/css 
rel=stylesheet><LINK 
href="Busy Developers' Guide to HSSF Features.files/mysite.css" type=text/css 
rel=stylesheet><LINK 
href="Busy Developers' Guide to HSSF Features.files/site.css" type=text/css 
rel=stylesheet><LINK media=print 
href="Busy Developers' Guide to HSSF Features.files/print.css" type=text/css 
rel=stylesheet>
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY class=composite bgColor=white><!--================= start Banner ==================-->
<DIV id=banner>
<TABLE cellSpacing=0 cellPadding=8 width="100%" summary=banner border=0>
  <TBODY>
  <TR><!--================= start Group Logo ==================-->
    <TD align=left>
      <DIV class=groupLogo><A href="http://poi.apache.org/"><IMG class=logoImage 
      alt="Apache POI" 
      src="Busy Developers' Guide to HSSF Features.files/group-logo.jpg" 
      border=0></A> </DIV></TD><!--================= end Group Logo ==================--><!--================= start Project Logo ==================-->
    <TD align=right>
      <DIV class=projectLogo><A href="http://poi.apache.org/"><IMG 
      class=logoImage alt=POI 
      src="Busy Developers' Guide to HSSF Features.files/project-logo.jpg" 
      border=0></A> </DIV></TD><!--================= end Project Logo ==================--></TR></TBODY></TABLE></DIV><!--================= end Banner ==================--><!--================= start Main ==================-->
<TABLE id=breadcrumbs cellSpacing=0 cellPadding=0 width="100%" summary=nav 
border=0>
  <TBODY><!--================= start Status ==================-->
  <TR class=status>
    <TD><!--================= start BreadCrumb ==================--><A 
      href="http://www.apache.org/">Apache</A> | <A 
      href="http://poi.apache.org/">POI</A><A 
      href="http://poi.apache.org/hssf/"></A> <!--================= end BreadCrumb ==================--></TD>
    <TD id=tabs><!--================= start Tabs ==================-->
      <DIV class=tab><SPAN class=selectedTab><A class=base-selected 
      href="http://poi.apache.org/index.html">Home</A></SPAN> |
      <SCRIPT language=Javascript type=text/javascript>function printit() {  if (window.print) {    window.print() ;  } else {    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH="0" HEIGHT="0" CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';document.body.insertAdjacentHTML('beforeEnd', WebBrowser);    WebBrowser1.ExecWB(6, 2);//Use a 1 vs. a 2 for a prompting dialog box    WebBrowser1.outerHTML = "";  }}</SCRIPT>

      <SCRIPT language=Javascript type=text/javascript>var NS = (navigator.appName == "Netscape");var VERSION = parseInt(navigator.appVersion);if (VERSION > 3) {    document.write('  <a title="PRINT this page OUT" href="javascript:printit()">PRINT</a>');}</SCRIPT>
       | <A title="PDF file of this page" 
      href="http://poi.apache.org/hssf/quick-guide.pdf">PDF</A> </DIV><!--================= end Tabs ==================--></TD></TR></TBODY></TABLE><!--================= end Status ==================-->
<TABLE id=main cellSpacing=0 cellPadding=8 width="100%" summary="" border=0>
  <TBODY>
  <TR vAlign=top><!--================= start Menu ==================-->
    <TD id=leftcol>
      <DIV id=navcolumn>
      <DIV class=menuBar>
      <DIV class=menu><SPAN class=menuLabel>Apache POI</SPAN> 
      <DIV class=menuItem><A href="http://poi.apache.org/index.html">Top</A> 
      </DIV></DIV>
      <DIV class=menu><SPAN class=menuLabel>HSSF</SPAN> 
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/index.html">Overview</A> </DIV>
      <DIV class=menuItem><SPAN class=menuSelected>Quick Guide</SPAN> </DIV>
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/how-to.html">HOWTO</A> </DIV>
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/formula.html">Formula Support</A> </DIV>
      <DIV class=menuItem><A href="http://poi.apache.org/hssf/eval.html">Formula 
      Evaluation</A> </DIV>
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/eval-devguide.html">Eval Dev Guide</A> 
      </DIV>
      <DIV class=menuItem><A href="http://poi.apache.org/hssf/use-case.html">Use 
      Case</A> </DIV>
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/diagrams.html">Pictorial Docs</A> </DIV>
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/limitations.html">Limitations</A> 
      </DIV></DIV>
      <DIV class=menu><SPAN class=menuLabel>Contributer's Guide</SPAN> 
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/hacking-hssf.html">Hacking HSSF</A> 
</DIV>
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/record-generator.html">Record 
      Generator</A> </DIV>
      <DIV class=menuItem><A 
      href="http://poi.apache.org/hssf/chart.html">Charts</A> 
      </DIV></DIV></DIV></DIV>
      <FORM action=http://www.google.com/search method=get target=_blank>
      <TABLE cellSpacing=0 cellPadding=0 summary=search border=0>
        <TBODY>
        <TR>
          <TD><IMG class=spacer height=1 alt="" 
            src="Busy Developers' Guide to HSSF Features.files/spacer.gif" 
            width=1></TD>
          <TD noWrap><INPUT type=hidden value=poi.apache.org 
            name=sitesearch><INPUT id=query size=10 name=q><IMG class=spacer 
            height=1 alt="" 
            src="Busy Developers' Guide to HSSF Features.files/spacer.gif" 
            width=5><INPUT type=submit value=GO name=Search> <BR>Search poi</TD>
          <TD><IMG class=spacer height=1 alt="" 
            src="Busy Developers' Guide to HSSF Features.files/spacer.gif" 
            width=1></TD></TR>
        <TR>
          <TD colSpan=3><IMG class=spacer height=7 alt="" 
            src="Busy Developers' Guide to HSSF Features.files/spacer.gif" 
            width=1></TD></TR>
        <TR>
          <TD class=bottom-left-thick></TD>
          <TD bgColor=#a5b6c6><IMG class=spacer height=1 alt="" 
            src="Busy Developers' Guide to HSSF Features.files/spacer.gif" 
            width=1></TD>
          <TD class=bottom-right-thick></TD></TR></TBODY></TABLE></FORM></TD><!--================= end Menu ==================--><!--================= start Content ==================-->
    <TD>
      <DIV id=bodycol>
      <DIV class=app>
      <DIV align=center>
      <H1>Busy Developers' Guide to HSSF Features</H1></DIV>
      <DIV class=h3>
      <DIV class=h3>
      <H3>Busy Developers' Guide to Features</H3></DIV>
      <P>Want to use HSSF read and write spreadsheets in a hurry? This guide is 
      for you. If you're after more in-depth coverage of the HSSF user-API 
      please consult the <A 
      href="http://poi.apache.org/hssf/how-to.html">HOWTO</A> guide as it 
      contains actual descriptions of how to use this stuff. </P>
      <DIV class=h4>
      <H4>Index of Features</H4></DIV>
      <UL>
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#NewWorkbook">How to 
        create a new workbook</A> 
        <LI><A href="http://poi.apache.org/hssf/quick-guide.html#NewSheet">How 
        to create a sheet</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#CreateCells">How to 
        create cells</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#CreateDateCells">How 
        to create date cells</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#CellTypes">Working 
        with different types of cells</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#Iterator">Iterate over 
        rows and cells</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#TextExtraction">Text 
        Extraction</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#Alignment">Aligning 
        cells</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#Borders">Working with 
        borders</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#FrillsAndFills">Fills 
        and color</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#MergedCells">Merging 
        cells</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#WorkingWithFonts">Working 
        with fonts</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#CustomColors">Custom 
        colors</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#ReadWriteWorkbook">Reading 
        and writing</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#NewLinesInCells">Use 
        newlines in cells.</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#DataFormats">Create 
        user defined data formats</A> 
        <LI><A href="http://poi.apache.org/hssf/quick-guide.html#FitTo">Fit 
        Sheet to One Page</A> 
        <LI><A href="http://poi.apache.org/hssf/quick-guide.html#PrintArea2">Set 
        print area for a sheet</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#FooterPageNumbers">Set 
        page numbers on the footer of a sheet</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#ShiftRows">Shift 
        rows</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#SelectSheet">Set a 
        sheet as selected</A> 
        <LI><A href="http://poi.apache.org/hssf/quick-guide.html#Zoom">Set the 
        zoom magnification for a sheet</A> 
        <LI><A href="http://poi.apache.org/hssf/quick-guide.html#Splits">Create 
        split and freeze panes</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#Repeating">Repeating 
        rows and columns</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#HeaderFooter">Headers 
        and Footers</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#DrawingShapes">Drawing 
        Shapes</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#StylingShapes">Styling 
        Shapes</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#Graphics2d">Shapes and 
        Graphics2d</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#Outlining">Outlining</A> 

        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#Images">Images</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#NamedRanges">Named 
        Ranges and Named Cells</A> 
        <LI><A 
        href="http://poi.apache.org/hssf/quick-guide.html#CellComments">How to 
        set cell comments</A> 
        <LI><A href="http://poi.apache.org/hssf/quick-guide.html#Autofit">How to 
        adjust column width to fit the contents</A> </LI></UL>
      <DIV class=h4>
      <H4>Features</H4></DIV><A name=NewWorkbook></A>
      <DIV class=h2>
      <H2>New Workbook</H2></DIV><PRE class=code>    HSSFWorkbook wb = new HSSFWorkbook();
    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
    wb.write(fileOut);
    fileOut.close();
                    </PRE><A name=NewSheet></A>
      <DIV class=h2>
      <H2>New Sheet</H2></DIV><PRE class=code>    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet1 = wb.createSheet("new sheet");
    HSSFSheet sheet2 = wb.createSheet("second sheet");
    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
    wb.write(fileOut);
    fileOut.close();
                    </PRE><A name=CreateCells></A>
      <DIV class=h2>
      <H2>Creating Cells</H2></DIV><PRE class=code>    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");

    // Create a row and put some cells in it. Rows are 0 based.
    HSSFRow row = sheet.createRow((short)0);
    // Create a cell and put a value in it.
    HSSFCell cell = row.createCell((short)0);
    cell.setCellValue(1);

    // Or do it on one line.
    row.createCell((short)1).setCellValue(1.2);
    row.createCell((short)2).setCellValue("This is a string");
    row.createCell((short)3).setCellValue(true);

    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
    wb.write(fileOut);
    fileOut.close();
                    </PRE><A name=CreateDateCells></A>
      <DIV class=h2>
      <H2>Creating Date Cells</H2></DIV><PRE class=code>    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");

    // Create a row and put some cells in it. Rows are 0 based.
    HSSFRow row = sheet.createRow((short)0);

    // Create a cell and put a date value in it.  The first cell is not styled
    // as a date.
    HSSFCell cell = row.createCell((short)0);
    cell.setCellValue(new Date());

    // we style the second cell as a date (and time).  It is important to
    // create a new cell style from the workbook otherwise you can end up
    // modifying the built in style and effecting not only this cell but other cells.
    HSSFCellStyle cellStyle = wb.createCellStyle();
    cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("m/d/yy h:mm"));
    cell = row.createCell((short)1);
    cell.setCellValue(new Date());
    cell.setCellStyle(cellStyle);

    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream("workbook.xls");
    wb.write(fileOut);
    fileOut.close();
                    </PRE><A name=CellTypes></A>
      <DIV class=h2>
      <H2>Working with different types of cells</H2></DIV><PRE class=code>    HSSFWorkbook wb = new HSSFWorkbook();
    HSSFSheet sheet = wb.createSheet("new sheet");
    HSSFRow row = sheet.createRow((short)2);
    row.createCell((short) 0).setCellValue(1.1);
    row.createCell((short) 1).setCellValue(new Date());
    row.createCell((short) 2).setCellValue("a string");
    row.createCell((short) 3).setCellValue(true);
    row.createCell((short) 4).setCellType(HSSFCell.CELL_TYPE_ERROR);

    // Write the output to a file
    FileOutputStream fileOut = new FileOutputStream("workbook.xls");

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -