public class HTMLTable
extends java.lang.Object
Title:HTMLTable 用于合成html table,描述的是表格table
Description:
构造器和说明 |
---|
HTMLTable()
无参数构造函数
|
HTMLTable(boolean createTableTag)
构造函数,传入的参数决定在生成HTML的时候是否生成table标签对
|
限定符和类型 | 方法和说明 |
---|---|
void |
autoColMerge(int col)
自动合并指定列
|
void |
autoRangeMerge(int row1,
int col1,
int row2,
int col2)
指定区域 自动合并(表格内容相同则合并)
|
void |
autoRowMerge(int row)
自动合并指定行
|
static HTMLTable |
createHTMLTable(Datastore ds)
根据传入的Datastore创建一个HTMLTable的实例
|
static HTMLTable |
createHTMLTable(Datastore ds,
java.lang.String[] colsName)
通过datastore创建一个HTMLTable对象
|
void |
createTable(int rows,
int cols)
指定行数和列数,初始化表格
|
java.lang.String |
getHTML()
获取table的html字符串
|
java.lang.Object |
getValue(int row,
int col)
取得某一个单元格的值
|
void |
insertCol(int col)
插入新的列
|
void |
insertRow(int row)
插入新的行
|
void |
removeCol(int col)
删除指定列
|
void |
removeRow(int row)
删除指定行
|
void |
setAttribute(java.lang.String pName,
java.lang.String pValue)
设置属性
|
void |
setColAttribute(int col,
java.lang.String name,
java.lang.String value)
设置指定列的所有单元格的属性
|
void |
setColor(int row,
int col,
java.lang.String str)
设置指定单元格字体颜色
|
void |
setColWidth(int col,
java.lang.String width)
设置指定列的所有单元格的宽度
|
void |
setFont(int row,
int col,
java.lang.String str)
设置指定单元格的字体
|
void |
setFontSize(int row,
int col,
java.lang.String str)
设置指定单元格字体大小
|
void |
setInitTDWidth(boolean init)
设置是否初始化TD的宽度,这一函数必须在构造出HTMLTable之后,而在createTable调用之前
|
void |
setRangeAttribute(int row1,
int col1,
int row2,
int col2,
java.lang.String name,
java.lang.String value)
设置指定范围的单元格的属性
|
void |
setRangeFormat(int row1,
int col1,
int row2,
int col2,
java.text.Format ft)
设置指定范围的单元格的格式
|
void |
setRowAttribute(int row,
java.lang.String name,
java.lang.String value)
设置指定行的所有单元格的属性
|
void |
setRowHeight(int row,
java.lang.String height)
设置指定行的所有单元格的高度
|
void |
setStrong(int row,
int col,
boolean bool)
设置指定单元格文字是否加粗
|
void |
setTDAlign(int sRow,
int sCol,
int eRow,
int eCol,
java.lang.String alignType)
设置一个区域的对齐方式
|
void |
setTDAttribute(int row,
int col,
java.lang.String pName,
java.lang.String pValue)
设置指定单元格的属性值
|
void |
setTDFormat(int row,
int col,
java.text.Format ft)
设置指定单元格的格式
|
void |
setTDFormat(int sRow,
int sCol,
int eRow,
int eCol,
java.text.Format ft)
设置一个区域的数据显示格式
|
void |
setTH(int row,
boolean bool)
设置指定行的单元格是否是TH
|
void |
setTH(int row,
int col,
boolean bool)
设置指定单元格是否是TH
|
void |
setTRAttribute(int row,
java.lang.String pName,
java.lang.String pValue)
设置指定tr的属性
|
void |
setValue(int row,
int col,
java.lang.Object obj)
设置指定单元格的文字内容
|
void |
setValue(int row,
int col,
java.lang.String value)
设置指定单元格的文字内容
|
void |
TDMerge(int row1,
int col1,
int row2,
int col2)
合并指定的单元格
|
public HTMLTable()
public HTMLTable(boolean createTableTag)
createTableTag
- booleanpublic void createTable(int rows, int cols) throws java.lang.Exception
rows
- 行数cols
- 列数java.lang.Exception
- Exceptionpublic void insertCol(int col) throws java.lang.Exception
col
- 列号,如果是插入到最前面,则为-1java.lang.Exception
- Exceptionpublic void insertRow(int row) throws java.lang.Exception
row
- 行号,如果是插入到最前面,则为-1java.lang.Exception
- Exceptionpublic void removeCol(int col) throws java.lang.Exception
col
- 列号java.lang.Exception
- Exceptionpublic void removeRow(int row) throws java.lang.Exception
row
- 行号java.lang.Exception
- Exceptionpublic void autoRangeMerge(int row1, int col1, int row2, int col2) throws java.lang.Exception
row1
- 起始行号col1
- 起始列号row2
- 结束行号col2
- 结束列号java.lang.Exception
- Exceptionpublic void autoRowMerge(int row) throws java.lang.Exception
row
- 行号java.lang.Exception
- Exceptionpublic void autoColMerge(int col) throws java.lang.Exception
col
- 列号java.lang.Exception
- Exceptionpublic void TDMerge(int row1, int col1, int row2, int col2) throws java.lang.Exception
row1
- 起始行号col1
- 起始列号row2
- 结束行号col2
- 结束列号java.lang.Exception
- Exceptionpublic void setAttribute(java.lang.String pName, java.lang.String pValue)
pName
- 属性名pValue
- 属性值(如果是无值的属性,则该值为"")public void setTDAttribute(int row, int col, java.lang.String pName, java.lang.String pValue) throws java.lang.Exception
row
- 行号col
- 列号pName
- 属性名pValue
- 属性值(如果是无值的属性,如nowrap,则该值为"")java.lang.Exception
- Exceptionpublic void setTRAttribute(int row, java.lang.String pName, java.lang.String pValue) throws java.lang.Exception
row
- 行号pName
- 属性名pValue
- 属性值(如果是无值的属性,则该值为"")java.lang.Exception
- Exceptionpublic void setValue(int row, int col, java.lang.String value) throws java.lang.Exception
row
- 行号col
- 列号value
- 文字内容java.lang.Exception
- Exceptionpublic void setValue(int row, int col, java.lang.Object obj) throws java.lang.Exception
row
- 行号col
- 列号obj
- 文字内容的对象java.lang.Exception
- Exceptionpublic java.lang.Object getValue(int row, int col) throws java.lang.Exception
row
- 行号col
- 列号java.lang.Exception
- Exceptionpublic void setFont(int row, int col, java.lang.String str) throws java.lang.Exception
row
- 行号col
- 列号str
- 字体字符串,如"宋体"java.lang.Exception
- Exceptionpublic void setFontSize(int row, int col, java.lang.String str) throws java.lang.Exception
row
- 行号col
- 列号str
- 字体大小,如"11pt"java.lang.Exception
- Exceptionpublic void setColor(int row, int col, java.lang.String str) throws java.lang.Exception
row
- 行号col
- 列号str
- 颜色字符串,如"#FF0000",或"RED",同html的颜色描述java.lang.Exception
- Exceptionpublic void setStrong(int row, int col, boolean bool) throws java.lang.Exception
row
- 行号col
- 列号bool
- true或falsejava.lang.Exception
- Exceptionpublic void setRowHeight(int row, java.lang.String height) throws java.lang.Exception
row
- 行号height
- 高度java.lang.Exception
- Exceptionpublic void setColWidth(int col, java.lang.String width) throws java.lang.Exception
col
- 列号width
- 宽度,如"20%"或"40"java.lang.Exception
- Exceptionpublic void setRowAttribute(int row, java.lang.String name, java.lang.String value) throws java.lang.Exception
row
- 行号name
- 属性名value
- 属性值java.lang.Exception
- Exceptionpublic void setColAttribute(int col, java.lang.String name, java.lang.String value) throws java.lang.Exception
col
- 列号name
- 属性名value
- 属性值java.lang.Exception
- Exceptionpublic void setRangeAttribute(int row1, int col1, int row2, int col2, java.lang.String name, java.lang.String value) throws java.lang.Exception
row1
- 起始行号col1
- 起始列号row2
- 结束行号col2
- 结束列号name
- 属性名value
- 属性值java.lang.Exception
- Exceptionpublic void setTDFormat(int row, int col, java.text.Format ft) throws java.lang.Exception
row
- 行号col
- 列号ft
- 格式 java.text.DecimalFormat java.text.SimpleDateFormat java.text.NumberFormatjava.lang.Exception
- Exceptionpublic void setTDFormat(int sRow, int sCol, int eRow, int eCol, java.text.Format ft) throws java.lang.Exception
sRow
- int 起始行sCol
- int 起始列eRow
- int 结束行eCol
- int 结束列ft
- 格式 java.text.DecimalFormat java.text.SimpleDateFormat java.text.NumberFormatjava.lang.Exception
- Exceptionpublic void setTDAlign(int sRow, int sCol, int eRow, int eCol, java.lang.String alignType) throws java.lang.Exception
sRow
- int 起始行sCol
- int 起始列eRow
- int 结束行eCol
- int 结束列alignType
- String 对齐类型,C居中、L左对齐、R右对齐java.lang.Exception
- Exceptionpublic void setRangeFormat(int row1, int col1, int row2, int col2, java.text.Format ft) throws java.lang.Exception
row1
- 起始行号col1
- 起始列号row2
- 结束行号col2
- 结束列号ft
- 格式 java.text.DecimalFormat java.text.SimpleDateFormat java.text.NumberFormatjava.lang.Exception
- Exceptionpublic void setTH(int row, int col, boolean bool) throws java.lang.Exception
row
- intcol
- intbool
- booleanjava.lang.Exception
- Exceptionpublic void setTH(int row, boolean bool) throws java.lang.Exception
row
- intbool
- booleanjava.lang.Exception
- Exceptionpublic java.lang.String getHTML() throws java.lang.Exception
java.lang.Exception
- Exceptionpublic static HTMLTable createHTMLTable(Datastore ds, java.lang.String[] colsName)
ds
- Datastore 数据中心colsName[]
- String 输出Datastore中的列清单public static HTMLTable createHTMLTable(Datastore ds)
ds
- Datastore 数据集public void setInitTDWidth(boolean init)
init
- boolean true采用均分的方式初始化,false不初始化