net.sf.excelutils
Class WorkbookUtils

java.lang.Object
  extended bynet.sf.excelutils.WorkbookUtils

public class WorkbookUtils
extends java.lang.Object

WorkbookUtils is a helper of Microsoft Excel,it's based on POI project

Version:
$Revision: 1.10 $ $Date: 2005/10/28 00:54:01 $
Author:
rainsoft

Constructor Summary
WorkbookUtils()
           
 
Method Summary
static void copyRow(HSSFSheet sheet, int from, int to, int count)
          copy row
static boolean getBooleanCellValue(HSSFSheet sheet, int rowNum, int colNum)
          get value of the cell
static HSSFCell getCell(HSSFRow row, int column)
          get Cell, if not exists, create
static HSSFCell getCell(HSSFSheet sheet, int rowNum, int colNum)
          get cell, if not exists, create
static java.util.Date getDateCellValue(HSSFSheet sheet, int rowNum, int colNum)
          get value of the cell
static double getNumericCellValue(HSSFSheet sheet, int rowNum, int colNum)
          get value of the cell
static HSSFRow getRow(int rowCounter, HSSFSheet sheet)
          get Row, if not exists, create
static java.lang.String getStringCellValue(HSSFSheet sheet, int rowNum, int colNum)
          get value of the cell
static HSSFWorkbook openWorkbook(java.io.InputStream in)
          Open an excel from InputStream
static HSSFWorkbook openWorkbook(ServletContext ctx, java.lang.String config)
          Open Excel File
static HSSFWorkbook openWorkbook(java.lang.String fileName)
          Open an excel file by real fileName
static void SaveWorkbook(HSSFWorkbook wb, java.io.OutputStream out)
          Save the Excel to OutputStream
static void setCellValue(HSSFSheet sheet, int rowNum, int colNum, boolean value)
          set value of the cell
static void setCellValue(HSSFSheet sheet, int rowNum, int colNum, java.util.Date value)
          set value of the cell
static void setCellValue(HSSFSheet sheet, int rowNum, int colNum, double value)
          set value of the cell
static void setCellValue(HSSFSheet sheet, int rowNum, int colNum, java.lang.String value)
          Set value of the cell
static void setCellValue(HSSFSheet sheet, int rowNum, int colNum, java.lang.String value, short encoding)
          set value of the cell
static void shiftCell(HSSFSheet sheet, HSSFRow row, HSSFCell beginCell, int shift, int rowCount)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WorkbookUtils

public WorkbookUtils()
Method Detail

openWorkbook

public static HSSFWorkbook openWorkbook(ServletContext ctx,
                                        java.lang.String config)
                                 throws ExcelException
Open Excel File

Parameters:
ctx - ServletContext
config - Excel Template Name
Returns:
HSSFWorkbook
Throws:
ExcelException

openWorkbook

public static HSSFWorkbook openWorkbook(java.lang.String fileName)
                                 throws ExcelException
Open an excel file by real fileName

Parameters:
fileName -
Returns:
HSSFWorkbook
Throws:
ExcelException

openWorkbook

public static HSSFWorkbook openWorkbook(java.io.InputStream in)
                                 throws ExcelException
Open an excel from InputStream

Parameters:
in -
Returns:
HSSFWorkbook
Throws:
ExcelException

SaveWorkbook

public static void SaveWorkbook(HSSFWorkbook wb,
                                java.io.OutputStream out)
                         throws ExcelException
Save the Excel to OutputStream

Parameters:
wb - HSSFWorkbook
out - OutputStream
Throws:
ExcelException

setCellValue

public static void setCellValue(HSSFSheet sheet,
                                int rowNum,
                                int colNum,
                                java.lang.String value)
Set value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
value - String

getStringCellValue

public static java.lang.String getStringCellValue(HSSFSheet sheet,
                                                  int rowNum,
                                                  int colNum)
get value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
Returns:
String

setCellValue

public static void setCellValue(HSSFSheet sheet,
                                int rowNum,
                                int colNum,
                                java.lang.String value,
                                short encoding)
set value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
value - String
encoding - short

setCellValue

public static void setCellValue(HSSFSheet sheet,
                                int rowNum,
                                int colNum,
                                double value)
set value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
value - double

getNumericCellValue

public static double getNumericCellValue(HSSFSheet sheet,
                                         int rowNum,
                                         int colNum)
get value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
Returns:
double

setCellValue

public static void setCellValue(HSSFSheet sheet,
                                int rowNum,
                                int colNum,
                                java.util.Date value)
set value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
value - Date

getDateCellValue

public static java.util.Date getDateCellValue(HSSFSheet sheet,
                                              int rowNum,
                                              int colNum)
get value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
Returns:
Date

setCellValue

public static void setCellValue(HSSFSheet sheet,
                                int rowNum,
                                int colNum,
                                boolean value)
set value of the cell

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
value - boolean

getBooleanCellValue

public static boolean getBooleanCellValue(HSSFSheet sheet,
                                          int rowNum,
                                          int colNum)
get value of the cell

Parameters:
sheet -
rowNum -
colNum -
Returns:
boolean value

getRow

public static HSSFRow getRow(int rowCounter,
                             HSSFSheet sheet)
get Row, if not exists, create

Parameters:
rowCounter - int
sheet - HSSFSheet
Returns:
HSSFRow

getCell

public static HSSFCell getCell(HSSFRow row,
                               int column)
get Cell, if not exists, create

Parameters:
row - HSSFRow
column - int
Returns:
HSSFCell

getCell

public static HSSFCell getCell(HSSFSheet sheet,
                               int rowNum,
                               int colNum)
get cell, if not exists, create

Parameters:
sheet - HSSFSheet
rowNum - int
colNum - int
Returns:
HSSFCell

copyRow

public static void copyRow(HSSFSheet sheet,
                           int from,
                           int to,
                           int count)
copy row

Parameters:
sheet -
from - begin of the row
to - destination fo the row
count - count of copy

shiftCell

public static void shiftCell(HSSFSheet sheet,
                             HSSFRow row,
                             HSSFCell beginCell,
                             int shift,
                             int rowCount)


Copyright (C) 200-2005 The ExcelUtils Project.