diff options
author | Javen O'Neal <onealj@apache.org> | 2016-07-04 10:15:18 +0000 |
---|---|---|
committer | Javen O'Neal <onealj@apache.org> | 2016-07-04 10:15:18 +0000 |
commit | 8d31c01f4035aaa40467d96fe1de1f88ed801cf8 (patch) | |
tree | 41f1ce223e92a49154a096a3e5f0c5d55a174975 /src/examples | |
parent | fb8c79d96c2f0ddffb13f5b96c0f65b66c77ce5f (diff) | |
download | poi-8d31c01f4035aaa40467d96fe1de1f88ed801cf8.tar.gz poi-8d31c01f4035aaa40467d96fe1de1f88ed801cf8.zip |
bug 59791: replace deprecated Cell.CELL_TYPE_* usage with CellType.*
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1751240 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
6 files changed, 53 insertions, 29 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java index 07b9b0165a..3e31d11f26 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/CellTypes.java @@ -17,15 +17,15 @@ package org.apache.poi.hssf.usermodel.examples; -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; - import java.io.FileOutputStream; import java.io.IOException; import java.util.Date; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellType; + public class CellTypes { public static void main(String[] args) throws IOException { HSSFWorkbook wb = new HSSFWorkbook(); @@ -35,7 +35,7 @@ public class CellTypes { row.createCell(1).setCellValue(new Date()); row.createCell(2).setCellValue("a string"); row.createCell(3).setCellValue(true); - row.createCell(4).setCellType(HSSFCell.CELL_TYPE_ERROR); + row.createCell(4).setCellType(CellType.ERROR); // Write the output to a file FileOutputStream fileOut = new FileOutputStream("workbook.xls"); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java index 8ed9213bfa..148b2a58b0 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/HyperlinkFormula.java @@ -17,11 +17,15 @@ package org.apache.poi.hssf.usermodel.examples; -import org.apache.poi.hssf.usermodel.*; - import java.io.FileOutputStream; import java.io.IOException; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.CellType; + /** * Test if hyperlink formula, with url that got more than 127 characters, works * @@ -34,7 +38,7 @@ public class HyperlinkFormula { HSSFRow row = sheet.createRow(0); HSSFCell cell = row.createCell(0); - cell.setCellType(HSSFCell.CELL_TYPE_FORMULA); + cell.setCellType(CellType.FORMULA); cell.setCellFormula("HYPERLINK(\"http://127.0.0.1:8080/toto/truc/index.html?test=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\", \"test\")"); FileOutputStream fileOut = new FileOutputStream("workbook.xls"); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java index 7653a0b527..018556f991 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/NewLinesInCells.java @@ -18,6 +18,7 @@ package org.apache.poi.hssf.usermodel.examples; import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.CellType; import java.io.FileOutputStream; import java.io.IOException; @@ -47,7 +48,7 @@ public class NewLinesInCells { r = s.createRow(2); r.setHeight((short) 0x349); c = r.createCell(2); - c.setCellType(HSSFCell.CELL_TYPE_STRING); + c.setCellType(CellType.STRING); c.setCellValue("Use \n with word wrap on to create a new line"); c.setCellStyle(cs); s.setColumnWidth(2, (int) ((50 * 8) / ((double) 1 / 20))); diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java index 26bba44674..2b3553f768 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/ReadWriteWorkbook.java @@ -17,16 +17,17 @@ package org.apache.poi.hssf.usermodel.examples; -import org.apache.poi.poifs.filesystem.POIFSFileSystem; -import org.apache.poi.hssf.usermodel.HSSFWorkbook; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.hssf.usermodel.HSSFRow; -import org.apache.poi.hssf.usermodel.HSSFCell; - import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.poifs.filesystem.POIFSFileSystem; +import org.apache.poi.ss.usermodel.CellType; + /** * This example demonstrates opening a workbook, modifying it and writing * the results back out. @@ -50,7 +51,7 @@ public class ReadWriteWorkbook { HSSFCell cell = row.getCell(3); if (cell == null) cell = row.createCell(3); - cell.setCellType(HSSFCell.CELL_TYPE_STRING); + cell.setCellType(CellType.STRING); cell.setCellValue("a test"); // Write the output to a file diff --git a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java index caace28f7f..b33d8cba10 100644 --- a/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java +++ b/src/examples/src/org/apache/poi/hssf/view/SVSheetTable.java @@ -16,20 +16,37 @@ ==================================================================== */ package org.apache.poi.hssf.view; -import org.apache.poi.hssf.view.brush.PendingPaintings; -import org.apache.poi.hssf.usermodel.HSSFCell; -import org.apache.poi.hssf.usermodel.HSSFSheet; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.Row; +import java.awt.Color; +import java.awt.Component; +import java.awt.Container; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.Toolkit; +import java.awt.event.HierarchyEvent; +import java.awt.event.HierarchyListener; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.JViewport; +import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import javax.swing.table.*; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import javax.swing.table.TableColumn; +import javax.swing.table.TableColumnModel; +import javax.swing.table.TableModel; import javax.swing.text.JTextComponent; -import java.awt.*; -import java.awt.event.HierarchyEvent; -import java.awt.event.HierarchyListener; + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.view.brush.PendingPaintings; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.Row; /** * This class is a table that represents the values in a single worksheet. @@ -125,7 +142,7 @@ public class SVSheetTable extends JTable { HSSFCell cell = (HSSFCell) getValueAt(row, col); String formula = ""; if (cell != null) { - if (cell.getCellType() == Cell.CELL_TYPE_FORMULA) { + if (cell.getCellType() == CellType.FORMULA) { formula = cell.getCellFormula(); } else { formula = cell.toString(); diff --git a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java index 67b6d56a6d..616f838706 100644 --- a/src/examples/src/org/apache/poi/ss/examples/ToCSV.java +++ b/src/examples/src/org/apache/poi/ss/examples/ToCSV.java @@ -29,6 +29,7 @@ import java.util.ArrayList; import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.DataFormatter; import org.apache.poi.ss.usermodel.FormulaEvaluator; import org.apache.poi.ss.usermodel.Row; @@ -541,7 +542,7 @@ public class ToCSV { csvLine.add(""); } else { - if(cell.getCellType() != Cell.CELL_TYPE_FORMULA) { + if(cell.getCellType() != CellType.FORMULA) { csvLine.add(this.formatter.formatCellValue(cell)); } else { |