首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

研讨生成excel的方法

2012-09-10 
探讨生成excel的方法附加源码探讨[解决办法]dtElement((Element)((Element)worksheetNode).getElementsBy

探讨生成excel的方法
附加源码探讨

[解决办法]
dtElement=((Element)((Element)worksheetNode).getElementsByTagName("Table").item(0));
dtRowlist=dtElement.getElementsByTagName("Row");
dtColumnWidthlist=dtElement.getElementsByTagName("Column");
rowLastColumn=dtColumnWidthlist.item(dtColumnWidthlist.getLength()-1).cloneNode(true);
dtRowlistTitle=((Element)dtElement.getElementsByTagName("Row").item(0)).getElementsByTagName("Cell").item(1).cloneNode(true);
dtTitle =(Element)dtRowlist.item(4).cloneNode(true); 
dtContxt=(Element)dtRowlist.item(5).cloneNode(true);
dtSumContxt=(Element)dtRowlist.item(6).cloneNode(true);
dtLastSumPrivContxt=(Element)dtRowlist.item(7).cloneNode(true);
dtLastSumContxt=(Element)dtRowlist.item(8).cloneNode(true);

if((null!=dtRowlist)&&(dtRowlist.getLength()>=4)){
for(int i=0;i<4;i++){
dtCelllist = ((Element)dtRowlist.item(i)).getElementsByTagName("Cell");
int is= dtCelllist.getLength();
for(int jj=0;jj<is;jj++){
if(((Element)dtCelllist.item(jj).getFirstChild())!=null){
for(SCSKColumnModel scm:this.localSCSKColumnModellist){
if(scm.isAlreadyAddColumn()){continue;}
if(0==scm.getChildColumnName().trim().indexOf("D")&&(!scm.isAlreadyAddColumn())){
((Element)dtLastSumPrivContxt).getElementsByTagName("Cell").item(0).getFirstChild().setTextContent(scm.getChildColumnAsName());
scm.setZAlreadyAddColumn(true);
continue;
}
if(scm.getChildColumnName().trim().equals(((Element)dtCelllist.item(jj).getFirstChild()).getTextContent().trim())){
String tempIndex=((Element)dtCelllist.item(jj).getFirstChild()).getTextContent();
((Element)dtCelllist.item(jj).getFirstChild()).setTextContent((scm.getChildColumnAsName().trim().equals("")?scm.getChildColumnName():scm.getChildColumnAsName()));

if(scm.isDataColumn()){
int _cellIndx= Integer.valueOf(tempIndex.replace("A",""))-1;
((Element)dtCelllist.item(jj)).setAttribute("ss:userColumnAsName","_"+scm.getChildColumnName().trim()+"_"+i+"_"+String.valueOf(jj));
if(scm.isHidden()){
setHiddenColumnMark((Element)dtContxt,"ss:userColumnIsHidden",_cellIndx);
setHiddenColumnMark((Element)dtSumContxt,"ss:userColumnIsHidden",_cellIndx);
setHiddenColumnMark((Element)dtLastSumContxt,"ss:userColumnIsHidden",_cellIndx);
((Element)dtColumnWidthlist.item(_cellIndx)).setAttribute("ss:Hidden", "1");
}
setHiddenColumnMark((Element)dtContxt,"ss:userIsDataColumn",_cellIndx);
setHiddenColumnMark((Element)dtSumContxt,"ss:userIsDataColumn",_cellIndx);
setHiddenColumnMark((Element)dtLastSumContxt,"ss:userIsDataColumn",_cellIndx);

if(scm.isTotal()){
setHiddenColumnMark((Element)dtContxt,"ss:userIsTotal",_cellIndx);
setHiddenColumnMark((Element)dtSumContxt,"ss:userIsTotal",_cellIndx);
setHiddenColumnMark((Element)dtLastSumContxt,"ss:userIsTotal",_cellIndx);
if(scm.isTotalTimes()){
setHiddenColumnMark((Element)dtContxt,"ss:userIsTotalTimes",_cellIndx);
setHiddenColumnMark((Element)dtSumContxt,"ss:userIsTotalTimes",_cellIndx);
setHiddenColumnMark((Element)dtLastSumContxt,"ss:userIsTotalTimes",_cellIndx)

热点排行