ASF Bugzilla – Attachment 22726 Details for
Bug 46004
implementd examples
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
examples
20081014Examples.diff (text/plain), 6.13 KB, created by
Gisella Bronzetti
on 2008-10-14 06:19:57 UTC
(
hide
)
Description:
examples
Filename:
MIME Type:
Creator:
Gisella Bronzetti
Created:
2008-10-14 06:19:57 UTC
Size:
6.13 KB
patch
obsolete
>Index: src/examples/src/org/apache/poi/xssf/usermodel/examples/PageNumberOnFooter.java >=================================================================== >--- src/examples/src/org/apache/poi/xssf/usermodel/examples/PageNumberOnFooter.java (revision 0) >+++ src/examples/src/org/apache/poi/xssf/usermodel/examples/PageNumberOnFooter.java (revision 0) >@@ -0,0 +1,29 @@ >+package org.apache.poi.xssf.usermodel.examples; >+ >+import java.io.FileOutputStream; >+ >+import org.apache.poi.ss.usermodel.Footer; >+import org.apache.poi.ss.usermodel.Sheet; >+import org.apache.poi.ss.usermodel.Workbook; >+import org.apache.poi.xssf.usermodel.XSSFWorkbook; >+ >+public class PageNumberOnFooter { >+ >+ >+ public static void main(String[]args) throws Exception{ >+ Workbook wb = new XSSFWorkbook(); >+ Sheet sheet = wb.createSheet("format sheet"); >+ sheet.createRow(0).createCell(0).setCellValue(123); >+ Footer footer = sheet.getFooter(); >+ //&P == current page number >+ //&N == page numbers >+ footer.setRight( "Page &P of &N" ); >+ >+ // Create various cells and rows for spreadsheet. >+ >+ FileOutputStream fileOut = new FileOutputStream("pageNumerOnFooter.xlsx"); >+ wb.write(fileOut); >+ fileOut.close(); >+ >+ } >+} >Index: src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java >=================================================================== >--- src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java (revision 0) >+++ src/examples/src/org/apache/poi/xssf/usermodel/examples/SelectedSheet.java (revision 0) >@@ -0,0 +1,28 @@ >+package org.apache.poi.xssf.usermodel.examples; >+ >+import java.io.FileOutputStream; >+ >+import org.apache.poi.ss.usermodel.Sheet; >+import org.apache.poi.ss.usermodel.Workbook; >+import org.apache.poi.xssf.usermodel.XSSFWorkbook; >+ >+public class SelectedSheet { >+ >+ public static void main(String[]args) throws Exception{ >+ Workbook wb = new XSSFWorkbook(); >+ Sheet sheet = wb.createSheet("row sheet"); >+ >+ Sheet sheet2 = wb.createSheet("another sheet"); >+ Sheet sheet3 = wb.createSheet(" sheet 3 "); >+ sheet3.setSelected(true); >+ >+ // Create various cells and rows for spreadsheet. >+ >+ FileOutputStream fileOut = new FileOutputStream("selectedSheet.xlsx"); >+ wb.write(fileOut); >+ fileOut.close(); >+ >+ >+ } >+ >+} >Index: src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java >=================================================================== >--- src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java (revision 0) >+++ src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java (revision 0) >@@ -0,0 +1,79 @@ >+package org.apache.poi.xssf.usermodel.examples; >+ >+import java.io.FileOutputStream; >+ >+import org.apache.poi.hssf.usermodel.HSSFFont; >+import org.apache.poi.hssf.util.HSSFColor; >+import org.apache.poi.ss.usermodel.Cell; >+import org.apache.poi.ss.usermodel.CellStyle; >+import org.apache.poi.ss.usermodel.CreationHelper; >+import org.apache.poi.ss.usermodel.Font; >+import org.apache.poi.ss.usermodel.Hyperlink; >+import org.apache.poi.ss.usermodel.Sheet; >+import org.apache.poi.ss.usermodel.Workbook; >+import org.apache.poi.xssf.usermodel.XSSFHyperlink; >+import org.apache.poi.xssf.usermodel.XSSFWorkbook; >+ >+public class HyperlinkExample { >+ >+ >+ public static void main(String[]args) throws Exception{ >+ Workbook wb = new XSSFWorkbook(); >+ >+ //cell style for hyperlinks >+ //by default hypelrinks are blue and underlined >+ CellStyle hlink_style = wb.createCellStyle(); >+ Font hlink_font = wb.createFont(); >+ hlink_font.setUnderline(HSSFFont.U_SINGLE); >+ hlink_font.setColor(HSSFColor.BLUE.index); >+ hlink_style.setFont(hlink_font); >+ >+ Cell cell; >+ Sheet sheet = wb.createSheet("Hyperlinks"); >+ CreationHelper createHelper = wb.getCreationHelper(); >+ //URL >+ cell = sheet.createRow(0).createCell((short)0); >+ cell.setCellValue("URL Link"); >+ >+ Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL); >+ link.setAddress("http://poi.apache.org/"); >+ cell.setHyperlink(link); >+ cell.setCellStyle(hlink_style); >+ >+ //link to a file in the current directory >+ cell = sheet.createRow(1).createCell((short)0); >+ cell.setCellValue("File Link"); >+ link = createHelper.createHyperlink(Hyperlink.LINK_FILE); >+ link.setAddress("link1.xls"); >+ cell.setHyperlink(link); >+ cell.setCellStyle(hlink_style); >+ >+ //e-mail link >+ cell = sheet.createRow(2).createCell((short)0); >+ cell.setCellValue("Email Link"); >+ link = createHelper.createHyperlink(Hyperlink.LINK_EMAIL); >+ //note, if subject contains white spaces, make sure they are url-encoded >+ link.setAddress("mailto:poi@apache.org?subject=Hyperlinks"); >+ cell.setHyperlink(link); >+ cell.setCellStyle(hlink_style); >+ >+ //link to a place in this workbook >+ >+ //create a target sheet and cell >+ Sheet sheet2 = wb.createSheet("Target Sheet"); >+ sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell"); >+ >+ cell = sheet.createRow(3).createCell((short)0); >+ cell.setCellValue("Worksheet Link"); >+ XSSFHyperlink link2 = (XSSFHyperlink)createHelper.createHyperlink(Hyperlink.LINK_DOCUMENT); >+ link2.setAddress("'Target Sheet'!A1"); >+ link2.setLocation("'Target Sheet'!A1"); >+ cell.setHyperlink(link2); >+ cell.setCellStyle(hlink_style); >+ >+ FileOutputStream out = new FileOutputStream("hyperinks.xlsx"); >+ wb.write(out); >+ out.close(); >+ >+ } >+} >Index: src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java >=================================================================== >--- src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java (revision 704016) >+++ src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFHyperlink.java (working copy) >@@ -124,10 +124,18 @@ > public String getLabel() { > return ctHyperlink.getDisplay(); > } >+ public String getLocation() { >+ return ctHyperlink.getLocation(); >+ } > > public void setLabel(String label) { > ctHyperlink.setDisplay(label); > } >+ >+ public void setLocation(String location){ >+ ctHyperlink.setLocation(location); >+ } >+ > public void setAddress(String address) { > location = address; > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 46004
: 22726