Author: onealj
Date: Mon Feb 12 06:42:26 2018
New Revision: 1823925
URL: http://svn.apache.org/viewvc?rev=1823925&view=rev
Log:
bug 61898: update Spreadsheet Quick Guide: short -> int
Modified:
poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml
Modified: poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml
URL:
http://svn.apache.org/viewvc/poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml?rev=1823925&r1=1823924&r2=1823925&view=diff
==============================================================================
--- poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml
(original)
+++ poi/site/src/documentation/content/xdocs/spreadsheet/quick-guide.xml Mon
Feb 12 06:42:26 2018
@@ -134,7 +134,7 @@
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
- Row row = sheet.createRow((short)0);
+ Row row = sheet.createRow(0);
// Create a cell and put a value in it.
Cell cell = row.createCell(0);
cell.setCellValue(1);
@@ -193,7 +193,7 @@
<source>
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");
- Row row = sheet.createRow((short)2);
+ Row row = sheet.createRow(2);
row.createCell(0).setCellValue(1.1);
row.createCell(1).setCellValue(new Date());
row.createCell(2).setCellValue(Calendar.getInstance());
@@ -260,16 +260,16 @@
Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
Sheet sheet = wb.createSheet();
- Row row = sheet.createRow((short) 2);
+ Row row = sheet.createRow(2);
row.setHeightInPoints(30);
- createCell(wb, row, (short) 0, HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM);
- createCell(wb, row, (short) 1, HorizontalAlignment.CENTER_SELECTION,
VerticalAlignment.BOTTOM);
- createCell(wb, row, (short) 2, HorizontalAlignment.FILL,
VerticalAlignment.CENTER);
- createCell(wb, row, (short) 3, HorizontalAlignment.GENERAL,
VerticalAlignment.CENTER);
- createCell(wb, row, (short) 4, HorizontalAlignment.JUSTIFY,
VerticalAlignment.JUSTIFY);
- createCell(wb, row, (short) 5, HorizontalAlignment.LEFT,
VerticalAlignment.TOP);
- createCell(wb, row, (short) 6, HorizontalAlignment.RIGHT,
VerticalAlignment.TOP);
+ createCell(wb, row, 0, HorizontalAlignment.CENTER,
VerticalAlignment.BOTTOM);
+ createCell(wb, row, 1, HorizontalAlignment.CENTER_SELECTION,
VerticalAlignment.BOTTOM);
+ createCell(wb, row, 2, HorizontalAlignment.FILL,
VerticalAlignment.CENTER);
+ createCell(wb, row, 3, HorizontalAlignment.GENERAL,
VerticalAlignment.CENTER);
+ createCell(wb, row, 4, HorizontalAlignment.JUSTIFY,
VerticalAlignment.JUSTIFY);
+ createCell(wb, row, 5, HorizontalAlignment.LEFT,
VerticalAlignment.TOP);
+ createCell(wb, row, 6, HorizontalAlignment.RIGHT,
VerticalAlignment.TOP);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("xssf-align.xlsx");
@@ -287,7 +287,7 @@
* @param halign the horizontal alignment for the cell.
* @param valign the vertical alignment for the cell.
*/
- private static void createCell(Workbook wb, Row row, short column,
HorizontalAlignment halign, VerticalAlignment valign) {
+ private static void createCell(Workbook wb, Row row, int column,
HorizontalAlignment halign, VerticalAlignment valign) {
Cell cell = row.createCell(column);
cell.setCellValue("Align It");
CellStyle cellStyle = wb.createCellStyle();
@@ -467,13 +467,13 @@
Sheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
- Row row = sheet.createRow((short) 1);
+ Row row = sheet.createRow(1);
// Aqua background
CellStyle style = wb.createCellStyle();
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex());
style.setFillPattern(FillPatternType.BIG_SPOTS);
- Cell cell = row.createCell((short) 1);
+ Cell cell = row.createCell(1);
cell.setCellValue("X");
cell.setCellStyle(style);
@@ -481,7 +481,7 @@
style = wb.createCellStyle();
style.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
- cell = row.createCell((short) 2);
+ cell = row.createCell(2);
cell.setCellValue("X");
cell.setCellStyle(style);
@@ -497,8 +497,8 @@
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet("new sheet");
- Row row = sheet.createRow((short) 1);
- Cell cell = row.createCell((short) 1);
+ Row row = sheet.createRow(1);
+ Cell cell = row.createCell(1);
cell.setCellValue("This is a test of merging");
sheet.addMergedRegion(new CellRangeAddress(
@@ -545,8 +545,7 @@
fileOut.close();
</source>
<p>
- Note, the maximum number of unique fonts in a workbook is limited to 32767 (
- the maximum positive short). You should re-use fonts in your applications
instead of
+ Note, the maximum number of unique fonts in a workbook is limited to 32767.
You should re-use fonts in your applications instead of
creating a font for each cell.
Examples:
</p>
@@ -554,7 +553,7 @@ Examples:
<source>
for (int i = 0; i < 10000; i++) {
Row row = sheet.createRow(i);
- Cell cell = row.createCell((short) 0);
+ Cell cell = row.createCell(0);
CellStyle style = workbook.createCellStyle();
Font font = workbook.createFont();
@@ -572,7 +571,7 @@ Examples:
style.setFont(font);
for (int i = 0; i < 10000; i++) {
Row row = sheet.createRow(i);
- Cell cell = row.createCell((short) 0);
+ Cell cell = row.createCell(0);
cell.setCellStyle(style);
}
</source>
@@ -584,8 +583,8 @@ Examples:
<source>
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet();
- HSSFRow row = sheet.createRow((short) 0);
- HSSFCell cell = row.createCell((short) 0);
+ HSSFRow row = sheet.createRow(0);
+ HSSFCell cell = row.createCell(0);
cell.setCellValue("Default Palette");
//apply some colors from the standard palette,
@@ -685,7 +684,7 @@ Examples:
row.setHeightInPoints((2*sheet.getDefaultRowHeightInPoints()));
//adjust column width to fit the content
- sheet.autoSizeColumn((short)2);
+ sheet.autoSizeColumn(2);
FileOutputStream fileOut = new FileOutputStream("ooxml-newlines.xlsx");
wb.write(fileOut);
@@ -701,8 +700,8 @@ Examples:
DataFormat format = wb.createDataFormat();
Row row;
Cell cell;
- short rowNum = 0;
- short colNum = 0;
+ int rowNum = 0;
+ int colNum = 0;
row = sheet.createRow(rowNum++);
cell = row.createCell(colNum);
@@ -806,19 +805,14 @@ Examples:
sheet1.addMergedRegion( region );
// Set the border and border colors.
- final short borderMediumDashed = BorderStyle.MEDIUM_DASHED;
- RegionUtil.setBorderBottom( borderMediumDashed,
- region, sheet1, wb );
- RegionUtil.setBorderTop( borderMediumDashed,
- region, sheet1, wb );
- RegionUtil.setBorderLeft( borderMediumDashed,
- region, sheet1, wb );
- RegionUtil.setBorderRight( borderMediumDashed,
- region, sheet1, wb );
+ RegionUtil.setBorderBottom( BorderStyle.MEDIUM_DASHED, region, sheet1, wb
);
+ RegionUtil.setBorderTop( BorderStyle.MEDIUM_DASHED, region, sheet1, wb
);
+ RegionUtil.setBorderLeft( BorderStyle.MEDIUM_DASHED, region, sheet1, wb
);
+ RegionUtil.setBorderRight( BorderStyle.MEDIUM_DASHED, region, sheet1, wb
);
RegionUtil.setBottomBorderColor(IndexedColors.AQUA.getIndex(), region,
sheet1, wb);
- RegionUtil.setTopBorderColor(IndexedColors.AQUA.getIndex(), region,
sheet1, wb);
- RegionUtil.setLeftBorderColor(IndexedColors.AQUA.getIndex(), region,
sheet1, wb);
- RegionUtil.setRightBorderColor(IndexedColors.AQUA.getIndex(), region,
sheet1, wb);
+ RegionUtil.setTopBorderColor( IndexedColors.AQUA.getIndex(), region,
sheet1, wb);
+ RegionUtil.setLeftBorderColor( IndexedColors.AQUA.getIndex(), region,
sheet1, wb);
+ RegionUtil.setRightBorderColor( IndexedColors.AQUA.getIndex(), region,
sheet1, wb);
// Shows some usages of HSSFCellUtil
CellStyle style = wb.createCellStyle();
@@ -1119,8 +1113,8 @@ Examples:
// Create a couple of lines in the group.
HSSFSimpleShape shape1 = group.createShape(new
HSSFChildAnchor(3,3,500,500));
shape1.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
- ( (HSSFChildAnchor) shape1.getAnchor() ).setAnchor((short)3,3,500,500);
- HSSFSimpleShape shape2 = group.createShape(new
HSSFChildAnchor((short)1,200,400,600));
+ ( (HSSFChildAnchor) shape1.getAnchor() ).setAnchor(3,3,500,500);
+ HSSFSimpleShape shape2 = group.createShape(new
HSSFChildAnchor(1,200,400,600));
shape2.setShapeType(HSSFSimpleShape.OBJECT_TYPE_LINE);
</source>
<p>
@@ -1265,9 +1259,9 @@ Examples:
sheet1.groupRow( 7, 14 );
sheet1.groupRow( 16, 19 );
- sheet1.groupColumn( (short)4, (short)7 );
- sheet1.groupColumn( (short)9, (short)12 );
- sheet1.groupColumn( (short)10, (short)11 );
+ sheet1.groupColumn( 4, 7 );
+ sheet1.groupColumn( 9, 12 );
+ sheet1.groupColumn( 10, 11 );
FileOutputStream fileOut = new FileOutputStream(filename);
wb.write(fileOut);
@@ -1278,7 +1272,7 @@ Examples:
</p>
<source>
sheet1.setRowGroupCollapsed( 7, true );
- sheet1.setColumnGroupCollapsed( (short)4, true );
+ sheet1.setColumnGroupCollapsed( 4, true );
</source>
<p>
The row/column you choose should contain an already
@@ -1383,7 +1377,7 @@ Examples:
String sname = "TestSheet", cname = "TestName", cvalue = "TestVal";
Workbook wb = new HSSFWorkbook();
Sheet sheet = wb.createSheet(sname);
- sheet.createRow(0).createCell((short) 0).setCellValue(cvalue);
+ sheet.createRow(0).createCell(0).setCellValue(cvalue);
// 1. create named range for a single cell using areareference
Name namedCell = wb.createName();
@@ -1522,7 +1516,7 @@ Examples:
Reading cell comments
</p>
<source>
- Cell cell = sheet.get(3).getColumn((short)1);
+ Cell cell = sheet.get(3).getColumn(1);
Comment comment = cell.getCellComment();
if (comment != null) {
RichTextString str = comment.getString();
@@ -1602,7 +1596,7 @@ Examples:
<source>
Sheet sheet = workbook.getSheetAt(0);
- Cell cell = sheet.getRow(0).getCell((short)0);
+ Cell cell = sheet.getRow(0).getCell(0);
Hyperlink link = cell.getHyperlink();
if(link != null){
System.out.println(link.getAddress());
@@ -1625,7 +1619,7 @@ Examples:
Cell cell;
Sheet sheet = wb.createSheet("Hyperlinks");
//URL
- cell = sheet.createRow(0).createCell((short)0);
+ cell = sheet.createRow(0).createCell(0);
cell.setCellValue("URL Link");
Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
@@ -1634,7 +1628,7 @@ Examples:
cell.setCellStyle(hlink_style);
//link to a file in the current directory
- cell = sheet.createRow(1).createCell((short)0);
+ cell = sheet.createRow(1).createCell(0);
cell.setCellValue("File Link");
link = createHelper.createHyperlink(Hyperlink.LINK_FILE);
link.setAddress("link1.xls");
@@ -1642,7 +1636,7 @@ Examples:
cell.setCellStyle(hlink_style);
//e-mail link
- cell = sheet.createRow(2).createCell((short)0);
+ cell = sheet.createRow(2).createCell(0);
cell.setCellValue("Email Link");
link = createHelper.createHyperlink(Hyperlink.LINK_EMAIL);
//note, if subject contains white spaces, make sure they are url-encoded
@@ -1654,9 +1648,9 @@ Examples:
//create a target sheet and cell
Sheet sheet2 = wb.createSheet("Target Sheet");
- sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell");
+ sheet2.createRow(0).createCell(0).setCellValue("Target Cell");
- cell = sheet.createRow(3).createCell((short)0);
+ cell = sheet.createRow(3).createCell(0);
cell.setCellValue("Worksheet Link");
Hyperlink link2 = createHelper.createHyperlink(Hyperlink.LINK_DOCUMENT);
link2.setAddress("'Target Sheet'!A1");
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]