From: Yegor Kozlov
Date: Tue, 13 Feb 2007 16:25:55 +0000 (+0000)
Subject: support for auto-sizing worksheet columns
X-Git-Tag: REL_3_0_RC1~8
X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c48613da0a67f364a08ce93716d771b24d608860;p=poi.git
support for auto-sizing worksheet columns
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@507076 13f79535-47bb-0310-9956-ffa450edef68
---
diff --git a/src/documentation/content/xdocs/hssf/quick-guide.xml b/src/documentation/content/xdocs/hssf/quick-guide.xml
index 6c3d964d0c..470dcb4589 100644
--- a/src/documentation/content/xdocs/hssf/quick-guide.xml
+++ b/src/documentation/content/xdocs/hssf/quick-guide.xml
@@ -65,6 +65,7 @@
Images
Named Ranges and Named Cells
How to set cell comments
+
How to adjust column width to fit the contents
Features
@@ -451,9 +452,9 @@
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("format sheet");
HSSFPrintSetup ps = sheet.getPrintSetup();
-
+
sheet.setAutobreaks(true);
-
+
ps.setFitHeight((short)1);
ps.setFitWidth((short)1);
@@ -473,15 +474,15 @@
wb.setPrintArea(0, "$A$1:$C$2");
//sets the print area for the first sheet
//Alternatively:
- //wb.setPrintArea(0, 0, 1, 0, 0) is equivalent to using the name reference (See the JavaDocs for more details)
+ //wb.setPrintArea(0, 0, 1, 0, 0) is equivalent to using the name reference (See the JavaDocs for more details)
// Create various cells and rows for spreadsheet.
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
-
-
+
+
@@ -491,9 +492,9 @@
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("format sheet");
HSSFFooter footer = sheet.getFooter()
-
+
footer.setRight( "Page " + HSSFFooter.page() + " of " + HSSFFooter.numPages() );
-
+
// Create various cells and rows for spreadsheet.
@@ -502,8 +503,8 @@
wb.write(fileOut);
fileOut.close();
-
-
+
+
Using the Convenience Functions
+
Set a sheet as selected
@@ -583,7 +584,7 @@
wb.write(fileOut);
fileOut.close();
-
+
Set the zoom magnification
@@ -709,7 +710,7 @@
HSSFHeader header = sheet.getHeader();
header.setCenter("Center Header");
header.setLeft("Left Header");
- header.setRight(HSSFHeader.font("Stencil-Normal", "Italic") +
+ header.setRight(HSSFHeader.font("Stencil-Normal", "Italic") +
HSSFHeader.fontSize((short) 16) + "Right w/ Stencil-Normal Italic font and size 16");
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
@@ -993,10 +994,10 @@
Named Ranges and Named Cells
- Named Range is a way to refer to a group of cells by a name. Named Cell is a
+ Named Range is a way to refer to a group of cells by a name. Named Cell is a
degenerate case of Named Range in that the 'group of cells' contains exactly one
cell. You can create as well as refer to cells in a workbook by their named range.
- When working with Named Ranges, the classes: org.apache.poi.hssf.util.CellReference and
+ When working with Named Ranges, the classes: org.apache.poi.hssf.util.CellReference and
& org.apache.poi.hssf.util.AreaReference are used.
@@ -1008,25 +1009,25 @@
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet(sname);
sheet.createRow(0).createCell((short) 0).setCellValue(cvalue);
-
+
// 1. create named range for a single cell using areareference
HSSFName namedCell = wb.createName();
namedCell.setNameName(cname);
String reference = sname+"!A1:A1"; // area reference
namedCell.setReference(reference);
-
+
// 2. create named range for a single cell using cellreference
HSSFName namedCell = wb.createName();
namedCell.setNameName(cname);
String reference = sname+"!A1"; // cell reference
namedCell.setReference(reference);
-
+
// 3. create named range for an area using AreaReference
HSSFName namedCell = wb.createName();
namedCell.setNameName(cname);
String reference = sname+"!A1:C5"; // area reference
namedCell.setReference(reference);
-
+
Reading from Named Range / Named Cell
@@ -1039,7 +1040,7 @@
// retrieve the named range
int namedCellIdx = wb.getNameIndex(cellName);
HSSFName aNamedCell = wb.getNameAt(namedCellIdx);
-
+
// retrieve the cell at the named range and test its contents
AreaReference aref = new AreaReference(aNamedCell.getReference());
CellReference[] crefs = aref.getCells();
@@ -1050,7 +1051,7 @@
// extract the cell contents based on cell type etc.
}
-
+
Cell Comments
@@ -1103,7 +1104,7 @@
comment2.setString(string);
//by default comments are hidden. This one is always visible.
- comment2.setVisible(true);
+ comment2.setVisible(true);
comment2.setAuthor("Bill Gates");
@@ -1124,13 +1125,22 @@